Created
April 1, 2022 18:45
-
-
Save developer-guy/373d393a36ab5fc3ff164710aafe3a08 to your computer and use it in GitHub Desktop.
create LLB state
This file contains 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 characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment