From cc46934d38285a5a5fad0e124d2969514a8e77ab Mon Sep 17 00:00:00 2001 From: Caleb Xavier Berger Date: Mon, 18 Jan 2021 23:54:33 -0500 Subject: [PATCH] Copy built files directly from builder image --- .github/workflows/Dockerfile.copyin | 6 ++- .github/workflows/cross-compiling-docker.yml | 46 +++++++------------- 2 files changed, 19 insertions(+), 33 deletions(-) diff --git a/.github/workflows/Dockerfile.copyin b/.github/workflows/Dockerfile.copyin index a89051cb7..e2f6ae7c2 100644 --- a/.github/workflows/Dockerfile.copyin +++ b/.github/workflows/Dockerfile.copyin @@ -1,10 +1,12 @@ FROM alpine:latest +ARG BUILDER= +ARG BUILDER_TAG= ARG DENDRITE_BINARY= -ARG BIN_DIRECTORY= + ENV DENDRITE_BINARY=${DENDRITE_BINARY} -COPY --from=builder /build/bin/* /usr/bin +COPY --from=${BUILDER}:${BUILDER_TAG} /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 99b657811..4ab27d72d 100644 --- a/.github/workflows/cross-compiling-docker.yml +++ b/.github/workflows/cross-compiling-docker.yml @@ -5,57 +5,41 @@ on: push jobs: compile: + runs-on: ubuntu-latest strategy: matrix: target: [amd64, arm64, arm] env: GOARCH: ${{ matrix.target }} - IMAGE_NAME: "dendrite-builder" - runs-on: ubuntu-latest + BUILDER_IMAGE_NAME: "dendrite-builder" + DOCKER_HUB_USER: dendritegithub + services: + registry: + image: registry:2 + ports: + - 5000:5000 steps: - uses: actions/checkout@v2 - uses: docker/setup-buildx-action@v1 + with: + driver-opts: network=host - name: build dendrite in Docker uses: docker/build-push-action@v2 with: context: . file: ./.github/workflows/Dockerfile.builder load: true # load into local image store - tags: "${{ env.IMAGE_NAME }}:${{ matrix.target }}" - - name: copy built files out of docker - run: docker run -v "$(pwd)/bin:/build/bin-out" "${{ env.IMAGE_NAME }}:${{ matrix.target }}" "/bin/sh" "-c" "cp -a /build/bin/* /build/bin-out" - - uses: actions/upload-artifact@v2 - with: - name: bin-${{ matrix.target }} - path: ./bin - build-monolith: - needs: [compile] - runs-on: ubuntu-latest - services: - registry: - image: registry:2 - ports: - - 5000:5000 - strategy: - matrix: - target: [amd64, arm64, arm] - env: - DOCKER_HUB_USER: dendritegithub - steps: - - uses: actions/checkout@v2 - - uses: actions/download-artifact@v2 - with: - name: bin-${{ matrix.target }} + tags: "${{ env.BUILDER_IMAGE_NAME }}:${{ matrix.target }}" + 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 - - uses: docker/setup-buildx-action@v1 - with: - driver-opts: network=host - - uses: docker/build-push-action@v2 + - name: build monolith + uses: docker/build-push-action@v2 with: context: . file: ./.github/workflows/Dockerfile.copyin 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"