generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
114 lines (88 loc) · 2.77 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!make
.DEFAULT_GOAL := help
-include .env
export
ifndef ENV
ENV=development
REGISTRY_URL=068084030754.dkr.ecr.eu-west-2.amazonaws.com
endif
UID=$(shell id -u)
DOCKER_COMPOSE = env ENV=${ENV} UID=$(UID) docker-compose -f docker-compose.yml
BUNDLE_FLAGS=
DOCKER_BUILD_CMD = BUNDLE_INSTALL_FLAGS="$(BUNDLE_FLAGS)" $(DOCKER_COMPOSE) build
.PHONY: authenticate_docker
authenticate-docker: ## Authenticate docker script
./scripts/authenticate_docker.sh
.PHONY: build
build: ## docker build image
docker build --platform linux/amd64 -t admin . --build-arg RACK_ENV --build-arg BUNDLE_WITHOUT
.PHONY: build-dev
build-dev: ## build-dev image
$(DOCKER_COMPOSE) build --build-arg BUILD_DEV="true"
.PHONY: shell-dev
shell-dev: ## Run application and start shell
$(DOCKER_COMPOSE) run --rm app sh
.PHONY: start-db
start-db: ## start database
$(DOCKER_COMPOSE) up -d admin-db
ENV=${ENV} ./scripts/wait_for_db.sh
.PHONY: db-setup
db-setup: ## setup database
$(MAKE) start-db
$(DOCKER_COMPOSE) run --rm app ./bin/rails db:drop db:create db:schema:load
.PHONY: serve
serve: ## Start application
$(MAKE) stop
$(MAKE) start-db
$(DOCKER_COMPOSE) up app
.PHONY: phpmyadmin
phpmyadmin: ## Start phpmyadmin
$(DOCKER_COMPOSE) up phpmyadmin
# TODO - this is potentially not needed, but we should check by running tests before removing
# run: serve
.PHONY: test
test: ## build and run tests
export ENV=test
$(DOCKER_COMPOSE) run -e COVERAGE=true --rm app bundle exec rake
.PHONY: shell
shell: ## build and run tests in shell
$(DOCKER_COMPOSE) run --rm app sh
.PHONY: shell-test
shell-test: ## build and run tests in shell with test variable
export ENV=test
$(DOCKER_COMPOSE) run --rm app sh
.PHONY: stop
stop: ## docker compose down
$(DOCKER_COMPOSE) down
.PHONY: migrate
migrate: ## run migrate script
./scripts/migrate.sh
.PHONY: seed
seed: ## run seed script
./scripts/seed.sh
.PHONY: migrate-dev
migrate-dev: ## run rails migrate dev
$(DOCKER_COMPOSE) run --rm app bundle exec rake db:migrate
.PHONY: bootstrap
bootstrap: ## run bootstrap script
./scripts/bootstrap.sh
.PHONY: deploy
deploy: ## run deploy script
./scripts/deploy.sh
.PHONY: push
push: ## push image to ECR
aws ecr get-login-password | docker login --username AWS --password-stdin ${REGISTRY_URL}
docker tag admin:latest ${REGISTRY_URL}/staff-device-${ENV}-dhcp-admin:latest
docker push ${REGISTRY_URL}/staff-device-${ENV}-dhcp-admin:latest
.PHONY: publish
publish: ## run build and push targets
$(MAKE) build
$(MAKE) push
.PHONY: lint
lint: ## lint
$(DOCKER_COMPOSE) run --rm app bundle exec rake standard:fix
.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}'