diff --git a/integration/build_test.go b/integration/build_test.go index eb46951049f..ced97c54fdd 100644 --- a/integration/build_test.go +++ b/integration/build_test.go @@ -53,6 +53,11 @@ func TestBuild(t *testing.T) { description: "docker build", dir: "testdata/build", }, + { + setup: setupBuildX, + description: "docker buildx", + dir: "testdata/buildx", + }, { description: "git tagger", dir: "testdata/tagPolicy", @@ -314,6 +319,36 @@ func setupGitRepo(t *testing.T, dir string) { } } +// setupBuildX sets up a docker buildx builder using buildkit +func setupBuildX(t *testing.T, dir string) { + t.Cleanup(func() { + dockerArgs := [][]string{ + {"buildx", "uninstall"}, + {"buildx", "rm", "buildkit"}, + } + for _, args := range dockerArgs { + cmd := exec.Command("docker", args...) + if buf, err := util.RunCmdOut(context.Background(), cmd); err != nil { + t.Log(string(buf)) + t.Fatal(err) + } + } + + }) + + dockerArgs := [][]string{ + {"buildx", "install"}, + {"buildx", "create", "--driver", "docker-container", "--name", "buildkit"}, + } + for _, args := range dockerArgs { + cmd := exec.Command("docker", args...) + if buf, err := util.RunCmdOut(context.Background(), cmd); err != nil { + t.Log(string(buf)) + t.Fatal(err) + } + } +} + // nowInChicago returns the dateTime string as generated by the dateTime tagger func nowInChicago() string { loc, _ := tz.LoadLocation("America/Chicago") diff --git a/integration/testdata/buildx/Dockerfile b/integration/testdata/buildx/Dockerfile new file mode 100644 index 00000000000..056a4cac066 --- /dev/null +++ b/integration/testdata/buildx/Dockerfile @@ -0,0 +1,12 @@ +# syntax=docker/dockerfile:1 + +FROM busybox as base + +RUN cat <<< "echo hello world" > app.sh +RUN chmod 755 app.sh + +FROM alpine:3 + +COPY --from base app.sh + +CMD ./app.sh diff --git a/integration/testdata/buildx/skaffold.yaml b/integration/testdata/buildx/skaffold.yaml new file mode 100644 index 00000000000..5ef3a91d922 --- /dev/null +++ b/integration/testdata/buildx/skaffold.yaml @@ -0,0 +1,13 @@ +apiVersion: skaffold/v4beta12 +kind: Config +build: + artifacts: + - image: my-app + docker: + dockerfile: Dockerfile + cacheFrom: + - "my-app" + local: + useBuildkit: true + useDockerCLI: true + tryImportMissing: true