@@ -100,23 +100,22 @@ jobs:
100
100
101
101
# # Distribute build across multiple runners
102
102
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
108
110
[`buildx imagetools create` command](/reference/cli/docker/buildx/imagetools/create.md).
109
111
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 :
113
115
114
116
- Docker Hub : ` docker.io/docker-user/my-app`
115
117
- GitHub Container Registry : ` ghcr.io/gh-user/my-app`
116
118
117
- This example also uses the [`metadata` action](https://github.com/docker/metadata-action)
118
- to set tags and labels.
119
-
120
119
` ` ` yaml
121
120
name: ci
122
121
@@ -129,13 +128,15 @@ env:
129
128
130
129
jobs:
131
130
build:
132
- runs-on: ubuntu-latest
133
131
strategy:
134
132
fail-fast: false
135
133
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 }}
139
140
steps:
140
141
- name: Prepare
141
142
run: |
@@ -163,9 +164,6 @@ jobs:
163
164
username: ${{ github.repository_owner }}
164
165
password: ${{ secrets.GITHUB_TOKEN }}
165
166
166
- - name: Set up QEMU
167
- uses: docker/setup-qemu-action@v3
168
-
169
167
- name: Set up Docker Buildx
170
168
uses: docker/setup-buildx-action@v3
171
169
@@ -337,13 +335,13 @@ jobs:
337
335
retention-days: 1
338
336
339
337
build:
340
- runs-on: ubuntu-latest
341
338
needs:
342
339
- prepare
343
340
strategy:
344
341
fail-fast: false
345
342
matrix:
346
343
platform: ${{ fromJson(needs.prepare.outputs.matrix) }}
344
+ runs-on: ${{ startsWith(matrix.platform, 'linux/arm') && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
347
345
steps:
348
346
- name: Prepare
349
347
run: |
@@ -355,16 +353,13 @@ jobs:
355
353
with:
356
354
name: bake-meta
357
355
path: ${{ runner.temp }}
358
-
356
+
359
357
- name: Login to Docker Hub
360
358
uses: docker/login-action@v3
361
359
with:
362
360
username: ${{ vars.DOCKERHUB_USERNAME }}
363
361
password: ${{ secrets.DOCKERHUB_TOKEN }}
364
362
365
- - name: Set up QEMU
366
- uses: docker/setup-qemu-action@v3
367
-
368
363
- name: Set up Docker Buildx
369
364
uses: docker/setup-buildx-action@v3
370
365
0 commit comments