Created
April 1, 2022 18:45
-
-
Save developer-guy/373d393a36ab5fc3ff164710aafe3a08 to your computer and use it in GitHub Desktop.
Revisions
-
developer-guy created this gist
Apr 1, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ package main import ( "context" "os" "github.com/moby/buildkit/client/llb" ) func createLLBState() llb.State { base := llb.Image("docker.io/library/alpine") base = base. File(llb.Mkdir("/tmp/dir", 0755)). File(llb.Copy(llb.Local("context"), "README.md", "/tmp/dir/README.md")). File(llb.Copy(llb.Local("context"), "README.md", "README.md")) anotbase := llb.Image("docker.io/library/alpine:3.6") anotbase = anotbase.Run(llb.Shlexf("cp -a /tmp/dir/%s /tmp/dir/%s", "README.md", "README.copy.md")). AddMount("/", base) return anotbase.Run(llb.Args([]string{"/bin/sh"})).Root() } func main() { dt, err := createLLBState().Marshal(context.TODO(), llb.LinuxAmd64) if err != nil { panic(err) } llb.WriteTo(dt, os.Stdout) } # go run main.go | buildctl debug dumb-llb | jq