-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
72 lines (52 loc) · 2.79 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Makefile tutorial-deploy-aws-image
# these-targets-are-not-files
.PHONY: all help deploy.test deploy deploy.tasks check.docker_registry docker.login docker.build_ docker.tag docker.build docker.push
# vars
REPO := git@github.com:arthuralvim/deploy-aws-image.git
VERSION := master
ENVIRON := staging
IMAGE_APP_VERSION := 120409133518.dkr.ecr.us-east-1.amazonaws.com/intelivix/tutorial-deploy-aws-image:887c83e
all: help
help:
@echo 'Makefile *** tutorial-deploy-aws-image *** Makefile'
deploy.tasks:
@ansible-playbook -i inventory deploy.yml -l deploy --extra-vars "environ=${ENVIRON} image_app_version=${IMAGE_APP_VERSION}" --list-tasks
deploy.test:
@ansible-playbook -i inventory deploy.yml -l deploy --extra-vars "environ=${ENVIRON} image_app_version=${IMAGE_APP_VERSION}" --list-hosts
deploy:
@ansible-playbook -i inventory deploy.yml -l deploy --extra-vars "environ=${ENVIRON} image_app_version=${IMAGE_APP_VERSION}"
deploy.undo:
@ansible-playbook -i inventory stop.yml -l deploy --extra-vars "environ=${ENVIRON} image_app_version=${IMAGE_APP_VERSION}"
### DOCKER
# export DOCKER_REGISTRY=120409133518.dkr.ecr.us-east-1.amazonaws.com
DOCKER_NAME := intelivix/tutorial-deploy-aws-image
DOCKER_TAG := $$(if [ "${TRAVIS_TAG}" = "" ]; then echo `git log -1 --pretty=%h`; else echo "${TRAVIS_TAG}"; fi)
DOCKER_IMG_TAG := ${DOCKER_NAME}:${DOCKER_TAG}
DOCKER_LATEST := ${DOCKER_NAME}:latest
DOCKER_PR_BRANCH := ${DOCKER_NAME}:${TRAVIS_PULL_REQUEST_BRANCH}
check.docker_registry:
@if test "$(DOCKER_REGISTRY)" = "" ; then echo "DOCKER_REGISTRY is undefined."; exit 1; fi
check.docker_image:
@if test "$(DOCKER_PULL_IMAGE_VERSION)" = "" ; then echo "DOCKER_REGISTRY is undefined."; exit 1; fi
docker.login:
$$(aws ecr get-login --no-include-email --region us-east-1)
docker.build_: check.docker_registry
@echo "Build started on `date`"
@docker build -f Dockerfile -t ${DOCKER_IMG_TAG} .
@echo "Build completed on `date`"
docker.tag: check.docker_registry
@if [ ! -z "${TRAVIS_PULL_REQUEST_BRANCH}" ]; then docker tag ${DOCKER_IMG_TAG} ${DOCKER_REGISTRY}/${DOCKER_PR_BRANCH}; fi
@docker tag ${DOCKER_IMG_TAG} ${DOCKER_REGISTRY}/${DOCKER_IMG_TAG}
docker.build: docker.build_ docker.tag
docker.actual_image: check.docker_registry
@echo ${DOCKER_REGISTRY}/${DOCKER_IMG_TAG}
docker.push: check.docker_registry
@echo "Pushing images started on `date`"
@if [ ! -z "${TRAVIS_PULL_REQUEST_BRANCH}" ]; then docker push ${DOCKER_REGISTRY}/${DOCKER_PR_BRANCH}; fi
@docker push ${DOCKER_REGISTRY}/${DOCKER_IMG_TAG}
@echo "Pushing images completed on `date`"
docker.pull: check.docker_registry
@echo "Pulling images started on `date`"
@if [ ! -z "${TRAVIS_PULL_REQUEST_BRANCH}" ]; then docker pull ${DOCKER_REGISTRY}/${DOCKER_PR_BRANCH}; fi
@docker pull ${DOCKER_REGISTRY}/${DOCKER_IMG_TAG}
@echo "Pulling images completed on `date`"