From d04b1abedf1f95b3a119ca26a46e935e0f8ba9af Mon Sep 17 00:00:00 2001 From: Jason Rasmussen Date: Mon, 6 Nov 2023 18:58:00 -0500 Subject: [PATCH] feat: multi stage push --- .github/workflows/docker.yml | 22 ++++++++++++---------- server/Dockerfile | 2 +- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 1741cd7..c08f909 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -6,7 +6,7 @@ on: pull_request: branches: [main] schedule: - - cron: '0 8 * * 5' + - cron: "0 8 * * 5" concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -19,14 +19,14 @@ jobs: build_and_push: runs-on: self-hosted strategy: - # Prevent a failure in one image from stopping the other builds - fail-fast: false + max-parallel: 1 + fail-fast: true matrix: + target: ["dev", "prod"] include: - context: "server" image: "base-server" platforms: "linux/amd64,linux/arm64" - stages: "dev,runtime" steps: - name: Checkout @@ -55,24 +55,26 @@ jobs: # Disable latest tag latest=false images: | - name=ghcr.io/${{ github.repository_owner }}/${{matrix.image}} + name=ghcr.io/${{ github.repository_owner }}/${{ matrix.image }}-${{ matrix.target }} tags: | # Tag scheduled runs with date - type=schedule,pattern={{date 'YYYYMMDD'}},suffix=-${{ matrix.stages }} + type=schedule,pattern={{date 'YYYYMMDD'}} # Tag with branch name - type=ref,event=branch,suffix=-${{ matrix.stages }} + type=ref,event=branch # Tag with pr-number - type=ref,event=pr,suffix=-${{ matrix.stages }} + type=ref,event=pr # Tag with git tag on release - type=ref,event=tag,suffix=-${{ matrix.stages }} + type=ref,event=tag - name: Build and push image uses: docker/build-push-action@v5.0.0 with: context: ${{ matrix.context }} + target: ${{ matrix.target }} platforms: ${{ matrix.platforms }} # Skip pushing when PR from a fork push: ${{ !github.event.pull_request.head.repo.fork }} tags: ${{ steps.metadata.outputs.tags }} labels: ${{ steps.metadata.outputs.labels }} - target: ${{ matrix.stages }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/server/Dockerfile b/server/Dockerfile index 2c18fad..6a4fd91 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -33,7 +33,7 @@ RUN ./build-libraw.sh RUN ./build-imagemagick.sh RUN ./build-libvips.sh -FROM node:20.8-bookworm-slim as runtime +FROM node:20.8-bookworm-slim as prod WORKDIR /usr/src/app