Files
ci-emsdk/docker/Makefile
Joshua T. 44f11eac54 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)
2025-09-25 10:51:45 -07:00

36 lines
1.1 KiB
Makefile

# A Makefile to build, test, tag and publish the Emscripten SDK Docker container.
# Emscripten version to build: Should match the version that has been already released.
# i.e.: 1.39.18
version =
alias =
only_alias =
image_name ?= emscripten/emsdk
.TEST:
ifndef version
$(error argument 'version' is not set. Please call `make version=SOME_VERSION ...`)
endif
build: Dockerfile .TEST
cd .. && docker build --progress=plain --network host --build-arg=EMSCRIPTEN_VERSION=${version} -t ${image_name}:${version} -f docker/$< .
test: test_dockerimage.sh .TEST
# test as non-root
# test fallback env variables by overriding the entrypoint
docker run --rm -u `id -u`:`id -g` -w /emsdk/docker --net=host --entrypoint /bin/bash ${image_name}:${version} $<
push: .TEST
ifndef only_alias
docker push ${image_name}:${version}
endif
ifdef alias
docker tag ${image_name}:${version} ${image_name}:${alias}
docker push ${image_name}:${alias}
endif
push-multiplatform: .TEST
docker manifest create ${image_name}:${version} $(foreach platform,x64 arm64,--amend ${image_name}:${version}-$(platform))
docker manifest push ${image_name}:${version}