forked from ministryofjustice/fb-service-token-cache
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
63 lines (47 loc) · 1.3 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
.PHONY := init push build login serve stop build_image
ifdef TARGET
TARGETDEFINED="true"
else
TARGETDEFINED="false"
endif
dev:
$(eval export env_stub=dev)
@true
test:
$(eval export env_stub=test)
@true
live:
$(eval export env_stub=live)
@true
target:
ifeq ($(TARGETDEFINED), "true")
$(eval export env_stub=${TARGET})
@true
else
$(info Must set TARGET)
@false
endif
init:
$(eval export ECR_REPO_URL=754256621582.dkr.ecr.eu-west-2.amazonaws.com/formbuilder/fb-service-token-cache)
# install aws cli w/o sudo
install_build_dependencies: init
docker --version
pip install --user awscli
$(eval export PATH=${PATH}:${HOME}/.local/bin/)
build_image: install_build_dependencies
docker build -t ${ECR_REPO_URL}:latest-${env_stub} -t ${ECR_REPO_URL}:${CIRCLE_SHA1} -f ./Dockerfile .
login: init
@eval $(shell aws ecr get-login --no-include-email --region eu-west-2)
push: login
docker push ${ECR_REPO_URL}:latest-${env_stub}
docker push ${ECR_REPO_URL}:${CIRCLE_SHA1} #multiple tags in ECR can only be done by pushing twice
build_and_push: build_image push
DOCKER_COMPOSE = docker-compose -f docker-compose.yml
stop:
$(DOCKER_COMPOSE) down -v
build: stop
$(DOCKER_COMPOSE) build
serve: stop build
$(DOCKER_COMPOSE) up
spec: build
$(DOCKER_COMPOSE) run --rm app bundle exec rspec --require spec_helper