@@ -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
@@ -284,8 +282,7 @@ target "image-all" {
284282 inherits = ["image"]
285283 platforms = [
286284 "linux/amd64",
287- "linux/arm/v6",
288- "linux/arm/v7",
285+ "linux/riscv64",
289286 "linux/arm64"
290287 ]
291288}
@@ -337,13 +334,13 @@ jobs:
337334 retention-days: 1
338335
339336 build:
340- runs-on: ubuntu-latest
341337 needs:
342338 - prepare
343339 strategy:
344340 fail-fast: false
345341 matrix:
346342 platform: ${{ fromJson(needs.prepare.outputs.matrix) }}
343+ runs-on: ${{ matrix.platform == 'linux/arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
347344 steps:
348345 - name: Prepare
349346 run: |
@@ -355,14 +352,15 @@ jobs:
355352 with:
356353 name: bake-meta
357354 path: ${{ runner.temp }}
358-
355+
359356 - name: Login to Docker Hub
360357 uses: docker/login-action@v3
361358 with:
362359 username: ${{ vars.DOCKERHUB_USERNAME }}
363360 password: ${{ secrets.DOCKERHUB_TOKEN }}
364361
365362 - name: Set up QEMU
363+ if: ${{ matrix.platform == 'linux/riscv64' }}
366364 uses: docker/setup-qemu-action@v3
367365
368366 - name: Set up Docker Buildx
0 commit comments