generated from ministryofjustice/cloud-platform-terraform-template
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
78 lines (60 loc) · 2.31 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
73
74
75
76
77
78
-include .env
export
.DEFAULT_GOAL := help
DOCKER_COMPOSE = docker-compose -f docker-compose.yml
.PHONY: authenticate-docker
authenticate-docker: ## Authenticate docker using ssm paramstore
./scripts/authenticate_docker.sh
.PHONY: build
build: ## Docker build dhcp service
docker build --platform=linux/amd64 -t dhcp ./dhcp-service
.PHONY: build-nginx
build-nginx: ## Docker build nginx
docker build --platform=linux/amd64 -t nginx ./nginx
.PHONY: push-nginx
push-nginx: ## Docker tag nginx with latest and push to ECR
aws ecr get-login-password | docker login --username AWS --password-stdin ${REGISTRY_URL}
docker tag nginx:latest ${REGISTRY_URL}/staff-device-${ENV}-dhcp-nginx:latest
docker push ${REGISTRY_URL}/staff-device-${ENV}-dhcp-nginx:latest
.PHONY: push
push: ## Docker tag dhcp image with latest and push to ECR
aws ecr get-login-password | docker login --username AWS --password-stdin ${REGISTRY_URL}
docker tag dhcp:latest ${REGISTRY_URL}/staff-device-${ENV}-dhcp:latest
docker push ${REGISTRY_URL}/staff-device-${ENV}-dhcp:latest
.PHONY: publish
publish: ## Build docker image, tag and push dhcp:latest, build nginx image, tag with latest and push
$(MAKE) build
$(MAKE) push
$(MAKE) build-nginx
$(MAKE) push-nginx
.PHONY: deploy
deploy: ## Run deploy script
./scripts/deploy.sh
.PHONY: build-dev
build-dev: ## Build dev image
$(DOCKER_COMPOSE) build
.PHONY: stop
stop: ## Stop and remove containers
$(DOCKER_COMPOSE) down -v
.PHONY: run
run: ## Build dev image and start dhcp container
$(DOCKER_COMPOSE) up -d dhcp-primary
$(DOCKER_COMPOSE) up -d dhcp-standby
$(DOCKER_COMPOSE) up -d dhcp-api
.PHONY: test
test: ## Build dev container, start dhcp container, run tests
$(DOCKER_COMPOSE) run --rm dhcp-test rspec -f d ./spec
.PHONY: shell
shell: ## Build dev image and start dhcp in shell
$(DOCKER_COMPOSE) run --rm dhcp-primary sh
.PHONY: shell-test
shell-test: ## Build dev container and tests in shell
$(DOCKER_COMPOSE) run --rm dhcp-test sh
.PHONY: logs
logs: ## Command will continue streaming the new output from the container's stdout and stderr
$(DOCKER_COMPOSE) logs --follow
.PHONY: implode
implode: ## remove docker container
$(DOCKER_COMPOSE) rm
help:
@grep -h -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'