From 4100226e273b54be36c55a0d34f12437a54a03d2 Mon Sep 17 00:00:00 2001 From: Kevin Alvarez Date: Wed, 18 Jan 2023 18:41:16 +0100 Subject: [PATCH 1/2] Dockerfile: use clang to build dockerd/docker-proxy Static binaries for dockerd are broken on armhf and armel (32-bit). It seems to be an issue with GCC as building using clang solves this issue. Also adds extra instruction to prefer ld for cross-compiling arm64 in bullseye otherwise it doesn't link. Signed-off-by: CrazyMax (cherry picked from commit f676dab8dc58c9eaa83b260c631a92d95a7a0b10) --- Dockerfile | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Dockerfile b/Dockerfile index 6334ce3db6..12839f06fd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -549,6 +549,12 @@ WORKDIR /go/src/github.com/docker/docker ENV GO111MODULE=off ENV CGO_ENABLED=1 ARG DEBIAN_FRONTEND +RUN --mount=type=cache,sharing=locked,id=moby-build-aptlib,target=/var/lib/apt \ + --mount=type=cache,sharing=locked,id=moby-build-aptcache,target=/var/cache/apt \ + apt-get update && apt-get install --no-install-recommends -y \ + clang \ + lld \ + llvm ARG TARGETPLATFORM RUN --mount=type=cache,sharing=locked,id=moby-build-aptlib,target=/var/lib/apt \ --mount=type=cache,sharing=locked,id=moby-build-aptcache,target=/var/cache/apt \ @@ -575,6 +581,12 @@ ARG PACKAGER_NAME # PREFIX overrides DEST dir in make.sh script otherwise it fails because of # read only mount in current work dir ENV PREFIX=/tmp +RUN < Date: Wed, 18 Jan 2023 11:40:37 +0100 Subject: [PATCH 2/2] Dockerfile: smoke tests for static builds Adds smoke test stage in our Dockerfile and a GitHub Action workflow Signed-off-by: CrazyMax (cherry picked from commit 518be73a5c004da831d3db7d59b67a36934b0ee0) --- .github/workflows/test.yml | 52 ++++++++++++++++++++++++++++++++++++++ Dockerfile | 14 ++++++++++ docker-bake.hcl | 14 ++++++++++ 3 files changed, 80 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7c1f4ab2cb..24f585c11b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -502,3 +502,55 @@ jobs: name: Create summary run: | teststat -markdown $(find /tmp/reports -type f -name '*.json' -print0 | xargs -0) >> $GITHUB_STEP_SUMMARY + + prepare-smoke: + runs-on: ubuntu-20.04 + needs: + - validate-dco + outputs: + matrix: ${{ steps.platforms.outputs.matrix }} + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Create matrix + id: platforms + run: | + matrix="$(docker buildx bake binary-smoketest --print | jq -cr '.target."binary-smoketest".platforms')" + echo "matrix=$matrix" >> $GITHUB_OUTPUT + - + name: Show matrix + run: | + echo ${{ steps.platforms.outputs.matrix }} + + smoke: + runs-on: ubuntu-20.04 + needs: + - prepare-smoke + strategy: + fail-fast: false + matrix: + platform: ${{ fromJson(needs.prepare-smoke.outputs.matrix) }} + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Prepare + run: | + platform=${{ matrix.platform }} + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV + - + name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - + name: Test + uses: docker/bake-action@v2 + with: + targets: binary-smoketest + set: | + *.platform=${{ matrix.platform }} diff --git a/Dockerfile b/Dockerfile index 12839f06fd..19f9963310 100644 --- a/Dockerfile +++ b/Dockerfile @@ -621,6 +621,20 @@ COPY --from=containerutil /build/ / COPY --from=vpnkit / / COPY --from=build /build / +# smoke tests +# usage: +# > docker buildx bake binary-smoketest +FROM --platform=$TARGETPLATFORM base AS smoketest +WORKDIR /usr/local/bin +COPY --from=build /build . +RUN < make shell # > SYSTEMD=true make shell diff --git a/docker-bake.hcl b/docker-bake.hcl index 95c1c6bcff..899551f9e4 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -124,6 +124,20 @@ target "binary-cross" { inherits = ["binary", "_platforms"] } +target "binary-smoketest" { + inherits = ["_common"] + target = "smoketest" + output = ["type=cacheonly"] + platforms = [ + "linux/amd64", + "linux/arm/v6", + "linux/arm/v7", + "linux/arm64", + "linux/ppc64le", + "linux/s390x" + ] +} + # # same as binary but with extra tools as well (containerd, runc, ...) #