From 699842748f091c0ed11abd2d69c85bbd99eb9a1f Mon Sep 17 00:00:00 2001 From: Caleb Xavier Berger Date: Tue, 19 Jan 2021 01:01:09 -0500 Subject: [PATCH] Use BuildKit/buildx autopopulated ARGs for getting builder image --- .github/workflows/Dockerfile.copyin | 12 ++++++++---- .github/workflows/cross-compiling-docker.yml | 7 ++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/Dockerfile.copyin b/.github/workflows/Dockerfile.copyin index e2f6ae7c2..d29fd7c7f 100644 --- a/.github/workflows/Dockerfile.copyin +++ b/.github/workflows/Dockerfile.copyin @@ -1,12 +1,16 @@ +ARG builder +ARG TARGETARCH + +# https://stackoverflow.com/a/63472135/3551604 +FROM ${TARGETARCH}/${builder}:latest as builder + FROM alpine:latest -ARG BUILDER= -ARG BUILDER_TAG= -ARG DENDRITE_BINARY= +ARG DENDRITE_BINARY ENV DENDRITE_BINARY=${DENDRITE_BINARY} -COPY --from=${BUILDER}:${BUILDER_TAG} /build/bin/* /usr/bin +COPY --from=builder /build/bin/* /usr/bin/ VOLUME /etc/dendrite WORKDIR /etc/dendrite diff --git a/.github/workflows/cross-compiling-docker.yml b/.github/workflows/cross-compiling-docker.yml index 4ab27d72d..139fcbc8b 100644 --- a/.github/workflows/cross-compiling-docker.yml +++ b/.github/workflows/cross-compiling-docker.yml @@ -20,6 +20,8 @@ jobs: - 5000:5000 steps: - uses: actions/checkout@v2 + - name: set docker target + run: echo "DOCKER_TARGET=$(./.github/workflows/get-compiler.sh docker)" >> $GITHUB_ENV - uses: docker/setup-buildx-action@v1 with: driver-opts: network=host @@ -29,10 +31,9 @@ jobs: context: . file: ./.github/workflows/Dockerfile.builder load: true # load into local image store - tags: "${{ env.BUILDER_IMAGE_NAME }}:${{ matrix.target }}" + tags: "${{ env.DOCKER_TARGET }}/${{ env.BUILDER_IMAGE_NAME }}:latest" build-args: "GOARCH=${{ env.GOARCH }}" # - run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - run: echo "DOCKER_TARGET=$(./.github/workflows/get-compiler.sh docker)" >> $GITHUB_ENV - uses: docker/setup-qemu-action@v1 - name: build monolith uses: docker/build-push-action@v2 @@ -42,4 +43,4 @@ jobs: platforms: ${{ env.DOCKER_TARGET }} push: true tags: localhost:5000/matrixdotorg/dendrite-monolith:latest - build-args: "BUILDER=${{ env.BUILDER_IMAGE_NAME }}\nBUILDER_TAG=${{ env.GOARCH }}\nDENDRITE_BINARY=dendrite-monolith-server" + build-args: "builder=${{ env.BUILDER_IMAGE_NAME }}\nDENDRITE_BINARY=dendrite-monolith-server"