Docker + buildx + AWS ECR images
Docker image built on top of official Docker image, with the addition of a helper binary to get a login token for AWS ECR.
This image is mostly useful in CI/CD pipelines to build and publish Docker images to AWS ECR, but can easily be used to publish on other registries.
The machine on which this command is run must be authenticated to the desired AWS account and have an associated IAM policy granting it permission to obtain the token (see the binary's repository for more information).
aws-ecr-get-login-password | docker login -u AWS --password-stdin "${ECR_REGISTRY}"
For a multi-architecture image with buildx, run these commands:
docker run --privileged tonistiigi/binfmt --install all
docker context create multi-arch
docker --context multi-arch buildx create --use
docker --context multi-arch buildx build --platform 'linux/amd64,linux/arm64' -t "${IMAGE_NAME}:${IMAGE_TAG}" .