docker: Build arm image using ubuntu-24.04-arm runner #387
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Docker | |
on: | |
push: | |
branches: [ 'trunk' ] | |
paths: | |
- 'tools/docker/Dockerfile' | |
- 'tools/docker/bin/run.sh' | |
- 'tools/docker/config/*' | |
- '.github/versions.sh' | |
- '.github/workflows/build-docker.yml' | |
pull_request: | |
paths: | |
- 'tools/docker/Dockerfile' | |
- 'tools/docker/bin/run.sh' | |
- 'tools/docker/config/*' | |
- '.github/versions.sh' | |
- '.github/workflows/build-docker.yml' | |
concurrency: | |
group: build-docker-${{ github.event_name }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
name: Build Jetpack Dev Environment (${{ matrix.platform }}) | |
runs-on: ${{ matrix.runner }} | |
permissions: | |
packages: write | |
contents: read | |
timeout-minutes: 10 # 2025-03-04: Build takes about 5? minutes. | |
strategy: | |
matrix: | |
include: | |
- runner: ubuntu-latest | |
platform: amd64 | |
- runner: ubuntu-24.04-arm | |
platform: arm64 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Fetch build args | |
id: buildargs | |
run: | | |
source .github/versions.sh | |
source .github/files/gh-funcs.sh | |
gh_set_output php-version "$PHP_VERSION" | |
gh_set_output composer-version "$COMPOSER_VERSION" | |
gh_set_output node-version "$NODE_VERSION" | |
gh_set_output pnpm-version "$PNPM_VERSION" | |
# We're not git-tagging for the env. Just tag all trunk builds as latest. | |
if [[ "$GITHUB_EVENT_NAME" == "push" ]]; then | |
gh_set_output tags "type=raw,latest" | |
gh_set_output images $'automattic/jetpack-wordpress-dev\nghcr.io/automattic/jetpack-wordpress-dev' | |
elif [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then | |
gh_set_output tags "type=ref,event=pr" | |
gh_set_output images "ghcr.io/automattic/jetpack-wordpress-dev" | |
else | |
echo "Unknown GITHUB_EVENT_NAME $GITHUB_EVENT_NAME" | |
exit 1 | |
fi | |
- name: Extract Docker metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
flavor: latest=false | |
images: ${{ steps.buildargs.outputs.images }} | |
labels: | | |
org.opencontainers.image.title=Jetpack Development Environment | |
org.opencontainers.image.description=Unified environment for developing in the Jetpack Monorepo using Docker containers. | |
org.opencontainers.image.documentation=${{ github.server_url }}/${{ github.repository }}/blob/trunk/tools/docker/README.md | |
- name: Build and push by digest | |
id: build | |
uses: docker/build-push-action@v6 | |
with: | |
context: tools/docker | |
platforms: linux/${{ matrix.platform }} | |
tags: ${{ steps.buildargs.outputs.images }} | |
labels: ${{ steps.meta.outputs.labels }} | |
outputs: type=image,push-by-digest=true,name-canonical=true,push=true | |
build-args: | | |
PHP_VERSION=${{ steps.buildargs.outputs.php-version }} | |
COMPOSER_VERSION=${{ steps.buildargs.outputs.composer-version }} | |
NODE_VERSION=${{ steps.buildargs.outputs.node-version }} | |
PNPM_VERSION=${{ steps.buildargs.outputs.pnpm-version }} | |
- name: Export digest | |
env: | |
TEMP: ${{ runner.temp }} | |
DIGEST: ${{ steps.build.outputs.digest }} | |
run: | | |
mkdir -p "$TEMP/digests" | |
touch "$TEMP/digests/${DIGEST#sha256:}" | |
- name: Upload digest | |
uses: actions/upload-artifact@v4 | |
with: | |
name: digests-linux-${{ matrix.platform }} | |
path: ${{ runner.temp }}/digests/* | |
if-no-files-found: error | |
retention-days: 1 | |
merge: | |
name: Merge and publish Jetpack Dev Environment | |
runs-on: ubuntu-latest | |
needs: build | |
permissions: | |
packages: write | |
contents: read | |
timeout-minutes: 10 # 2025-03-04: Merge takes about 5? minutes. | |
steps: | |
- name: Download digests | |
uses: actions/download-artifact@v4 | |
with: | |
path: ${{ runner.temp }}/digests | |
pattern: digests-* | |
merge-multiple: true | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: matticbot | |
password: ${{ secrets.DOCKER_HUB_MATTICBOT_TOKEN }} | |
- name: Log in to GitHub Packages | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Fetch build args | |
id: buildargs | |
run: | | |
source .github/versions.sh | |
source .github/files/gh-funcs.sh | |
gh_set_output php-version "$PHP_VERSION" | |
gh_set_output composer-version "$COMPOSER_VERSION" | |
gh_set_output node-version "$NODE_VERSION" | |
gh_set_output pnpm-version "$PNPM_VERSION" | |
# We're not git-tagging for the env. Just tag all trunk builds as latest. | |
if [[ "$GITHUB_EVENT_NAME" == "push" ]]; then | |
gh_set_output tags "type=raw,latest" | |
gh_set_output images $'automattic/jetpack-wordpress-dev\nghcr.io/automattic/jetpack-wordpress-dev' | |
elif [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then | |
gh_set_output tags "type=ref,event=pr" | |
gh_set_output images "ghcr.io/automattic/jetpack-wordpress-dev" | |
else | |
echo "Unknown GITHUB_EVENT_NAME $GITHUB_EVENT_NAME" | |
exit 1 | |
fi | |
- name: Extract Docker metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
flavor: latest=false | |
tags: ${{ steps.buildargs.outputs.tags }} | |
images: ${{ steps.buildargs.outputs.images }} | |
labels: | | |
org.opencontainers.image.title=Jetpack Development Environment | |
org.opencontainers.image.description=Unified environment for developing in the Jetpack Monorepo using Docker containers. | |
org.opencontainers.image.documentation=${{ github.server_url }}/${{ github.repository }}/blob/trunk/tools/docker/README.md | |
- name: Create manifest list and push | |
working-directory: ${{ runner.temp }}/digests | |
run: | | |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
$(printf "$REGISTRY_IMAGE@sha256:%s " *) | |
- name: Inspect image | |
env: | |
VERSION: ${{ steps.meta.outputs.version }} | |
run: | | |
docker buildx imagetools inspect "$REGISTRY_IMAGE:$VERSION" |