Multi-Arch Docker Images with ECR

Dependency requirement in Jenkins
1 Docker
2 AWS CLI 2.X / 1.X (If you are using ECR repo)
Create buildX Profile
The default profile doesn’t allow you to create multiple platform , so we need to create new buildX profile by providing following command in your machine where you run buildx commands. jenkinsBuildX
is the name of your buildx.
>> New Profile
docker buildx create --name jenkinsBuildX
>> Use the newly created the profile for build x following command
docker buildx use jenkinsBuildX
>> Check the profile information
docker buildx inspect --bootstrap
Create a Dockerfile you want to create Multi Arch, here am just creating base ubuntu image and pushing to ECR public repo.
FROM ubuntu:20.04
Login to ECR repo via CLI
1#Private repo 2aws ecr get-login-password — region us-west-2 | docker login — username AWS — password-stdin <<AccountID>>.dkr.ecr.us-west-2.amazonaws.com 3#Public repo 4aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws
Run following commands to generate multi-architecture image and push to ECR
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t public.ecr.aws/ALIAS_ID/MyBaseREPO:Ubuntu-20.04 --push .