Skip to content

Commit ccdf3a3

Browse files
committed
docker: Build arm image using ubuntu-24.04-arm runner
Linux arm64 runners are in public preview. Building the arm64 part of the Docker image on one of these rather than in qemu should be a lot faster; let's try it.
1 parent 75b0abc commit ccdf3a3

File tree

1 file changed

+140
-39
lines changed

1 file changed

+140
-39
lines changed

.github/workflows/build-docker.yml

+140-39
Original file line numberDiff line numberDiff line change
@@ -20,40 +20,31 @@ concurrency:
2020
cancel-in-progress: true
2121

2222
jobs:
23-
build:
24-
name: Build and publish Jetpack Dev Environment
23+
prepare:
24+
name: Prepare
2525
runs-on: ubuntu-latest
2626
permissions:
27-
packages: write
2827
contents: read
29-
timeout-minutes: 60 # 2021-10-26: Build for arm64 is S-L-O-W. Sigh.
28+
timeout-minutes: 5 # 2025-03-04: Takes just a few seconds.
29+
outputs:
30+
php-version: ${{ steps.buildargs.outputs.php-version }}
31+
composer-version: ${{ steps.buildargs.outputs.composer-version }}
32+
node-version: ${{ steps.buildargs.outputs.node-version }}
33+
pnpm-version: ${{ steps.buildargs.outputs.pnpm-version }}
34+
labels: ${{ steps.buildargs.outputs.labels }}
35+
tags: ${{ steps.buildargs.outputs.tags }}
36+
images: ${{ steps.buildargs.outputs.images }}
3037

3138
steps:
3239
- uses: actions/checkout@v4
3340

34-
- name: Set up qemu
35-
uses: docker/setup-qemu-action@v3
36-
with:
37-
platforms: arm64
38-
39-
- name: Set up Docker Buildx
40-
uses: docker/setup-buildx-action@v3
41-
42-
- name: Log in to Docker Hub
43-
uses: docker/login-action@v3
44-
with:
45-
username: matticbot
46-
password: ${{ secrets.DOCKER_HUB_MATTICBOT_TOKEN }}
47-
48-
- name: Log in to GitHub Packages
49-
uses: docker/login-action@v3
50-
with:
51-
registry: ghcr.io
52-
username: ${{ github.actor }}
53-
password: ${{ secrets.GITHUB_TOKEN }}
54-
5541
- name: Fetch build args
5642
id: buildargs
43+
env:
44+
LABELS: |
45+
org.opencontainers.image.title=Jetpack Development Environment
46+
org.opencontainers.image.description=Unified environment for developing in the Jetpack Monorepo using Docker containers.
47+
org.opencontainers.image.documentation=${{ github.server_url }}/${{ github.repository }}/blob/trunk/tools/docker/README.md
5748
run: |
5849
source .github/versions.sh
5950
source .github/files/gh-funcs.sh
@@ -62,6 +53,7 @@ jobs:
6253
gh_set_output composer-version "$COMPOSER_VERSION"
6354
gh_set_output node-version "$NODE_VERSION"
6455
gh_set_output pnpm-version "$PNPM_VERSION"
56+
gh_set_output labels "$LABELS"
6557
6658
# We're not git-tagging for the env. Just tag all trunk builds as latest.
6759
if [[ "$GITHUB_EVENT_NAME" == "push" ]]; then
@@ -75,28 +67,137 @@ jobs:
7567
exit 1
7668
fi
7769
70+
build:
71+
name: Build Jetpack Dev Environment (${{ matrix.platform }})
72+
runs-on: ${{ matrix.runner }}
73+
needs: prepare
74+
permissions:
75+
packages: write
76+
contents: read
77+
timeout-minutes: 15 # 2025-03-04: Arm64 build takes about 5 minutes, amd64 build about 3.
78+
strategy:
79+
matrix:
80+
include:
81+
- runner: ubuntu-latest
82+
platform: amd64
83+
- runner: ubuntu-24.04-arm
84+
platform: arm64
85+
86+
steps:
87+
- uses: actions/checkout@v4
88+
89+
- name: Set up Docker Buildx
90+
uses: docker/setup-buildx-action@v3
91+
92+
- name: Log in to Docker Hub
93+
uses: docker/login-action@v3
94+
with:
95+
username: matticbot
96+
password: ${{ secrets.DOCKER_HUB_MATTICBOT_TOKEN }}
97+
98+
- name: Log in to GitHub Packages
99+
uses: docker/login-action@v3
100+
with:
101+
registry: ghcr.io
102+
username: ${{ github.actor }}
103+
password: ${{ secrets.GITHUB_TOKEN }}
104+
78105
- name: Extract Docker metadata
79106
id: meta
80107
uses: docker/metadata-action@v5
81108
with:
82109
flavor: latest=false
83-
tags: ${{ steps.buildargs.outputs.tags }}
84-
images: ${{ steps.buildargs.outputs.images }}
85-
labels: |
86-
org.opencontainers.image.title=Jetpack Development Environment
87-
org.opencontainers.image.description=Unified environment for developing in the Jetpack Monorepo using Docker containers.
88-
org.opencontainers.image.documentation=${{ github.server_url }}/${{ github.repository }}/blob/trunk/tools/docker/README.md
110+
images: ${{ needs.prepare.outputs.images }}
111+
labels: ${{ needs.prepare.outputs.labels }}
89112

