From 2edb64792f9f0a90dc1c17ee53cc172155b997f8 Mon Sep 17 00:00:00 2001 From: Karsten Dambekalns Date: Wed, 4 Nov 2026 20:20:15 +0100 Subject: [PATCH 1/3] Build arm64 images natively instead of emulating them Like in docker-php, every platform now builds on a native runner of its own (ubuntu-24.04 and ubuntu-24.04-arm) and pushes by digest only; a merge job combines the digests into one manifest list per PHP version and tags it in both registries. Each build job reads the PHP version from the label of the newest harbor.flownative.io/docker/php image itself and names its digest artifact after it, so if docker-php publishes a new version between the two jobs of a branch, the merge fails instead of combining images of different PHP versions. Also adds workflow_dispatch, to be able to start a build by hand. Refs OPS-8R Co-Authored-By: Claude Opus 5.5 --- .github/workflows/docker.build.yaml | 184 +++++++++++++++++++++------- 1 file changed, 138 insertions(+), 46 deletions(-) diff --git a/.github/workflows/docker.build.yaml b/.github/workflows/docker.build.yaml index d12b868..077c742 100644 --- a/.github/workflows/docker.build.yaml +++ b/.github/workflows/docker.build.yaml @@ -1,5 +1,6 @@ name: Build Docker images on: + workflow_dispatch: repository_dispatch: types: [php-images-built] push: @@ -8,14 +9,17 @@ on: tags: - 'v*.*.*' +env: + IMAGE_DOCKER_HUB: flownative/beach-php + IMAGE_HARBOR: harbor.flownative.io/docker/beach-php + PHP_IMAGE: harbor.flownative.io/docker/php + jobs: - build: + # The images are always built from the latest release. + prepare: runs-on: ubuntu-latest - - strategy: - matrix: - php: [ "8.2", "8.3", "8.4", "8.5" ] - + outputs: + tag: ${{ steps.latest_version.outputs.tag }} steps: - uses: actions/checkout@v7 with: @@ -26,51 +30,118 @@ jobs: id: latest_version uses: flownative/action-git-latest-release@v1 - - run: | - sudo chmod -R ugo+rwX . && shopt -s dotglob && rm -rf * - + # Every platform is built natively on a runner of its own instead of + # emulating arm64 with QEMU. The images are pushed by digest only and + # tagged in the merge job. + build: + needs: prepare + strategy: + matrix: + php: [ "8.2", "8.3", "8.4", "8.5" ] + platform: [ linux/amd64, linux/arm64 ] + include: + - platform: linux/amd64 + runner: ubuntu-24.04 + - platform: linux/arm64 + runner: ubuntu-24.04-arm + runs-on: ${{ matrix.runner }} + steps: - uses: actions/checkout@v7 with: - ref: ${{ steps.latest_version.outputs.tag }} - fetch-depth: 100 + ref: ${{ needs.prepare.outputs.tag }} - - name: Determine latest built PHP ${{ matrix.php }} version - id: latest_php_version - uses: flownative/action-docker-get-label@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v4 + + - name: Login to Docker Hub + uses: docker/login-action@v4 with: - image: harbor.flownative.io/docker/php:${{ matrix.php }} - label: org.opencontainers.image.version - registry_endpoint: https://harbor.flownative.io - registry_username: ${{ secrets.HARBOR_DOCKER_USERNAME }} - registry_password: ${{ secrets.HARBOR_DOCKER_PASSWORD }} + username: ${{ secrets.DOCKER_IO_REGISTRY_USER }} + password: ${{ secrets.DOCKER_IO_REGISTRY_PASSWORD }} + + - name: Login to Harbor + uses: docker/login-action@v4 + with: + registry: harbor.flownative.io + username: ${{ secrets.HARBOR_DOCKER_USERNAME }} + password: ${{ secrets.HARBOR_DOCKER_PASSWORD }} + + # The digest artifact is named after the PHP version found here. Should + # docker-php publish a new version between the jobs of the two + # platforms, the merge job finds only one digest per version and fails + # instead of combining images of different PHP versions. + - name: Determine latest built PHP ${{ matrix.php }} version + id: php + env: + PHP_BRANCH: ${{ matrix.php }} + PLATFORM: ${{ matrix.platform }} + run: | + set -euo pipefail + version="$(docker buildx imagetools inspect "${PHP_IMAGE}:${PHP_BRANCH}" \ + --format '{{ index (index .Image "linux/amd64").Config.Labels "org.opencontainers.image.version" }}')" + if ! [[ "${version}" =~ ^${PHP_BRANCH//./\\.}\.[0-9]+$ ]]; then + echo "::error::${PHP_IMAGE}:${PHP_BRANCH} has an unexpected version label: '${version}'" + exit 1 + fi + echo "version=${version}" >> "${GITHUB_OUTPUT}" + echo "artifact=digest-${version}-${PLATFORM#linux/}" >> "${GITHUB_OUTPUT}" - name: Docker meta id: meta uses: docker/metadata-action@v6 with: - flavor: | - latest=false images: | - flownative/beach-php - harbor.flownative.io/docker/beach-php + ${{ env.IMAGE_DOCKER_HUB }} + ${{ env.IMAGE_HARBOR }} labels: | org.opencontainers.image.title=Beach PHP org.opencontainers.image.description=Docker image providing PHP for Beach and Local Beach org.opencontainers.image.licenses=MIT org.opencontainers.image.vendor=Flownative GmbH org.opencontainers.image.authors=Robert Lemke - org.opencontainers.image.version=${{ steps.latest_php_version.outputs.value }} - tags: | - type=semver,pattern={{major}}.{{minor}},value=${{ steps.latest_php_version.outputs.value }} - type=semver,pattern={{version}},value=${{ steps.latest_php_version.outputs.value }} - - - name: Set up QEMU - id: qemu - uses: docker/setup-qemu-action@v4 - - - - name: Set up Docker Buildx - id: buildx + org.opencontainers.image.version=${{ steps.php.outputs.version }} + + - name: Build Docker image + id: build + uses: docker/build-push-action@v7 + with: + context: . + platforms: ${{ matrix.platform }} + pull: true + build-args: | + PHP_BASE_IMAGE=${{ env.PHP_IMAGE }}:${{ steps.php.outputs.version }} + labels: ${{ steps.meta.outputs.labels }} + outputs: type=image,"name=${{ env.IMAGE_DOCKER_HUB }},${{ env.IMAGE_HARBOR }}",push-by-digest=true,name-canonical=true,push=true + + - name: Export digest + env: + DIGEST: ${{ steps.build.outputs.digest }} + run: | + mkdir -p "${RUNNER_TEMP}/digests" + touch "${RUNNER_TEMP}/digests/${DIGEST#sha256:}" + + - name: Upload digest + uses: actions/upload-artifact@v7 + with: + name: ${{ steps.php.outputs.artifact }} + path: ${{ runner.temp }}/digests/* + if-no-files-found: error + retention-days: 1 + + # Combines the images of all platforms into one manifest list per PHP + # version and tags it in both registries. The PHP versions are taken from + # the names of the digest artifacts, so they are listed only once above. + merge: + needs: build + runs-on: ubuntu-latest + steps: + - name: Download digests + uses: actions/download-artifact@v8 + with: + path: ${{ runner.temp }}/digests + pattern: digest-* + + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v4 - name: Login to Docker Hub @@ -86,20 +157,41 @@ jobs: username: ${{ secrets.HARBOR_DOCKER_USERNAME }} password: ${{ secrets.HARBOR_DOCKER_PASSWORD }} - - name: Build Docker image - uses: docker/build-push-action@v7 - with: - context: . - platforms: linux/amd64,linux/arm64 - push: true - build-args: | - PHP_BASE_IMAGE=harbor.flownative.io/docker/php:${{ steps.latest_php_version.outputs.value }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + # Each registry gets its manifest list from the images pushed to that + # same registry, so no blobs have to be copied between registries. + - name: Create manifest lists + working-directory: ${{ runner.temp }}/digests + run: | + set -euo pipefail + versions="$(find . -mindepth 1 -maxdepth 1 -type d -name 'digest-*' | sed -n 's|^\./digest-\([0-9.]*\)-[a-z0-9]*$|\1|p' | sort -u)" + [ -n "${versions}" ] || { echo "::error::No digests found"; exit 1; } + for version in ${versions}; do + # Each artifact is a directory holding one empty file named + # after the digest. + digests="$(find . -mindepth 2 -path "./digest-${version}-*/*" -type f -exec basename {} \;)" + count="$(echo "${digests}" | wc -w | tr -d ' ')" + if [ "${count}" -ne 2 ]; then + echo "::error::PHP ${version}: expected 2 digests, found ${count}" + exit 1 + fi + for image in "${IMAGE_DOCKER_HUB}" "${IMAGE_HARBOR}"; do + sources=() + for digest in ${digests}; do + sources+=("${image}@sha256:${digest}") + done + echo "::group::${image}:${version}" + docker buildx imagetools create \ + --tag "${image}:${version%.*}" \ + --tag "${image}:${version}" \ + "${sources[@]}" + docker buildx imagetools inspect "${image}:${version}" + echo "::endgroup::" + done + done announce: runs-on: ubuntu-latest - needs: build + needs: merge steps: - name: Dispatch to beach-php-k8s uses: peter-evans/repository-dispatch@v4 From a81f02830fe8af98b3f7c138e47a8dbdc7fbd22c Mon Sep 17 00:00:00 2001 From: Karsten Dambekalns Date: Thu, 5 Nov 2026 08:44:42 +0100 Subject: [PATCH 2/3] Change runner from ubuntu-latest to ubuntu-26.04 --- .github/workflows/docker.build.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker.build.yaml b/.github/workflows/docker.build.yaml index 077c742..5cc736c 100644 --- a/.github/workflows/docker.build.yaml +++ b/.github/workflows/docker.build.yaml @@ -17,7 +17,7 @@ env: jobs: # The images are always built from the latest release. prepare: - runs-on: ubuntu-latest + runs-on: ubuntu-26.04 outputs: tag: ${{ steps.latest_version.outputs.tag }} steps: @@ -133,7 +133,7 @@ jobs: # the names of the digest artifacts, so they are listed only once above. merge: needs: build - runs-on: ubuntu-latest + runs-on: ubuntu-26.04 steps: - name: Download digests uses: actions/download-artifact@v8 @@ -190,7 +190,7 @@ jobs: done announce: - runs-on: ubuntu-latest + runs-on: ubuntu-26.04 needs: merge steps: - name: Dispatch to beach-php-k8s From dac2aa90ea42016644af8aafc98efd60ac30640b Mon Sep 17 00:00:00 2001 From: Karsten Dambekalns Date: Thu, 5 Nov 2026 08:47:29 +0100 Subject: [PATCH 3/3] Update Docker build runners to Ubuntu 26.04 --- .github/workflows/docker.build.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.build.yaml b/.github/workflows/docker.build.yaml index 5cc736c..5388004 100644 --- a/.github/workflows/docker.build.yaml +++ b/.github/workflows/docker.build.yaml @@ -41,9 +41,9 @@ jobs: platform: [ linux/amd64, linux/arm64 ] include: - platform: linux/amd64 - runner: ubuntu-24.04 + runner: ubuntu-26.04 - platform: linux/arm64 - runner: ubuntu-24.04-arm + runner: ubuntu-26.04-arm runs-on: ${{ matrix.runner }} steps: - uses: actions/checkout@v7