From 7bb84355dff62e2019ad14098bf1068c7be4170e Mon Sep 17 00:00:00 2001 From: Benjamin Brummer Date: Mon, 20 Oct 2025 09:34:35 +0200 Subject: [PATCH 1/5] initial commit for manifest creation for multiple runners --- .github/workflows/build-image-debian.yaml | 67 ++++++++++++++++++++++- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-image-debian.yaml b/.github/workflows/build-image-debian.yaml index fb6e2be..528bda7 100644 --- a/.github/workflows/build-image-debian.yaml +++ b/.github/workflows/build-image-debian.yaml @@ -10,8 +10,11 @@ on: branches: - master +env: + REGISTRY_IMAGE: invoiceninja/invoiceninja-debian + jobs: - docker: + build: runs-on: ${{ startsWith(matrix.platforms, 'linux/arm') && 'ubuntu-24.04-arm' || 'ubuntu-latest' }} strategy: fail-fast: false @@ -21,6 +24,24 @@ jobs: - name: Checkout uses: actions/checkout@v5 + - name: Prepare + id: prep + run: | + platform=${{ matrix.platform }} + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY_IMAGE }} + + - name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v3 @@ -31,6 +52,48 @@ jobs: with: context: debian load: true - tags: invoiceninja/invoiceninja-debian:test + tags: ${{ env.REGISTRY_IMAGE }}:test cache-from: type=gha cache-to: type=gha,mode=max + + merge: + runs-on: ubuntu-latest + needs: + - build + steps: + - name: Download digests + uses: actions/download-artifact@v4 + with: + path: ${{ runner.temp }}/digests + pattern: digests-* + merge-multiple: true + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY_IMAGE }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + + - name: Create manifest list (--dry-run) + working-directory: ${{ runner.temp }}/digests + run: | + docker buildx imagetools create --dry-run $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ + $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) + + - name: Inspect image + run: | + docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} From fbb4bd29f7d402f46952bf0a9be18bba3241d6d1 Mon Sep 17 00:00:00 2001 From: Benjamin Brummer Date: Mon, 20 Oct 2025 10:31:21 +0200 Subject: [PATCH 2/5] handle digest --- .github/workflows/build-image-debian.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/build-image-debian.yaml b/.github/workflows/build-image-debian.yaml index 528bda7..2414cb2 100644 --- a/.github/workflows/build-image-debian.yaml +++ b/.github/workflows/build-image-debian.yaml @@ -53,9 +53,24 @@ jobs: context: debian load: true tags: ${{ env.REGISTRY_IMAGE }}:test + outputs: type=image,push-by-digest=true,name-canonical=true cache-from: type=gha cache-to: type=gha,mode=max + - name: Export digest + run: | + mkdir -p ${{ runner.temp }}/digests + digest="${{ steps.build.outputs.digest }}" + touch "${{ runner.temp }}/digests/${digest#sha256:}" + + - name: Upload digest + uses: actions/upload-artifact@v4 + with: + name: digests-${{ env.PLATFORM_PAIR }} + path: ${{ runner.temp }}/digests/* + if-no-files-found: error + retention-days: 1 + merge: runs-on: ubuntu-latest needs: From abeae7fb6419e52bae05cfa43d8062ed72c2a9df Mon Sep 17 00:00:00 2001 From: Benjamin Brummer Date: Mon, 20 Oct 2025 10:33:37 +0200 Subject: [PATCH 3/5] Publish manifest for multiple runners --- .github/workflows/publish-image.yaml | 92 +++++++++++++++++++++++----- 1 file changed, 78 insertions(+), 14 deletions(-) diff --git a/.github/workflows/publish-image.yaml b/.github/workflows/publish-image.yaml index c1a5d28..bca7668 100644 --- a/.github/workflows/publish-image.yaml +++ b/.github/workflows/publish-image.yaml @@ -5,16 +5,16 @@ on: tags-ignore: - "invoiceninja-*" +env: + REGISTRY_IMAGE: invoiceninja/invoiceninja-debian + jobs: - docker: + build: runs-on: ${{ startsWith(matrix.platforms, 'linux/arm') && 'ubuntu-24.04-arm' || 'ubuntu-latest' }} strategy: fail-fast: false matrix: platform: ["linux/amd64", "linux/arm64"] - include: - - image: invoiceninja/invoiceninja-debian - context: debian steps: - name: Checkout @@ -23,7 +23,10 @@ jobs: - name: Prepare id: prep run: | - DOCKER_IMAGE=${{ matrix.image }} + platform=${{ matrix.platform }} + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV + + DOCKER_IMAGE=${{ env.REGISTRY_IMAGE }} VERSION=edge if [[ $GITHUB_REF == refs/tags/* ]]; then VERSION=${GITHUB_REF#refs/tags/} @@ -43,32 +46,93 @@ jobs: echo "version=${VERSION}" >> $GITHUB_OUTPUT echo "major=${MAJOR}" >> $GITHUB_OUTPUT - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v3 + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY_IMAGE }} - name: Login to DockerHub - if: github.event_name != 'pull_request' uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - - name: Build and push + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push by digest id: docker_build uses: docker/build-push-action@v6 with: - context: ${{ matrix.context }} + context: debian build-args: INVOICENINJA_VERSION=${{ steps.prep.outputs.version }} push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.prep.outputs.tags }} + outputs: type=image,push-by-digest=true,name-canonical=true cache-from: type=gha cache-to: type=gha,mode=max - - name: Image digest - run: echo ${{ steps.docker_build.outputs.digest }} + - name: Export digest + run: | + mkdir -p ${{ runner.temp }}/digests + digest="${{ steps.build.outputs.digest }}" + touch "${{ runner.temp }}/digests/${digest#sha256:}" + + - name: Upload digest + uses: actions/upload-artifact@v4 + with: + name: digests-${{ env.PLATFORM_PAIR }} + path: ${{ runner.temp }}/digests/* + if-no-files-found: error + retention-days: 1 + + merge: + runs-on: ubuntu-latest + needs: + - build + steps: + - name: Download digests + uses: actions/download-artifact@v4 + with: + path: ${{ runner.temp }}/digests + pattern: digests-* + merge-multiple: true + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY_IMAGE }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + + - name: Create manifest list and push + working-directory: ${{ runner.temp }}/digests + if: ${{ github.event_name != 'pull_request' }} + run: | + docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ + $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) + + - name: Inspect image + run: | + docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} Description: + if: ${{ github.event_name != 'pull_request' }} runs-on: ubuntu-latest steps: - name: Checkout @@ -81,4 +145,4 @@ jobs: with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - repository: invoiceninja/invoiceninja-debian + repository: ${{ env.REGISTRY_IMAGE }} From ea252c7891027d880b068208fe908b18c8a69ed6 Mon Sep 17 00:00:00 2001 From: benbrummer Date: Mon, 20 Oct 2025 21:01:35 +0200 Subject: [PATCH 4/5] multiple runner build --- .github/workflows/build-image-debian.yaml | 31 +++++++++-------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build-image-debian.yaml b/.github/workflows/build-image-debian.yaml index 2414cb2..65e66ba 100644 --- a/.github/workflows/build-image-debian.yaml +++ b/.github/workflows/build-image-debian.yaml @@ -15,17 +15,18 @@ env: jobs: build: - runs-on: ${{ startsWith(matrix.platforms, 'linux/arm') && 'ubuntu-24.04-arm' || 'ubuntu-latest' }} + runs-on: ${{ startsWith(matrix.platform, 'linux/arm') && 'ubuntu-24.04-arm' || 'ubuntu-latest' }} strategy: fail-fast: false matrix: - platform: ["linux/amd64", "linux/arm64"] + platform: + - linux/amd64 + - linux/arm64 steps: - name: Checkout uses: actions/checkout@v5 - name: Prepare - id: prep run: | platform=${{ matrix.platform }} echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV @@ -41,19 +42,20 @@ jobs: with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - + - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v3 - - name: Build - id: docker_build + - name: Build and push by digest + id: build uses: docker/build-push-action@v6 with: context: debian - load: true - tags: ${{ env.REGISTRY_IMAGE }}:test - outputs: type=image,push-by-digest=true,name-canonical=true + platforms: ${{ matrix.platform }} + labels: ${{ steps.meta.outputs.labels }} + tags: ${{ env.REGISTRY_IMAGE }} + outputs: type=image,push-by-digest=true,name-canonical=true,push=true cache-from: type=gha cache-to: type=gha,mode=max @@ -97,18 +99,9 @@ jobs: uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY_IMAGE }} - tags: | - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - - name: Create manifest list (--dry-run) + - name: Create manifest list and push (--dry-run) working-directory: ${{ runner.temp }}/digests run: | docker buildx imagetools create --dry-run $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) - - - name: Inspect image - run: | - docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} From 98f60d721c5910e5ee1ec946a30bd6184aed4a77 Mon Sep 17 00:00:00 2001 From: Benjamin Brummer Date: Mon, 20 Oct 2025 21:45:11 +0200 Subject: [PATCH 5/5] multiple runner publish --- .github/workflows/publish-image.yaml | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/.github/workflows/publish-image.yaml b/.github/workflows/publish-image.yaml index bca7668..87d75fa 100644 --- a/.github/workflows/publish-image.yaml +++ b/.github/workflows/publish-image.yaml @@ -10,12 +10,15 @@ env: jobs: build: - runs-on: ${{ startsWith(matrix.platforms, 'linux/arm') && 'ubuntu-24.04-arm' || 'ubuntu-latest' }} + runs-on: ${{ startsWith(matrix.platform, 'linux/arm') && 'ubuntu-24.04-arm' || 'ubuntu-latest' }} + outputs: + tags: ${{ steps.prep.outputs.tags }} strategy: fail-fast: false matrix: - platform: ["linux/amd64", "linux/arm64"] - + platform: + - linux/amd64 + - linux/arm64 steps: - name: Checkout uses: actions/checkout@v5 @@ -63,14 +66,15 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Build and push by digest - id: docker_build + id: build uses: docker/build-push-action@v6 with: context: debian build-args: INVOICENINJA_VERSION=${{ steps.prep.outputs.version }} - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.prep.outputs.tags }} - outputs: type=image,push-by-digest=true,name-canonical=true + platforms: ${{ matrix.platform }} + labels: ${{ steps.meta.outputs.labels }} + tags: ${{ env.REGISTRY_IMAGE }} + outputs: type=image,push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }} cache-from: type=gha cache-to: type=gha,mode=max @@ -115,10 +119,7 @@ jobs: with: images: ${{ env.REGISTRY_IMAGE }} tags: | - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} + ${{ needs.build.outputs.tags }} - name: Create manifest list and push working-directory: ${{ runner.temp }}/digests @@ -128,12 +129,15 @@ jobs: $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) - name: Inspect image + if: ${{ github.event_name != 'pull_request' }} run: | docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} Description: if: ${{ github.event_name != 'pull_request' }} runs-on: ubuntu-latest + needs: + - merge steps: - name: Checkout uses: actions/checkout@v5