90-
- name: Build and push Docker image
113+
- name: Build and push by digest
114+
id: build
91115
uses: docker/build-push-action@v6
92116
with:
93117
context: tools/docker
94-
platforms: linux/amd64,linux/arm64
95-
push: true
96-
tags: ${{ steps.meta.outputs.tags }}
118+
platforms: linux/${{ matrix.platform }}
119+
# For push by digest, the "tags" are just the images. We tag later.
120+
tags: ${{ needs.prepare.outputs.images }}
97121
labels: ${{ steps.meta.outputs.labels }}
122+
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
98123
build-args: |
99-
PHP_VERSION=${{ steps.buildargs.outputs.php-version }}
100-
COMPOSER_VERSION=${{ steps.buildargs.outputs.composer-version }}
101-
NODE_VERSION=${{ steps.buildargs.outputs.node-version }}
102-
PNPM_VERSION=${{ steps.buildargs.outputs.pnpm-version }}
124+
PHP_VERSION=${{ needs.prepare.outputs.php-version }}
125+
COMPOSER_VERSION=${{ needs.prepare.outputs.composer-version }}
126+
NODE_VERSION=${{ needs.prepare.outputs.node-version }}
127+
PNPM_VERSION=${{ needs.prepare.outputs.pnpm-version }}
128+
129+
- name: Export digest
130+
env:
131+
TEMP: ${{ runner.temp }}
132+
DIGEST: ${{ steps.build.outputs.digest }}
133+
run: |
134+
mkdir -p "$TEMP/digests"
135+
touch "$TEMP/digests/${DIGEST#sha256:}"
136+
137+
- name: Upload digest
138+
uses: actions/upload-artifact@v4
139+
with:
140+
name: digests-linux-${{ matrix.platform }}
141+
path: ${{ runner.temp }}/digests/*
142+
if-no-files-found: error
143+
retention-days: 1
144+
145+
merge:
146+
name: Merge and publish Jetpack Dev Environment
147+
runs-on: ubuntu-latest
148+
needs: [ prepare, build ]
149+
permissions:
150+
packages: write
151+
contents: read
152+
timeout-minutes: 5 # 2025-03-04: Merge takes less than a minute.
153+
154+
steps:
155+
- name: Download digests
156+
uses: actions/download-artifact@v4
157+
with:
158+
path: ${{ runner.temp }}/digests
159+
pattern: digests-*
160+
merge-multiple: true
161+
162+
- name: Set up Docker Buildx
163+
uses: docker/setup-buildx-action@v3
164+
165+
- name: Log in to Docker Hub
166+
uses: docker/login-action@v3
167+
with:
168+
username: matticbot
169+
password: ${{ secrets.DOCKER_HUB_MATTICBOT_TOKEN }}
170+
171+
- name: Log in to GitHub Packages
172+
uses: docker/login-action@v3
173+
with:
174+
registry: ghcr.io
175+
username: ${{ github.actor }}
176+
password: ${{ secrets.GITHUB_TOKEN }}
177+
178+
- name: Extract Docker metadata
179+
id: meta
180+
uses: docker/metadata-action@v5
181+
with:
182+
flavor: latest=false
183+
tags: ${{ needs.prepare.outputs.tags }}
184+
images: ${{ needs.prepare.outputs.images }}
185+
labels: ${{ needs.prepare.outputs.labels }}
186+
187+
- name: Create manifest list and push
188+
working-directory: ${{ runner.temp }}/digests
189+
run: |
190+
while IFS= read -r IMAGE; do
191+
echo "=== $IMAGE ==="
192+
docker buildx imagetools create $(jq -cr --arg IMG "$IMAGE" '.tags | map( select( startswith( $IMG + ":" ) ) | "-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
193+
$(printf "$IMAGE@sha256:%s " *)
194+
done < <( jq -r '.tags[] | sub( ":.*"; "" )' <<< "$DOCKER_METADATA_OUTPUT_JSON" )
195+
196+
- name: Inspect image
197+
env:
198+
VERSION: ${{ steps.meta.outputs.version }}
199+
run: |
200+
while IFS= read -r IMAGE; do
201+
echo "=== $IMAGE ==="
202+
docker buildx imagetools inspect "$IMAGE:$VERSION"
203+
done < <( jq -r '.tags[] | sub( ":.*"; "" )' <<< "$DOCKER_METADATA_OUTPUT_JSON" )

0 commit comments

Comments
 (0)