-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathMakefile
executable file
·179 lines (133 loc) · 6.87 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#!make
# ------------------------------------------------------------------------------
# Makefile -- HA Flight Ops
# ------------------------------------------------------------------------------
include .env
export $(shell sed 's/=.*//' .env)
export GIT_LOCAL_BRANCH?=$(shell git rev-parse --abbrev-ref HEAD)
export DEPLOY_DATE?=$(shell date '+%Y%m%d%H%M')
define deployTag
"${PROJECT}-${GIT_LOCAL_BRANCH}-${DEPLOY_DATE}"
endef
ifndef PROJECT
$(error The PROJECT variable is missing.)
endif
ifndef ENVIRONMENT
$(error The ENVIRONMENT variable is missing.)
endif
#ifndef BUILD_TARGET
#$(error The BUILD_TARGET variable is missing.)
#endif
DIR := ${CURDIR}
all : help
.DEFAULT : help
.PHONY : local database close-local clean-local close-production print-status
# ------------------------------------------------------------------------------
# Task Aliases
# ------------------------------------------------------------------------------
local: | print-status build-local run-local ## Task-Alias -- Run the steps for a local-build.
local-setup: | print-status build-local run-db seed-local close-db
local-debug: | print-status build-local run-debug
local-test-setup: print-status build-local-test run-db-test seed-local-test close-db-test
local-test: | print-status test-local
local-test-watch: | print-status test-local-watch
e2e-setup: | print-status build-e2e run-db-e2e seed-e2e close-db-e2e
# ------------------------------------------------------------------------------
# Status Output
# ------------------------------------------------------------------------------
print-status:
@echo " +---------------------------------------------------------+ "
@echo " | Current Settings | "
@echo " +---------------------------------------------------------+ "
@echo " | PROJECT: $(PROJECT) "
@echo " | BRANCH: $(GIT_LOCAL_BRANCH) "
@echo " +---------------------------------------------------------+ "
@echo " | BUILD_TARGET: $(BUILD_TARGET) "
@echo " +---------------------------------------------------------+ "
@echo " | Docker-Compose Config Output "
@echo " +---------------------------------------------------------+ "
# ------------------------------------------------------------------------------
# Development Commands
# ------------------------------------------------------------------------------
local-env:
@echo "+\n++ Preparing project for local development ...\n+"
build-local: ## -- Target : Builds the local development containers.
@echo "+\n++ Make: Building local Docker image ...\n+"
@docker-compose -f docker-compose.yml build
setup-local: ## -- Target : Prepares the environment variables for local development.
@echo "+\n++ Make: Preparing project for local development ...\n+"
@cp .config/.env.dev .env
run-local: ## -- Target : Runs the local development containers.
@echo "+\n++ Make: Running locally ...\n+"
@docker-compose -f docker-compose.yml up -d
run-debug: ## -- Target : Runs the local development containers.
@echo "+\n++ Make: Running locally for debugging...\n+"
@docker-compose -f docker-compose.yml up
run-db: ## -- Target : Runs the local development containers.
@echo "+\n++ Make: Running db locally...\n+"
@docker-compose -f docker-compose.yml up -d db
close-db: ## -- Target : Runs the local development containers.
@echo "+\n++ Make: Closing local db...\n+"
@docker-compose -f docker-compose.yml stop db
close-db-test: ## -- Target : Runs the local development containers.
@echo "+\n++ Make: Closing local db for test...\n+"
@docker-compose -f test.docker-compose.yml -p myra-test stop db
run-db-test: ## -- Target : Runs the local development containers.
@echo "+\n++ Make: Running db for test locally...\n+"
@docker-compose -f test.docker-compose.yml -p myra-test up -d db minio minio-nginx
close-local: ## -- Target : Closes the local development containers.
@echo "+\n++ Make: Closing local container ...\n+"
@docker-compose -f docker-compose.yml down
clean-local: ## -- Target : Closes and clean local development containers.
@echo "+\n++ Make: Closing and cleaning local container ...\n+"
@docker-compose -f docker-compose.yml down -v
@rm -rf ./_app_data
seed-local:
@echo "+\n++ Make: Seeding local database ...\n+"
@docker-compose -f docker-compose.yml run range_api npm run initialize_docker
seed-local-test:
@echo "+\n++ Make: Seeding local test database ...\n+"
@docker-compose -f test.docker-compose.yml -p myra-test run range_api npm run initialize_docker
test-local-d: ## -- .
@echo "+\n++ Make: Running unit test ...\n+"
@docker-compose -f test.docker-compose.yml -p myra-test up -d
test-local: ## -- .
@echo "+\n++ Make: Running unit test ...\n+"
@docker-compose -f test.docker-compose.yml -p myra-test run --rm range_api npm run test -- --forceExit
test-local-watch: ## -- .
@echo "+\n++ Make: Running unit test ...\n+"
@docker-compose -f test.docker-compose.yml -p myra-test run --rm range_api npm run test:watch
build-local-test: ## -- Target : Builds the local development containers.
@echo "+\n++ Make: Building local Docker image ...\n+"
@docker-compose -f test.docker-compose.yml build
close-local-test: ## -- Target : Closes the local development containers.
@echo "+\n++ Make: Closing local test container ...\n+"
@docker-compose -f test.docker-compose.yml -p myra-test down
clean-local-test: ## -- Target : Closes and clean local development containers.
@echo "+\n++ Make: Closing and cleaning test local container ...\n+"
@docker-compose -f test.docker-compose.yml -p myra-test down -v
# E2E tests
run-e2e:
@docker-compose -f e2e.docker-compose.yml -p myra-e2e up -d
build-e2e:
@docker-compose -f e2e.docker-compose.yml -p myra-e2e build
run-db-e2e:
@docker-compose -f e2e.docker-compose.yml -p myra-e2e up -d db
seed-e2e:
@docker-compose -f e2e.docker-compose.yml -p myra-e2e run range_api npm run initialize_docker
close-db-e2e:
@docker-compose -f e2e.docker-compose.yml -p myra-e2e stop db
# ------------------------------------------------------------------------------
# Helper Commands
# ------------------------------------------------------------------------------
database: ## <Helper> :: Executes into database container.
@echo "Make: Shelling into local database container ..."
@docker-compose -f docker-compose.yml exec db psql -U $(POSTGRESQL_USER) -W $(POSTGRESQL_DATABASE)
database-test: ## <Helper> :: Executes into the test database container.
@echo "Make: Shelling into local database container ..."
@docker-compose -f docker-compose.yml -p myra-test exec db psql -U $(POSTGRESQL_USER) -W $(POSTGRESQL_DATABASE_TEST)
workspace: ## <Workspcae> :: Excute into API container
@echo "Make: Shelling into local api container ..."
@docker-compose -f docker-compose.yml exec range_api bash
help: ## ** Display this help screen.
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'