@@ -100,23 +100,22 @@ jobs:
100100
101101# # Distribute build across multiple runners
102102
103- In the previous example, each platform is built on the same runner which can
104- take a long time depending on the number of platforms and your Dockerfile.
105-
106- To solve this issue you can use a matrix strategy to distribute the build for
107- each platform across multiple runners and create manifest list using the
103+ Building multiple platforms on the same runner can significantly extend build
104+ times, particularly when dealing with complex Dockerfiles or a high number of
105+ target platforms. By distributing platform-specific builds across multiple
106+ runners using a matrix strategy, you can drastically reduce build durations and
107+ streamline your CI pipeline. These examples demonstrate how to allocate each
108+ platform build to a dedicated runner, including ARM-native runners where
109+ applicable, and create a unified manifest list using the
108110[`buildx imagetools create` command](/reference/cli/docker/buildx/imagetools/create.md).
109111
110- The following workflow will build the image for each platform on a dedicated
111- runner using a matrix strategy and push by digest. Then, the `merge` job will
112- create manifest lists and push them to two registries :
112+ The workflow also highlights tagging and labeling using the [Docker Metadata action](https://github.com/docker/metadata-action),
113+ pushing platform-specific images by digest, and creating manifest lists for two
114+ registries :
113115
114116- Docker Hub : ` docker.io/docker-user/my-app`
115117- GitHub Container Registry : ` ghcr.io/gh-user/my-app`
116118
117- This example also uses the [`metadata` action](https://github.com/docker/metadata-action)
118- to set tags and labels.
119-
120119` ` ` yaml
121120name: ci
122121
@@ -129,13 +128,15 @@ env:
129128
130129jobs:
131130 build:
132- runs-on: ubuntu-latest
133131 strategy:
134132 fail-fast: false
135133 matrix:
136- platform:
137- - linux/amd64
138- - linux/arm64
134+ include:
135+ - platform: linux/amd64
136+ os: ubuntu-latest
137+ - platform: linux/arm64
138+ os: ubuntu-24.04-arm
139+ runs-on: ${{ matrix.os }}
139140 steps:
140141 - name: Prepare
141142 run: |
@@ -163,9 +164,6 @@ jobs:
163164 username: ${{ github.repository_owner }}
164165 password: ${{ secrets.GITHUB_TOKEN }}
165166
166- - name: Set up QEMU
167- uses: docker/setup-qemu-action@v3
168-
169167 - name: Set up Docker Buildx
170168 uses: docker/setup-buildx-action@v3
171169
@@ -337,13 +335,13 @@ jobs:
337335 retention-days: 1
338336
339337 build:
340- runs-on: ubuntu-latest
341338 needs:
342339 - prepare
343340 strategy:
344341 fail-fast: false
345342 matrix:
346343 platform: ${{ fromJson(needs.prepare.outputs.matrix) }}
344+ runs-on: ${{ startsWith(matrix.platform, 'linux/arm') && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
347345 steps:
348346 - name: Prepare
349347 run: |
@@ -355,16 +353,13 @@ jobs:
355353 with:
356354 name: bake-meta
357355 path: ${{ runner.temp }}
358-
356+
359357 - name: Login to Docker Hub
360358 uses: docker/login-action@v3
361359 with:
362360 username: ${{ vars.DOCKERHUB_USERNAME }}
363361 password: ${{ secrets.DOCKERHUB_TOKEN }}
364362
365- - name: Set up QEMU
366- uses: docker/setup-qemu-action@v3
367-
368363 - name: Set up Docker Buildx
369364 uses: docker/setup-buildx-action@v3
370365
0 commit comments