From 80492a7b680ac452f4978c2e44f947fbdceb7c11 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Mon, 16 Feb 2026 13:15:52 +0100 Subject: [PATCH] Use native ARM runners for ARM Docker image builds (#1248) * Initial plan * Use ARM runners for ARM Docker image builds Co-authored-by: jbtronics <5410681+jbtronics@users.noreply.github.com> * Fix artifact naming and add comments for latest=false flavor Co-authored-by: jbtronics <5410681+jbtronics@users.noreply.github.com> * Remove trailing commas from tag configuration in merge job Co-authored-by: jbtronics <5410681+jbtronics@users.noreply.github.com> * Remove duplicate tag entries and clean up configuration Co-authored-by: jbtronics <5410681+jbtronics@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jbtronics <5410681+jbtronics@users.noreply.github.com> --- .github/workflows/docker_build.yml | 113 ++++++++++++++++++++---- .github/workflows/docker_frankenphp.yml | 113 ++++++++++++++++++++---- 2 files changed, 194 insertions(+), 32 deletions(-) diff --git a/.github/workflows/docker_build.yml b/.github/workflows/docker_build.yml index ce3243ca..2e0d533c 100644 --- a/.github/workflows/docker_build.yml +++ b/.github/workflows/docker_build.yml @@ -15,8 +15,20 @@ on: - 'v*.*.*-**' jobs: - docker: - runs-on: ubuntu-latest + build: + strategy: + matrix: + include: + - platform: linux/amd64 + runner: ubuntu-latest + platform-slug: amd64 + - platform: linux/arm64 + runner: ubuntu-24.04-arm + platform-slug: arm64 + - platform: linux/arm/v7 + runner: ubuntu-24.04-arm + platform-slug: armv7 + runs-on: ${{ matrix.runner }} steps: - name: Checkout @@ -32,13 +44,12 @@ jobs: # Mark the image build from master as latest (as we dont have really releases yet) tags: | type=edge,branch=master - type=ref,event=branch, - type=ref,event=tag, + type=ref,event=branch + type=ref,event=tag type=schedule type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} - type=ref,event=branch type=ref,event=pr labels: | org.opencontainers.image.source=${{ github.event.repository.clone_url }} @@ -49,12 +60,10 @@ jobs: org.opencontainers.image.source=https://github.com/Part-DB/Part-DB-symfony org.opencontainers.image.authors=Jan Böhmer org.opencontainers.licenses=AGPL-3.0-or-later + # Disable automatic 'latest' tag in build jobs - it will be created in merge job + flavor: | + latest=false - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - with: - platforms: 'arm64,arm' - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -67,13 +76,85 @@ jobs: password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push + name: Build and push by digest + id: build uses: docker/build-push-action@v6 with: context: . - platforms: linux/amd64,linux/arm64,linux/arm/v7 - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.docker_meta.outputs.tags }} + platforms: ${{ matrix.platform }} labels: ${{ steps.docker_meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max + outputs: type=image,name=jbtronics/part-db1,push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }} + cache-from: type=gha,scope=build-${{ matrix.platform }} + cache-to: type=gha,mode=max,scope=build-${{ matrix.platform }} + + - + name: Export digest + if: github.event_name != 'pull_request' + run: | + mkdir -p /tmp/digests + digest="${{ steps.build.outputs.digest }}" + touch "/tmp/digests/${digest#sha256:}" + + - + name: Upload digest + if: github.event_name != 'pull_request' + uses: actions/upload-artifact@v4 + with: + name: digests-${{ matrix.platform-slug }} + path: /tmp/digests/* + if-no-files-found: error + retention-days: 1 + + merge: + runs-on: ubuntu-latest + needs: + - build + if: github.event_name != 'pull_request' + steps: + - + name: Download digests + uses: actions/download-artifact@v4 + with: + path: /tmp/digests + pattern: digests-* + merge-multiple: true + + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - + name: Docker meta + id: docker_meta + uses: docker/metadata-action@v5 + with: + images: | + jbtronics/part-db1 + tags: | + type=edge,branch=master + type=ref,event=branch + type=ref,event=tag + type=schedule + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=ref,event=pr + + - + name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - + name: Create manifest list and push + working-directory: /tmp/digests + run: | + docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ + $(printf 'jbtronics/part-db1@sha256:%s ' *) + + - + name: Inspect image + run: | + docker buildx imagetools inspect jbtronics/part-db1:${{ steps.docker_meta.outputs.version }} diff --git a/.github/workflows/docker_frankenphp.yml b/.github/workflows/docker_frankenphp.yml index 1180f0c5..10e62dfc 100644 --- a/.github/workflows/docker_frankenphp.yml +++ b/.github/workflows/docker_frankenphp.yml @@ -15,8 +15,20 @@ on: - 'v*.*.*-**' jobs: - docker: - runs-on: ubuntu-latest + build: + strategy: + matrix: + include: + - platform: linux/amd64 + runner: ubuntu-latest + platform-slug: amd64 + - platform: linux/arm64 + runner: ubuntu-24.04-arm + platform-slug: arm64 + - platform: linux/arm/v7 + runner: ubuntu-24.04-arm + platform-slug: armv7 + runs-on: ${{ matrix.runner }} steps: - name: Checkout @@ -32,13 +44,12 @@ jobs: # Mark the image build from master as latest (as we dont have really releases yet) tags: | type=edge,branch=master - type=ref,event=branch, - type=ref,event=tag, + type=ref,event=branch + type=ref,event=tag type=schedule type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} - type=ref,event=branch type=ref,event=pr labels: | org.opencontainers.image.source=${{ github.event.repository.clone_url }} @@ -49,12 +60,10 @@ jobs: org.opencontainers.image.source=https://github.com/Part-DB/Part-DB-server org.opencontainers.image.authors=Jan Böhmer org.opencontainers.licenses=AGPL-3.0-or-later + # Disable automatic 'latest' tag in build jobs - it will be created in merge job + flavor: | + latest=false - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - with: - platforms: 'arm64,arm' - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -67,14 +76,86 @@ jobs: password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push + name: Build and push by digest + id: build uses: docker/build-push-action@v6 with: context: . file: Dockerfile-frankenphp - platforms: linux/amd64,linux/arm64,linux/arm/v7 - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.docker_meta.outputs.tags }} + platforms: ${{ matrix.platform }} labels: ${{ steps.docker_meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max + outputs: type=image,name=partdborg/part-db,push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }} + cache-from: type=gha,scope=build-${{ matrix.platform }} + cache-to: type=gha,mode=max,scope=build-${{ matrix.platform }} + + - + name: Export digest + if: github.event_name != 'pull_request' + run: | + mkdir -p /tmp/digests + digest="${{ steps.build.outputs.digest }}" + touch "/tmp/digests/${digest#sha256:}" + + - + name: Upload digest + if: github.event_name != 'pull_request' + uses: actions/upload-artifact@v4 + with: + name: digests-${{ matrix.platform-slug }} + path: /tmp/digests/* + if-no-files-found: error + retention-days: 1 + + merge: + runs-on: ubuntu-latest + needs: + - build + if: github.event_name != 'pull_request' + steps: + - + name: Download digests + uses: actions/download-artifact@v4 + with: + path: /tmp/digests + pattern: digests-* + merge-multiple: true + + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - + name: Docker meta + id: docker_meta + uses: docker/metadata-action@v5 + with: + images: | + partdborg/part-db + tags: | + type=edge,branch=master + type=ref,event=branch + type=ref,event=tag + type=schedule + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=ref,event=pr + + - + name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - + name: Create manifest list and push + working-directory: /tmp/digests + run: | + docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ + $(printf 'partdborg/part-db@sha256:%s ' *) + + - + name: Inspect image + run: | + docker buildx imagetools inspect partdborg/part-db:${{ steps.docker_meta.outputs.version }}