We have been using docker build for our images.
The build takes place using Jenkins slave on ec2 amd64.
docker build .
The build takes around 5 minutes.
However, now when using docker buildx --platform linux/amd64, linux/arm64.
The build takes much longer around 30 minutes.
From what I understood, it’s because the node is amd64 and it’s using an emulator for building the arm64.
How can we make it faster?
We are having npm install command in our dockerfile and some shell commands.
2
Answers
If you can run that command from an
arm64
ec2 instance, like Graviton, it will run MUCH faster. When we build multi-arch images onarm64
we can build in a matter of minutes, but when doing the same thing onamd64
, it can take well over half an hour depending on the image.arm64
chips seem to be able to handle the multi-arch builds much better thanamd64
, unfortunately.Another option besides running
docker buildx
from a single host, is to build both images on their native architectures quickly, push the resulting containers to the repo and then push the manifest to combine them into a multi-arch container. For larger builds this may be the way to go instead of waiting forever for a build to finish.Sample Refs: