Skip to content

Commit 44f11ea

Browse files
authored
Build and push multi-platform docker image (#1567)
This PR adds the `publish-docker-image-multiplatform` CI job step that pushes a multi-platform docker image when a new tag is created. #1211 Unfortunately, this is not as simple as pushing two images targeting different platforms to the same tag. There are a couple of ways to create a multi-platform image: - Using `docker buildx` to build images for all platforms. To do this images targeting non-native platforms would need to be built using QEMU (slower), a remote machine or cross-compilation. - Building and publishing platform-specific images `emscripten/emsdk-x64`, `emscripten/emsdk-arm64` and then creating a manifest that links to these images. This is the simpler solution to implement, and is what this PR does. Tested with CircleCI on my fork. See the pushed images at [radiantly/emsdk · DockerHub](https://hub.docker.com/r/radiantly/emsdk/tags)
1 parent 389a68b commit 44f11ea

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

.circleci/config.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ jobs:
9696
python3 -m pip install flake8==7.1.1
9797
python3 -m flake8 --show-source --statistics --extend-exclude=./scripts
9898
99-
10099
test-linux:
101100
executor: ubuntu
102101
environment:
@@ -249,7 +248,7 @@ jobs:
249248
name: push image
250249
command: |
251250
docker login -u "$DOCKER_USER" -p "$DOCKER_PASS"
252-
make -C ./docker version=${CIRCLE_TAG} alias=latest push
251+
make -C ./docker version=${CIRCLE_TAG} alias=${CIRCLE_TAG}-x64 only_alias=true push
253252
254253
publish-docker-image-arm64:
255254
executor: linux_arm64
@@ -267,6 +266,16 @@ jobs:
267266
docker login -u "$DOCKER_USER" -p "$DOCKER_PASS"
268267
make -C ./docker version=${CIRCLE_TAG} alias=${CIRCLE_TAG}-arm64 only_alias=true push
269268
269+
publish-docker-image-multiplatform:
270+
executor: linux_arm64
271+
steps:
272+
- checkout
273+
- run:
274+
name: push image
275+
command: |
276+
docker login -u "$DOCKER_USER" -p "$DOCKER_PASS"
277+
make -C ./docker version=${CIRCLE_TAG} alias="latest" push-multiplatform
278+
270279
test-bazel7-linux:
271280
executor: ubuntu
272281
environment:
@@ -345,6 +354,14 @@ workflows:
345354
ignore: /.*/
346355
tags:
347356
only: /.*/
357+
- publish-docker-image-multiplatform:
358+
filters:
359+
tags:
360+
only: /.*/
361+
requires:
362+
- publish-docker-image-x64
363+
- publish-docker-image-arm64
364+
348365
test-bazel7-linux:
349366
jobs:
350367
- test-bazel7-linux

docker/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,7 @@ ifdef alias
2929
docker tag ${image_name}:${version} ${image_name}:${alias}
3030
docker push ${image_name}:${alias}
3131
endif
32+
33+
push-multiplatform: .TEST
34+
docker manifest create ${image_name}:${version} $(foreach platform,x64 arm64,--amend ${image_name}:${version}-$(platform))
35+
docker manifest push ${image_name}:${version}

0 commit comments

Comments
 (0)