This cluster runs on the arm64 instruction set. Some of the deployments in it do not provide cross-built docker images for the arm64 arch so we use QEMU to emulate it at build time and push the image to my public GitHub Container Registry.
First, we need to add arm64 as an available build target from an x86 host using buildx. We can verify that arm64 targets are missing via:
# Verify that no arm64 local build env exists
$ docker buildx ls
NAME/NODE DRIVER/ENDPOINT STATUS PLATFORMS
default * docker
default default running linux/amd64, linux/386
# Start the buildx qemu environment
$ docker \
run \
--rm \
--privileged \
tonistiigi/binfmt:qemu-v6.0.0 \
--install arm64
# Verify that new build environments have been added
$ docker buildx ls
NAME/NODE DRIVER/ENDPOINT STATUS PLATFORMS
default * docker
default default running linux/amd64, linux/386, linux/arm64
Next, we'll need to authorize docker to push container images to my registry: docs.
export CR_PAT=SECRET_SECRET
echo $CR_PAT | docker login ghcr.io -u paulkiernan --password-stdin
Finally, we can build the images.
docker \
buildx \
build \
--platform linux/arm64 \
-t ghcr.io/paulkiernan/valheim-server-docker:main-arm64 \
--push \
.
docker \
buildx \
build \
--progress plain \
--platform linux/arm64 \
-t ghcr.io/paulkiernan/valheim-server-docker:main-arm64 \
--push \
.
We can uninstall QEMU:
docker \
run \
--privileged \
--rm \
tonistiigi/binfmt \
--uninstall qemu-aarch64