Build amd64 and arm64 for docker images

docker buildx for multiarch support

create a builder

because the default builder doesn't support multi-arch building,
create a new builder with docker-container driver and use it

1
docker buildx create  --use --name multiarch --driver docker-container

if your self-build registry is not https, please touch a buildkitd.toml

1
2
3
4
[registry."your-registry-domain or ip"]
http = true
insecure = true

and then use this config to create a builder

1
2
3
# if your builder has already existed, delete it and create
docker buildx rm multiarch
docker buildx create --use --name multiarch --driver docker-container --config ./buildkitd.toml

build the multiarch image and push it to your registry

docker buildx inspect --bootstrap to get the supported platform information

1
2
3
4
5
# don't ignore the trailing dot, it's to search the current directory's Dockerfile file
docker buildx build --push --platform linux/amd64,linux/arm64 -t pplmx/demo:v2.0.0 .

# if you wanna to specify a Dockerfile
docker buildx build --push --platform linux/amd64,linux/arm64 -t pplmx/demo:v2.0.0 -f ./Dockerfile