chialab / docker-buildx-ecr

A Docker image shipped with tools to build multi-arch images with buildx and authenticate against AWS ECR.
MIT License
3 stars 1 forks source link

Docker + buildx + AWS ECR images

Build status Authors link License


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.

Usage

Login to ECR

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}"

Build container

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}" .