-
Notifications
You must be signed in to change notification settings - Fork 14
/
Makefile
272 lines (181 loc) · 7.47 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
APP_NAME = mosquittoChat
PROJECT_NAME = mosquittoChat
UNIT_TESTING_NAME = mosquittoChatunit
CONTRACT_TESTING_NAME = mosquittoChatcontract
INTEGRATION_TESTING_NAME = mosquittoChatintegration
COMPONENT_TESTING_NAME = mosquittoChatcomponent
END_TO_END_TESTING_NAME = mosquittoChate2e
UNIT_TEST_DIR = $(PWD)/tests/unit
CONTRACT_TEST_DIR = $(PWD)/tests/contract
INTEGRATION_TEST_DIR = $(PWD)/tests/integration
COMPONENT_TEST_DIR = $(PWD)/tests/component
END_TO_END_TEST_DIR = $(PWD)/tests/e2e
PROJECT_ROOT_DIR = $(PWD)
DATA_VOLUME_NAME = $(PROJECT_NAME)_mosquitto_data_volume
DEPLOY_ENVIRONMENT = production
CI_SERVER = travis
DOCKER = docker
DOCKER_COMPOSE = docker-compose
ifeq ($(CI_SERVER), jenkins)
DOCKER = sudo docker
DOCKER_COMPOSE = sudo docker-compose
endif
.PHONY: travis-setup jenkins-setup
travis-setup:
bash -c "scripts/travis-setup.sh $(PROJECT_ROOT_DIR)"
jenkins-setup:
bash -c "scripts/jenkins-setup.sh $(PROJECT_ROOT_DIR)"
.PHONY: clean-pyc clean-build
clean-pyc:
find . -name '*.pyc' -exec rm --force {} +
find . -name '*.pyo' -exec rm --force {} +
find . -name '*~' -exec rm --force {} +
clean-build:
rm --force --recursive build/
rm --force --recursive dist/
rm --force --recursive *.egg-info
.PHONY: build-volume-prod remove-volume-prod
build-volume-prod:
$(DOCKER) volume create --driver=rexray --opt=size=4 --opt=volumeType=gp2 $(DATA_VOLUME_NAME)
remove-volume-prod:
$(DOCKER) volume rm $(DATA_VOLUME_NAME)
.PHONY: build build-dev build-prod
build: build-dev
build-dev:
bash -c "source docker.env && $(DOCKER_COMPOSE) -p $(PROJECT_NAME) build"
build-prod: build-volume-prod
sudo sysctl -w vm.max_map_count=262144
.PHONY: start start-dev start-prod
start: start-dev
start-dev: build-dev
bash -c "source docker.env && $(DOCKER_COMPOSE) -p $(PROJECT_NAME) up -d"
start-prod:
bash -c "source docker.env && $(DOCKER) stack deploy --compose-file docker-compose.prod.yml $(PROJECT_NAME)"
.PHONY: stop stop-dev stop-prod stop-all
stop: stop-dev
stop-dev:
$(DOCKER_COMPOSE) -p $(PROJECT_NAME) stop
stop-prod:
$(DOCKER) stack rm $(PROJECT_NAME)
stop-all: stop-dev stop-prod
.PHONY: remove remove-dev remove-prod remove-all
remove: remove-dev
remove-dev: stop-dev
$(DOCKER_COMPOSE) -p $(PROJECT_NAME) rm --force -v
remove-prod: stop-prod
remove-all: remove-dev remove-prod
.PHONY: check-logs check-logs-dev check-logs-dev-app check-logs-app check-logs-prod check-logs-prod-app
check-logs: check-logs-dev
check-logs-app: check-logs-dev-app
check-logs-dev:
$(DOCKER_COMPOSE) -p $(PROJECT_NAME) logs --follow --tail=10 $(APP_NAME)
check-logs-dev-app:
$(DOCKER_COMPOSE) -p $(PROJECT_NAME) logs --follow --tail=10
check-logs-prod:
$(DOCKER_COMPOSE) -p $(PROJECT_NAME) -f docker-compose.prod.yml logs --follow --tail=10 $(APP_NAME)
check-logs-prod-app:
$(DOCKER_COMPOSE) -p $(PROJECT_NAME) -f docker-compose.prod.yml logs --follow --tail=10
.PHONY: system-prune clean clean-dev clean-prod clean-all
system-prune:
echo "y" | $(DOCKER) system prune
clean: clean-dev
clean-dev: remove-dev system-prune
clean-prod: remove-prod system-prune
clean-all: clean-dev clean-prod
.PHONY: test test-unit test-component test-contract test-integration test-e2e test-system test-ui-acceptance test-functional
# testing:
# ./tests/test.sh $(APP_NAME) unit $(UNIT_TESTING_NAME) $(UNIT_TEST_DIR)
test-unit:
bash -c "tests/test.sh $(APP_NAME) unit $(UNIT_TESTING_NAME) $(UNIT_TEST_DIR) $(PROJECT_ROOT_DIR) $(CI_SERVER)"
test-component:
bash -c "tests/test.sh $(APP_NAME) component $(COMPONENT_TESTING_NAME) $(COMPONENT_TEST_DIR) $(PROJECT_ROOT_DIR) $(CI_SERVER)"
test-contract:
bash -c "tests/test.sh $(APP_NAME) contract $(CONTRACT_TESTING_NAME) $(CONTRACT_TEST_DIR) $(PROJECT_ROOT_DIR) $(CI_SERVER)"
test-integration:
bash -c "tests/test.sh $(APP_NAME) integration $(INTEGRATION_TESTING_NAME) $(INTEGRATION_TEST_DIR) $(PROJECT_ROOT_DIR) $(CI_SERVER)"
test-e2e:
bash -c "tests/test.sh $(APP_NAME) e2e $(END_TO_END_TESTING_NAME) $(END_TO_END_TEST_DIR) $(PROJECT_ROOT_DIR) $(CI_SERVER)"
test-system: test-e2e
test-ui-acceptance: test-e2e
test-functional: test-e2e
test: system-prune test-unit test-integration test-component test-ui-acceptance
test-staging: test-e2e
.PHONY: build-tag-push deploy
build-tag-push:
bash -c "scripts/build-tag-push-image.sh $(CI_SERVER)"
deploy:
bash -c "scripts/deploy.sh $(CI_SERVER) $(DEPLOY_ENVIRONMENT)"
.PHONY: help
help:
@echo " clean-pyc"
@echo " Remove python artifacts."
@echo " clean-build"
@echo " Remove build artifacts."
@echo " build"
@echo " Build Project in Development Environment Docker Container"
@echo " build-dev"
@echo " Alias for build"
@echo " build-prod"
@echo " Build Project in Production Environment Docker Container"
@echo " start"
@echo " Start and Run Project in Development Environment Docker Container"
@echo " start-dev"
@echo " Alias for start"
@echo " start-prod"
@echo " Start and Run Project in Production Environmen Docker Containert"
@echo " stop"
@echo " Stop the Development Environment Docker Container"
@echo " stop-dev"
@echo " Alias for stop"
@echo " stop-prod"
@echo " Stop the Production Environment Docker Container"
@echo " stop-all"
@echo " Stop both the Development and Production Environment Docker Containers"
@echo " remove"
@echo " Remove the Development Environment Docker Container"
@echo " remove-dev"
@echo " Alias for remove"
@echo " remove-prod"
@echo " Remove the Production Environment Docker Container"
@echo " remove-all"
@echo " Remove both the Development and Production Environment Docker Containers"
@echo " check-logs"
@echo " Alias for check-logs-dev"
@echo " check-logs-app"
@echo " Alias for check-logs-dev-app"
@echo " check-logs-dev"
@echo " Check logs of the Development Environment Docker Container"
@echo " check-logs-dev-app"
@echo " Check logs of the Main Application in the Development Environment Docker Containers"
@echo " check-logs-prod"
@echo " Check logs of the Production Environment Docker Container"
@echo " check-logs-prod-app"
@echo " Check logs of the Main Application in the Production Environment Docker Containers"
@echo " clean"
@echo " Clean the Development Environment Docker Container"
@echo " clean-dev"
@echo " Alias for clean"
@echo " clean-prod"
@echo " Clean the Production Environment Docker Container"
@echo " clean-all"
@echo " Clean both the Development and Production Environment Docker Containers"
@echo " system-prune"
@echo " Clean both the Development and Production Environment Docker Containers, volumes, images which are dangling"
@echo " test-unit"
@echo " Perform Unit tests in Docker Container"
@echo " test-contract"
@echo " Perform Contract tests in Docker Container"
@echo " test-component"
@echo " Perform Component tests in Docker Container"
@echo " test-integration"
@echo " Perform Integration tests in Docker Container"
@echo " test-e2e"
@echo " Perform End to End tests in Docker Container"
@echo " test-system"
@echo " Alias for test-e2d"
@echo " test-functional"
@echo " Alias for test-e2d"
@echo " test-ui-acceptance"
@echo " Alias for test-e2d"
@echo " test"
@echo " Test Everything (unit, Contract, Component, Integration, E2E"