Last active
October 7, 2022 12:06
-
-
Save josnidhin/4df09b3e6b70f0e976eba8e2788fc28b to your computer and use it in GitHub Desktop.
A simple makefile that I use to build and push docker containers to various AWS accounts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NAME = test-app | |
VERSION = latest | |
TEST_AWS = 111111111111 | |
STAGE_AWS = 222222222222 | |
PROD_AWS = 333333333333 | |
AWS_ECR_DOMAIN = dkr.ecr.eu-west-1.amazonaws.com | |
# Start DO NOT EDIT SECTION | |
define tag | |
docker image tag $(1) | |
endef | |
define push | |
docker image push $(1) | |
endef | |
default: clean-build | |
.PHONY: build | |
build: | |
docker image build -t $(NAME):$(VERSION) . | |
.PHONY: clean-build | |
clean-build: | |
docker image build -t $(NAME):$(VERSION) --no-cache . | |
.PHONY: .tag | |
.tag: | |
$(call tag,$(NAME):$(VERSION) $(AWS_ACC_NO).$(AWS_ECR_DOMAIN)/$(NAME)) | |
.PHONY: .push | |
.push: | |
$(call push,$(AWS_ACC_NO).$(AWS_ECR_DOMAIN)/$(NAME)) | |
# End DO NOT EDIT SECTION | |
# TEST AWS | |
.PHONY: test-aws | |
test-aws: AWS_ACC_NO=$(TEST_AWS) | |
test-aws: .tag .push | |
# STAGE AWS | |
.PHONY: stage-aws | |
stage-aws: AWS_ACC_NO=$(STAGE_AWS) | |
stage-aws: .tag .push | |
# PROD AWS | |
.PHONY: prod-aws | |
prod-aws: AWS_ACC_NO=$(PROD_AWS) | |
prod-aws: .tag .push |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment