Skip to content

Commit

Permalink
feat: multi-stage-push
Browse files Browse the repository at this point in the history
feat: multi stage push
  • Loading branch information
jrasm91 authored Nov 7, 2023
2 parents bee631e + d04b1ab commit 74bbebb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
22 changes: 12 additions & 10 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
pull_request:
branches: [main]
schedule:
- cron: '0 8 * * 5'
- cron: "0 8 * * 5"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -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
Expand Down Expand Up @@ -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/[email protected]
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
2 changes: 1 addition & 1 deletion server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 74bbebb

Please sign in to comment.