From 7147463418b9c3aad9bbbcd2c6c0f0308d4045ab Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Mon, 19 Jun 2023 09:56:23 +0200 Subject: [PATCH 1/4] dockerfile: update docker to 24.0.2 Signed-off-by: CrazyMax --- Dockerfile | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 91601323..215891fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,13 +2,12 @@ ARG GO_VERSION=1.20 ARG XX_VERSION=1.2.1 -ARG DOCKERD_VERSION=20.10.14 + +ARG DOCKER_VERSION=24.0.2 ARG GOTESTSUM_VERSION=v1.9.0 ARG REGISTRY_VERSION=2.8.0 ARG BUILDKIT_VERSION=v0.11.6 -FROM docker:$DOCKERD_VERSION AS dockerd-release - # xx is a helper for cross-compilation FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx @@ -25,6 +24,22 @@ FROM registry:$REGISTRY_VERSION AS registry FROM moby/buildkit:$BUILDKIT_VERSION AS buildkit +FROM gobase AS docker +ARG TARGETPLATFORM +ARG DOCKER_VERSION +WORKDIR /opt/docker +RUN DOCKER_ARCH=$(case ${TARGETPLATFORM:-linux/amd64} in \ + "linux/amd64") echo "x86_64" ;; \ + "linux/arm/v6") echo "armel" ;; \ + "linux/arm/v7") echo "armhf" ;; \ + "linux/arm64") echo "aarch64" ;; \ + "linux/ppc64le") echo "ppc64le" ;; \ + "linux/s390x") echo "s390x" ;; \ + *) echo "" ;; esac) \ + && echo "DOCKER_ARCH=$DOCKER_ARCH" \ + && wget -qO- "https://download.docker.com/linux/static/stable/${DOCKER_ARCH}/docker-${DOCKER_VERSION}.tgz" | tar xvz --strip 1 +RUN ./dockerd --version && ./containerd --version && ./ctr --version && ./runc --version + FROM gobase AS gotestsum ARG GOTESTSUM_VERSION ENV GOFLAGS= @@ -77,9 +92,20 @@ FROM binaries-$TARGETOS AS binaries ARG BUILDKIT_SBOM_SCAN_STAGE=true FROM gobase AS integration-test-base -RUN apk add --no-cache docker runc containerd +# https://github.com/docker/docker/blob/master/project/PACKAGERS.md#runtime-dependencies +RUN apk add --no-cache \ + btrfs-progs \ + e2fsprogs \ + e2fsprogs-extra \ + ip6tables \ + iptables \ + openssl \ + shadow-uidmap \ + xfsprogs \ + xz COPY --link --from=gotestsum /out/gotestsum /usr/bin/ COPY --link --from=registry /bin/registry /usr/bin/ +COPY --link --from=docker /opt/docker/* /usr/bin/ COPY --link --from=buildkit /usr/bin/buildkitd /usr/bin/ COPY --link --from=buildkit /usr/bin/buildctl /usr/bin/ COPY --link --from=binaries /buildx /usr/bin/ @@ -102,7 +128,7 @@ FROM scratch AS release COPY --from=releaser /out/ / # Shell -FROM docker:$DOCKERD_VERSION AS dockerd-release +FROM docker:$DOCKER_VERSION AS dockerd-release FROM alpine AS shell RUN apk add --no-cache iptables tmux git vim less openssh RUN mkdir -p /usr/local/lib/docker/cli-plugins && ln -s /usr/local/bin/buildx /usr/local/lib/docker/cli-plugins/docker-buildx From 2235ebce2f72a5a443971bc72cc296fbfb1f170e Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Mon, 19 Jun 2023 08:57:46 +0200 Subject: [PATCH 2/4] test: register docker worker with containerd snapshotter Signed-off-by: CrazyMax --- .github/workflows/build.yml | 5 +++-- tests/workers/docker.go | 10 ++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 912e9a20..ee04de4a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -66,6 +66,7 @@ jobs: matrix: worker: - docker + - docker\+containerd # same as docker, but with containerd snapshotter - docker-container - remote pkg: @@ -101,8 +102,8 @@ jobs: export TEST_REPORT_SUFFIX=-${{ github.job }}-$(echo "${{ matrix.pkg }}-${{ matrix.skip-integration-tests }}-${{ matrix.worker }}" | tr -dc '[:alnum:]-\n\r' | tr '[:upper:]' '[:lower:]') ./hack/test env: - TEST_DOCKERD: "${{ (matrix.worker == 'docker' || matrix.worker == 'docker-container') && '1' || '0' }}" - TESTFLAGS: "${{ (matrix.worker == 'docker') && env.TESTFLAGS_DOCKER || env.TESTFLAGS }} --run=//worker=${{ matrix.worker }}$" + TEST_DOCKERD: "${{ startsWith(matrix.worker, 'docker') && '1' || '0' }}" + TESTFLAGS: "${{ (matrix.worker == 'docker' || matrix.worker == 'docker\\+containerd') && env.TESTFLAGS_DOCKER || env.TESTFLAGS }} --run=//worker=${{ matrix.worker }}$" TESTPKGS: "${{ matrix.pkg }}" SKIP_INTEGRATION_TESTS: "${{ matrix.skip-integration-tests }}" - diff --git a/tests/workers/docker.go b/tests/workers/docker.go index 3ba32940..347ca87d 100644 --- a/tests/workers/docker.go +++ b/tests/workers/docker.go @@ -14,10 +14,15 @@ func InitDockerWorker() { integration.Register(&dockerWorker{ id: "docker", }) + integration.Register(&dockerWorker{ + id: "docker+containerd", + containerdSnapshotter: true, + }) } type dockerWorker struct { - id string + id string + containerdSnapshotter bool } func (c dockerWorker) Name() string { @@ -30,7 +35,8 @@ func (c dockerWorker) Rootless() bool { func (c dockerWorker) New(ctx context.Context, cfg *integration.BackendConfig) (b integration.Backend, cl func() error, err error) { moby := integration.Moby{ - ID: c.id, + ID: c.id, + ContainerdSnapshotter: c.containerdSnapshotter, } bk, bkclose, err := moby.New(ctx, cfg) if err != nil { From 75ecc15958d30c33031d1196033776663900d693 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Mon, 19 Jun 2023 08:50:28 +0200 Subject: [PATCH 3/4] test: fix inspect and ls Signed-off-by: CrazyMax --- tests/inspect.go | 4 +++- tests/ls.go | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/inspect.go b/tests/inspect.go index 207d495e..9bfb5e4d 100644 --- a/tests/inspect.go +++ b/tests/inspect.go @@ -33,6 +33,8 @@ func testInspect(t *testing.T, sb integration.Sandbox) { driver = strings.TrimSpace(v) } } + require.Equal(t, sb.Address(), name) - require.Equal(t, sb.Name(), driver) + sbDriver, _, _ := strings.Cut(sb.Name(), "+") + require.Equal(t, sbDriver, driver) } diff --git a/tests/ls.go b/tests/ls.go index a072d2af..a45b2675 100644 --- a/tests/ls.go +++ b/tests/ls.go @@ -23,9 +23,10 @@ func testLs(t *testing.T, sb integration.Sandbox) { out, err := lsCmd(sb) require.NoError(t, err, string(out)) + sbDriver, _, _ := strings.Cut(sb.Name(), "+") for _, line := range strings.Split(out, "\n") { if strings.Contains(line, sb.Address()) { - require.Contains(t, line, sb.Name()) + require.Contains(t, line, sbDriver) return } } From 28a1eb3527c9292e80acded4bcbf8ca69813acd5 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Mon, 19 Jun 2023 11:26:00 +0200 Subject: [PATCH 4/4] test: fix testImageIDOutput Signed-off-by: CrazyMax --- tests/build.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/build.go b/tests/build.go index f82c80b3..b380071c 100644 --- a/tests/build.go +++ b/tests/build.go @@ -106,7 +106,7 @@ func testImageIDOutput(t *testing.T, sb integration.Sandbox) { cmd := buildxCmd( sb, - withArgs("build", "-q", outFlag, "--iidfile", filepath.Join(targetDir, "iid.txt"), "--metadata-file", filepath.Join(targetDir, "md.json"), dir), + withArgs("build", "-q", "--provenance", "false", outFlag, "--iidfile", filepath.Join(targetDir, "iid.txt"), "--metadata-file", filepath.Join(targetDir, "md.json"), dir), ) stdout := bytes.NewBuffer(nil) cmd.Stdout = stdout