Here's how to do it in Jenkins only using the plugin for image naming:
script {
docker.withRegistry('my.registry.com', 'my_creds') {
def image = docker.image("my_image:my_tag")
sh "docker buildx create --use --name multiarch"
sh """
docker buildx build \
--platform linux/amd64,linux/arm64 \
-t ${image.imageName()} \
--push .
"""
}
}
For this to work the Jenkins agent needs to have the QEMU binary formats registered with binfmt so the builder it creates will have all the emulators it needs. This docker container will do it:
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
This command needs to be be run on every reboot of the agent. In AWS EC-2 you can put it in an executable script in /var/lib/cloud/scripts/per-boot/
and see the output in /var/log/cloud-init-output.log
.