Skip to content

Instantly share code, notes, and snippets.

@Aposhian
Created November 7, 2022 23:35
Show Gist options
  • Save Aposhian/44a24f7460f9df09baa14b48ae4e7e07 to your computer and use it in GitHub Desktop.
Save Aposhian/44a24f7460f9df09baa14b48ae4e7e07 to your computer and use it in GitHub Desktop.
LLB Build
#!/usr/bin/env
if [ -z "$(docker ps --filter=name=buildkitd -q)" ];
then
docker run -d --name buildkitd --privileged moby/buildkit:latest
fi
export BUILDKIT_HOST=docker-container://buildkitd
go run main.go | buildctl build
module example.com/build/v2
go 1.18
require (
github.com/containerd/containerd v1.6.3-0.20220401172941-5ff8fce1fcc6 // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/moby/buildkit v0.10.5 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
golang.org/x/crypto v0.0.0-20211202192323-5770296d904e // indirect
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa // indirect
google.golang.org/grpc v1.45.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
)
package main
import (
"os"
"context"
"github.com/moby/buildkit/client/llb"
)
func main() {
image := llb.Image("docker.io/library/debian:latest")
newimage := image.Run(llb.Shlex("apt-get update"))
dt, err := newimage.Marshal(context.Background(), llb.LinuxAmd64)
if err != nil {
panic(err)
}
llb.WriteTo(dt, os.Stdout)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment