Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Makefile docker push to AWS Elastic Container Registry (ECR)
# Login to AWS registry (must have docker running)
docker/login:
$$(aws ecr get-login --no-include-email --region us-east-1 --profile=mycompany)
# Build docker target
docker/build:
docker build -f Dockerfile --no-cache -t mycompany/myapp .
# Tag docker image
docker/tag:
$(eval REV=$(shell git rev-parse HEAD | cut -c1-7))
docker tag mycompany/myapp:latest 123.dkr.ecr.us-east-1.amazonaws.com/mycompany/myapp:latest
docker tag mycompany/myapp:latest 123.dkr.ecr.us-east-1.amazonaws.com/mycompany/myapp:$(REV)
# Push to registry
docker/push:
$(eval REV=$(shell git rev-parse HEAD | cut -c1-7))
docker push 123.dkr.ecr.us-east-1.amazonaws.com/mycompany/myapp:latest
docker push 123.dkr.ecr.us-east-1.amazonaws.com/mycompany/myapp:$(REV)
# Build docker image and push to AWS registry
docker/build-and-push: docker/login docker/build docker/tag docker/push 
@rederlo

This comment has been minimized.

Copy link

commented Jan 11, 2019

saved my life

@kevinherro

This comment has been minimized.

Copy link

commented Sep 13, 2019

docker/registry/login:
	$$(aws ecr get-login --no-include-email --region us-east-1 --profile=mycompany)

goldmine. thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.