-
Notifications
You must be signed in to change notification settings - Fork 15
/
Makefile
369 lines (304 loc) · 24.1 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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
include .env
# Determine if .env.local file exist
ifneq ("$(wildcard .env.local)", "")
include .env.local
endif
ifndef INSIDE_DOCKER_CONTAINER
INSIDE_DOCKER_CONTAINER = 0
endif
HOST_UID := $(shell id -u)
HOST_GID := $(shell id -g)
PHP_USER := -u www-data
PROJECT_NAME := -p ${COMPOSE_PROJECT_NAME}
OPENSSL_BIN := $(shell which openssl)
INTERACTIVE := $(shell [ -t 0 ] && echo 1)
ERROR_ONLY_FOR_HOST = @printf "\033[33mThis command for host machine\033[39m\n"
.DEFAULT_GOAL := help
ifneq ($(INTERACTIVE), 1)
OPTION_T := -T
endif
ifeq ($(GITLAB_CI), 1)
# Determine additional params for phpunit in order to generate coverage badge on GitLabCI side
PHPUNIT_OPTIONS := --coverage-text --colors=never
endif
help: ## Shows available commands with description
@echo "\033[34mList of available commands:\033[39m"
@grep -E '^[a-zA-Z-]+:.*?## .*$$' Makefile | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "[32m%-27s[0m %s\n", $$1, $$2}'
load-staging-env:
$(eval include .env.staging)
load-prod-env:
$(eval include .env.prod)
build: ## Build dev environment
ifeq ($(INSIDE_DOCKER_CONTAINER), 0)
@HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) WEB_PORT_HTTP=$(WEB_PORT_HTTP) WEB_PORT_SSL=$(WEB_PORT_SSL) XDEBUG_CONFIG=$(XDEBUG_CONFIG) XDEBUG_VERSION=$(XDEBUG_VERSION) MYSQL_VERSION=$(MYSQL_VERSION) INNODB_USE_NATIVE_AIO=$(INNODB_USE_NATIVE_AIO) SQL_MODE=$(SQL_MODE) MYSQL_ROOT_PASSWORD=$(MYSQL_ROOT_PASSWORD) MYSQL_PORT=$(MYSQL_PORT) RABBITMQ_ERLANG_COOKIE=$(RABBITMQ_ERLANG_COOKIE) RABBITMQ_USER=$(RABBITMQ_USER) RABBITMQ_PASS=$(RABBITMQ_PASS) RABBITMQ_MANAGEMENT_PORT=$(RABBITMQ_MANAGEMENT_PORT) docker compose -f compose.yaml build
else
$(ERROR_ONLY_FOR_HOST)
endif
build-test: ## Build test or continuous integration environment
ifeq ($(INSIDE_DOCKER_CONTAINER), 0)
@HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) WEB_PORT_HTTP=$(WEB_PORT_HTTP) WEB_PORT_SSL=$(WEB_PORT_SSL) XDEBUG_CONFIG=$(XDEBUG_CONFIG) XDEBUG_VERSION=$(XDEBUG_VERSION) MYSQL_VERSION=$(MYSQL_VERSION) INNODB_USE_NATIVE_AIO=$(INNODB_USE_NATIVE_AIO) SQL_MODE=$(SQL_MODE) MYSQL_ROOT_PASSWORD=$(MYSQL_ROOT_PASSWORD) MYSQL_PORT=$(MYSQL_PORT) RABBITMQ_ERLANG_COOKIE=$(RABBITMQ_ERLANG_COOKIE) RABBITMQ_USER=$(RABBITMQ_USER) RABBITMQ_PASS=$(RABBITMQ_PASS) RABBITMQ_MANAGEMENT_PORT=$(RABBITMQ_MANAGEMENT_PORT) docker compose -f compose-test-ci.yaml build
else
$(ERROR_ONLY_FOR_HOST)
endif
build-staging: load-staging-env ## Build staging environment
ifeq ($(INSIDE_DOCKER_CONTAINER), 0)
@HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) WEB_PORT_HTTP=$(WEB_PORT_HTTP) WEB_PORT_SSL=$(WEB_PORT_SSL) MYSQL_VERSION=$(MYSQL_VERSION) INNODB_USE_NATIVE_AIO=$(INNODB_USE_NATIVE_AIO) SQL_MODE=$(SQL_MODE) MYSQL_ROOT_PASSWORD=$(MYSQL_ROOT_PASSWORD) MYSQL_PORT=$(MYSQL_PORT) RABBITMQ_ERLANG_COOKIE=$(RABBITMQ_ERLANG_COOKIE) RABBITMQ_USER=$(RABBITMQ_USER) RABBITMQ_PASS=$(RABBITMQ_PASS) RABBITMQ_MANAGEMENT_PORT=$(RABBITMQ_MANAGEMENT_PORT) docker compose -f compose-staging.yaml build
else
$(ERROR_ONLY_FOR_HOST)
endif
build-prod: load-prod-env ## Build prod environment
ifeq ($(INSIDE_DOCKER_CONTAINER), 0)
@HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) WEB_PORT_HTTP=$(WEB_PORT_HTTP) WEB_PORT_SSL=$(WEB_PORT_SSL) MYSQL_VERSION=$(MYSQL_VERSION) INNODB_USE_NATIVE_AIO=$(INNODB_USE_NATIVE_AIO) SQL_MODE=$(SQL_MODE) MYSQL_ROOT_PASSWORD=$(MYSQL_ROOT_PASSWORD) MYSQL_PORT=$(MYSQL_PORT) RABBITMQ_ERLANG_COOKIE=$(RABBITMQ_ERLANG_COOKIE) RABBITMQ_USER=$(RABBITMQ_USER) RABBITMQ_PASS=$(RABBITMQ_PASS) RABBITMQ_MANAGEMENT_PORT=$(RABBITMQ_MANAGEMENT_PORT) docker compose -f compose-prod.yaml build
else
$(ERROR_ONLY_FOR_HOST)
endif
start: ## Start dev environment
ifeq ($(INSIDE_DOCKER_CONTAINER), 0)
@HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) WEB_PORT_HTTP=$(WEB_PORT_HTTP) WEB_PORT_SSL=$(WEB_PORT_SSL) XDEBUG_CONFIG=$(XDEBUG_CONFIG) XDEBUG_VERSION=$(XDEBUG_VERSION) MYSQL_VERSION=$(MYSQL_VERSION) INNODB_USE_NATIVE_AIO=$(INNODB_USE_NATIVE_AIO) SQL_MODE=$(SQL_MODE) MYSQL_ROOT_PASSWORD=$(MYSQL_ROOT_PASSWORD) MYSQL_PORT=$(MYSQL_PORT) RABBITMQ_ERLANG_COOKIE=$(RABBITMQ_ERLANG_COOKIE) RABBITMQ_USER=$(RABBITMQ_USER) RABBITMQ_PASS=$(RABBITMQ_PASS) RABBITMQ_MANAGEMENT_PORT=$(RABBITMQ_MANAGEMENT_PORT) docker compose -f compose.yaml $(PROJECT_NAME) up -d
else
$(ERROR_ONLY_FOR_HOST)
endif
start-test: ## Start test or continuous integration environment
ifeq ($(INSIDE_DOCKER_CONTAINER), 0)
@HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) WEB_PORT_HTTP=$(WEB_PORT_HTTP) WEB_PORT_SSL=$(WEB_PORT_SSL) XDEBUG_CONFIG=$(XDEBUG_CONFIG) XDEBUG_VERSION=$(XDEBUG_VERSION) MYSQL_VERSION=$(MYSQL_VERSION) INNODB_USE_NATIVE_AIO=$(INNODB_USE_NATIVE_AIO) SQL_MODE=$(SQL_MODE) MYSQL_ROOT_PASSWORD=$(MYSQL_ROOT_PASSWORD) MYSQL_PORT=$(MYSQL_PORT) RABBITMQ_ERLANG_COOKIE=$(RABBITMQ_ERLANG_COOKIE) RABBITMQ_USER=$(RABBITMQ_USER) RABBITMQ_PASS=$(RABBITMQ_PASS) RABBITMQ_MANAGEMENT_PORT=$(RABBITMQ_MANAGEMENT_PORT) docker compose -f compose-test-ci.yaml $(PROJECT_NAME) up -d
else
$(ERROR_ONLY_FOR_HOST)
endif
start-staging: load-staging-env ## Start staging environment
ifeq ($(INSIDE_DOCKER_CONTAINER), 0)
@HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) WEB_PORT_HTTP=$(WEB_PORT_HTTP) WEB_PORT_SSL=$(WEB_PORT_SSL) MYSQL_VERSION=$(MYSQL_VERSION) INNODB_USE_NATIVE_AIO=$(INNODB_USE_NATIVE_AIO) SQL_MODE=$(SQL_MODE) MYSQL_ROOT_PASSWORD=$(MYSQL_ROOT_PASSWORD) MYSQL_PORT=$(MYSQL_PORT) RABBITMQ_ERLANG_COOKIE=$(RABBITMQ_ERLANG_COOKIE) RABBITMQ_USER=$(RABBITMQ_USER) RABBITMQ_PASS=$(RABBITMQ_PASS) RABBITMQ_MANAGEMENT_PORT=$(RABBITMQ_MANAGEMENT_PORT) docker compose -f compose-staging.yaml $(PROJECT_NAME) up -d
else
$(ERROR_ONLY_FOR_HOST)
endif
start-prod: load-prod-env ## Start prod environment
ifeq ($(INSIDE_DOCKER_CONTAINER), 0)
@HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) WEB_PORT_HTTP=$(WEB_PORT_HTTP) WEB_PORT_SSL=$(WEB_PORT_SSL) MYSQL_VERSION=$(MYSQL_VERSION) INNODB_USE_NATIVE_AIO=$(INNODB_USE_NATIVE_AIO) SQL_MODE=$(SQL_MODE) MYSQL_ROOT_PASSWORD=$(MYSQL_ROOT_PASSWORD) MYSQL_PORT=$(MYSQL_PORT) RABBITMQ_ERLANG_COOKIE=$(RABBITMQ_ERLANG_COOKIE) RABBITMQ_USER=$(RABBITMQ_USER) RABBITMQ_PASS=$(RABBITMQ_PASS) RABBITMQ_MANAGEMENT_PORT=$(RABBITMQ_MANAGEMENT_PORT) docker compose -f compose-prod.yaml $(PROJECT_NAME) up -d
else
$(ERROR_ONLY_FOR_HOST)
endif
stop: ## Stop dev environment containers
ifeq ($(INSIDE_DOCKER_CONTAINER), 0)
@HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) WEB_PORT_HTTP=$(WEB_PORT_HTTP) WEB_PORT_SSL=$(WEB_PORT_SSL) XDEBUG_CONFIG=$(XDEBUG_CONFIG) XDEBUG_VERSION=$(XDEBUG_VERSION) MYSQL_VERSION=$(MYSQL_VERSION) INNODB_USE_NATIVE_AIO=$(INNODB_USE_NATIVE_AIO) SQL_MODE=$(SQL_MODE) MYSQL_ROOT_PASSWORD=$(MYSQL_ROOT_PASSWORD) MYSQL_PORT=$(MYSQL_PORT) RABBITMQ_ERLANG_COOKIE=$(RABBITMQ_ERLANG_COOKIE) RABBITMQ_USER=$(RABBITMQ_USER) RABBITMQ_PASS=$(RABBITMQ_PASS) RABBITMQ_MANAGEMENT_PORT=$(RABBITMQ_MANAGEMENT_PORT) docker compose -f compose.yaml $(PROJECT_NAME) stop
else
$(ERROR_ONLY_FOR_HOST)
endif
stop-test: ## Stop test or continuous integration environment containers
ifeq ($(INSIDE_DOCKER_CONTAINER), 0)
@HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) WEB_PORT_HTTP=$(WEB_PORT_HTTP) WEB_PORT_SSL=$(WEB_PORT_SSL) XDEBUG_CONFIG=$(XDEBUG_CONFIG) XDEBUG_VERSION=$(XDEBUG_VERSION) MYSQL_VERSION=$(MYSQL_VERSION) INNODB_USE_NATIVE_AIO=$(INNODB_USE_NATIVE_AIO) SQL_MODE=$(SQL_MODE) MYSQL_ROOT_PASSWORD=$(MYSQL_ROOT_PASSWORD) MYSQL_PORT=$(MYSQL_PORT) RABBITMQ_ERLANG_COOKIE=$(RABBITMQ_ERLANG_COOKIE) RABBITMQ_USER=$(RABBITMQ_USER) RABBITMQ_PASS=$(RABBITMQ_PASS) RABBITMQ_MANAGEMENT_PORT=$(RABBITMQ_MANAGEMENT_PORT) docker compose -f compose-test-ci.yaml $(PROJECT_NAME) stop
else
$(ERROR_ONLY_FOR_HOST)
endif
stop-staging: load-staging-env ## Stop staging environment containers
ifeq ($(INSIDE_DOCKER_CONTAINER), 0)
@HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) WEB_PORT_HTTP=$(WEB_PORT_HTTP) WEB_PORT_SSL=$(WEB_PORT_SSL) MYSQL_VERSION=$(MYSQL_VERSION) INNODB_USE_NATIVE_AIO=$(INNODB_USE_NATIVE_AIO) SQL_MODE=$(SQL_MODE) MYSQL_ROOT_PASSWORD=$(MYSQL_ROOT_PASSWORD) MYSQL_PORT=$(MYSQL_PORT) RABBITMQ_ERLANG_COOKIE=$(RABBITMQ_ERLANG_COOKIE) RABBITMQ_USER=$(RABBITMQ_USER) RABBITMQ_PASS=$(RABBITMQ_PASS) RABBITMQ_MANAGEMENT_PORT=$(RABBITMQ_MANAGEMENT_PORT) docker compose -f compose-staging.yaml $(PROJECT_NAME) stop
else
$(ERROR_ONLY_FOR_HOST)
endif
stop-prod: load-prod-env ## Stop prod environment containers
ifeq ($(INSIDE_DOCKER_CONTAINER), 0)
@HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) WEB_PORT_HTTP=$(WEB_PORT_HTTP) WEB_PORT_SSL=$(WEB_PORT_SSL) MYSQL_VERSION=$(MYSQL_VERSION) INNODB_USE_NATIVE_AIO=$(INNODB_USE_NATIVE_AIO) SQL_MODE=$(SQL_MODE) MYSQL_ROOT_PASSWORD=$(MYSQL_ROOT_PASSWORD) MYSQL_PORT=$(MYSQL_PORT) RABBITMQ_ERLANG_COOKIE=$(RABBITMQ_ERLANG_COOKIE) RABBITMQ_USER=$(RABBITMQ_USER) RABBITMQ_PASS=$(RABBITMQ_PASS) RABBITMQ_MANAGEMENT_PORT=$(RABBITMQ_MANAGEMENT_PORT) docker compose -f compose-prod.yaml $(PROJECT_NAME) stop
else
$(ERROR_ONLY_FOR_HOST)
endif
down: ## Stop and remove dev environment containers, networks
ifeq ($(INSIDE_DOCKER_CONTAINER), 0)
@HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) WEB_PORT_HTTP=$(WEB_PORT_HTTP) WEB_PORT_SSL=$(WEB_PORT_SSL) XDEBUG_CONFIG=$(XDEBUG_CONFIG) XDEBUG_VERSION=$(XDEBUG_VERSION) MYSQL_VERSION=$(MYSQL_VERSION) INNODB_USE_NATIVE_AIO=$(INNODB_USE_NATIVE_AIO) SQL_MODE=$(SQL_MODE) MYSQL_ROOT_PASSWORD=$(MYSQL_ROOT_PASSWORD) MYSQL_PORT=$(MYSQL_PORT) RABBITMQ_ERLANG_COOKIE=$(RABBITMQ_ERLANG_COOKIE) RABBITMQ_USER=$(RABBITMQ_USER) RABBITMQ_PASS=$(RABBITMQ_PASS) RABBITMQ_MANAGEMENT_PORT=$(RABBITMQ_MANAGEMENT_PORT) docker compose -f compose.yaml $(PROJECT_NAME) down
else
$(ERROR_ONLY_FOR_HOST)
endif
down-test: ## Stop and remove test or continuous integration environment containers, networks
ifeq ($(INSIDE_DOCKER_CONTAINER), 0)
@HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) WEB_PORT_HTTP=$(WEB_PORT_HTTP) WEB_PORT_SSL=$(WEB_PORT_SSL) XDEBUG_CONFIG=$(XDEBUG_CONFIG) XDEBUG_VERSION=$(XDEBUG_VERSION) MYSQL_VERSION=$(MYSQL_VERSION) INNODB_USE_NATIVE_AIO=$(INNODB_USE_NATIVE_AIO) SQL_MODE=$(SQL_MODE) MYSQL_ROOT_PASSWORD=$(MYSQL_ROOT_PASSWORD) MYSQL_PORT=$(MYSQL_PORT) RABBITMQ_ERLANG_COOKIE=$(RABBITMQ_ERLANG_COOKIE) RABBITMQ_USER=$(RABBITMQ_USER) RABBITMQ_PASS=$(RABBITMQ_PASS) RABBITMQ_MANAGEMENT_PORT=$(RABBITMQ_MANAGEMENT_PORT) docker compose -f compose-test-ci.yaml $(PROJECT_NAME) down
else
$(ERROR_ONLY_FOR_HOST)
endif
down-staging: load-staging-env ## Stop and remove staging environment containers, networks
ifeq ($(INSIDE_DOCKER_CONTAINER), 0)
@HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) WEB_PORT_HTTP=$(WEB_PORT_HTTP) WEB_PORT_SSL=$(WEB_PORT_SSL) MYSQL_VERSION=$(MYSQL_VERSION) INNODB_USE_NATIVE_AIO=$(INNODB_USE_NATIVE_AIO) SQL_MODE=$(SQL_MODE) MYSQL_ROOT_PASSWORD=$(MYSQL_ROOT_PASSWORD) MYSQL_PORT=$(MYSQL_PORT) RABBITMQ_ERLANG_COOKIE=$(RABBITMQ_ERLANG_COOKIE) RABBITMQ_USER=$(RABBITMQ_USER) RABBITMQ_PASS=$(RABBITMQ_PASS) RABBITMQ_MANAGEMENT_PORT=$(RABBITMQ_MANAGEMENT_PORT) docker compose -f compose-staging.yaml $(PROJECT_NAME) down
else
$(ERROR_ONLY_FOR_HOST)
endif
down-prod: load-prod-env ## Stop and remove prod environment containers, networks
ifeq ($(INSIDE_DOCKER_CONTAINER), 0)
@HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) WEB_PORT_HTTP=$(WEB_PORT_HTTP) WEB_PORT_SSL=$(WEB_PORT_SSL) MYSQL_VERSION=$(MYSQL_VERSION) INNODB_USE_NATIVE_AIO=$(INNODB_USE_NATIVE_AIO) SQL_MODE=$(SQL_MODE) MYSQL_ROOT_PASSWORD=$(MYSQL_ROOT_PASSWORD) MYSQL_PORT=$(MYSQL_PORT) RABBITMQ_ERLANG_COOKIE=$(RABBITMQ_ERLANG_COOKIE) RABBITMQ_USER=$(RABBITMQ_USER) RABBITMQ_PASS=$(RABBITMQ_PASS) RABBITMQ_MANAGEMENT_PORT=$(RABBITMQ_MANAGEMENT_PORT) docker compose -f compose-prod.yaml $(PROJECT_NAME) down
else
$(ERROR_ONLY_FOR_HOST)
endif
restart: stop start ## Stop and start dev environment
restart-test: stop-test start-test ## Stop and start test or continuous integration environment
restart-staging: stop-staging start-staging ## Stop and start staging environment
restart-prod: stop-prod start-prod ## Stop and start prod environment
env-prod: ## Creates cached config file .env.local.php (usually for prod environment)
@make exec cmd="composer dump-env prod"
env-staging: ## Creates cached config file .env.local.php (usually for staging environment)
@make exec cmd="composer dump-env staging"
ssh: ## Get bash inside symfony docker container
ifeq ($(INSIDE_DOCKER_CONTAINER), 0)
@HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) WEB_PORT_HTTP=$(WEB_PORT_HTTP) WEB_PORT_SSL=$(WEB_PORT_SSL) XDEBUG_CONFIG=$(XDEBUG_CONFIG) XDEBUG_VERSION=$(XDEBUG_VERSION) MYSQL_VERSION=$(MYSQL_VERSION) INNODB_USE_NATIVE_AIO=$(INNODB_USE_NATIVE_AIO) SQL_MODE=$(SQL_MODE) MYSQL_ROOT_PASSWORD=$(MYSQL_ROOT_PASSWORD) MYSQL_PORT=$(MYSQL_PORT) RABBITMQ_ERLANG_COOKIE=$(RABBITMQ_ERLANG_COOKIE) RABBITMQ_USER=$(RABBITMQ_USER) RABBITMQ_PASS=$(RABBITMQ_PASS) RABBITMQ_MANAGEMENT_PORT=$(RABBITMQ_MANAGEMENT_PORT) docker compose $(PROJECT_NAME) exec $(OPTION_T) $(PHP_USER) symfony bash
else
$(ERROR_ONLY_FOR_HOST)
endif
ssh-root: ## Get bash as root user inside symfony docker container
ifeq ($(INSIDE_DOCKER_CONTAINER), 0)
@HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) WEB_PORT_HTTP=$(WEB_PORT_HTTP) WEB_PORT_SSL=$(WEB_PORT_SSL) XDEBUG_CONFIG=$(XDEBUG_CONFIG) XDEBUG_VERSION=$(XDEBUG_VERSION) MYSQL_VERSION=$(MYSQL_VERSION) INNODB_USE_NATIVE_AIO=$(INNODB_USE_NATIVE_AIO) SQL_MODE=$(SQL_MODE) MYSQL_ROOT_PASSWORD=$(MYSQL_ROOT_PASSWORD) MYSQL_PORT=$(MYSQL_PORT) RABBITMQ_ERLANG_COOKIE=$(RABBITMQ_ERLANG_COOKIE) RABBITMQ_USER=$(RABBITMQ_USER) RABBITMQ_PASS=$(RABBITMQ_PASS) RABBITMQ_MANAGEMENT_PORT=$(RABBITMQ_MANAGEMENT_PORT) docker compose $(PROJECT_NAME) exec $(OPTION_T) symfony bash
else
$(ERROR_ONLY_FOR_HOST)
endif
fish: ## Get fish shell inside symfony docker container
ifeq ($(INSIDE_DOCKER_CONTAINER), 0)
@HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) WEB_PORT_HTTP=$(WEB_PORT_HTTP) WEB_PORT_SSL=$(WEB_PORT_SSL) XDEBUG_CONFIG=$(XDEBUG_CONFIG) XDEBUG_VERSION=$(XDEBUG_VERSION) MYSQL_VERSION=$(MYSQL_VERSION) INNODB_USE_NATIVE_AIO=$(INNODB_USE_NATIVE_AIO) SQL_MODE=$(SQL_MODE) MYSQL_ROOT_PASSWORD=$(MYSQL_ROOT_PASSWORD) MYSQL_PORT=$(MYSQL_PORT) RABBITMQ_ERLANG_COOKIE=$(RABBITMQ_ERLANG_COOKIE) RABBITMQ_USER=$(RABBITMQ_USER) RABBITMQ_PASS=$(RABBITMQ_PASS) RABBITMQ_MANAGEMENT_PORT=$(RABBITMQ_MANAGEMENT_PORT) docker compose $(PROJECT_NAME) exec $(OPTION_T) $(PHP_USER) symfony fish
else
$(ERROR_ONLY_FOR_HOST)
endif
ssh-nginx: ## Get bash inside nginx docker container
ifeq ($(INSIDE_DOCKER_CONTAINER), 0)
@HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) WEB_PORT_HTTP=$(WEB_PORT_HTTP) WEB_PORT_SSL=$(WEB_PORT_SSL) XDEBUG_CONFIG=$(XDEBUG_CONFIG) XDEBUG_VERSION=$(XDEBUG_VERSION) MYSQL_VERSION=$(MYSQL_VERSION) INNODB_USE_NATIVE_AIO=$(INNODB_USE_NATIVE_AIO) SQL_MODE=$(SQL_MODE) MYSQL_ROOT_PASSWORD=$(MYSQL_ROOT_PASSWORD) MYSQL_PORT=$(MYSQL_PORT) RABBITMQ_ERLANG_COOKIE=$(RABBITMQ_ERLANG_COOKIE) RABBITMQ_USER=$(RABBITMQ_USER) RABBITMQ_PASS=$(RABBITMQ_PASS) RABBITMQ_MANAGEMENT_PORT=$(RABBITMQ_MANAGEMENT_PORT) docker compose $(PROJECT_NAME) exec nginx /bin/sh
else
$(ERROR_ONLY_FOR_HOST)
endif
ssh-supervisord: ## Get bash inside supervisord docker container (cron jobs running there, etc...)
ifeq ($(INSIDE_DOCKER_CONTAINER), 0)
@HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) WEB_PORT_HTTP=$(WEB_PORT_HTTP) WEB_PORT_SSL=$(WEB_PORT_SSL) XDEBUG_CONFIG=$(XDEBUG_CONFIG) XDEBUG_VERSION=$(XDEBUG_VERSION) MYSQL_VERSION=$(MYSQL_VERSION) INNODB_USE_NATIVE_AIO=$(INNODB_USE_NATIVE_AIO) SQL_MODE=$(SQL_MODE) MYSQL_ROOT_PASSWORD=$(MYSQL_ROOT_PASSWORD) MYSQL_PORT=$(MYSQL_PORT) RABBITMQ_ERLANG_COOKIE=$(RABBITMQ_ERLANG_COOKIE) RABBITMQ_USER=$(RABBITMQ_USER) RABBITMQ_PASS=$(RABBITMQ_PASS) RABBITMQ_MANAGEMENT_PORT=$(RABBITMQ_MANAGEMENT_PORT) docker compose $(PROJECT_NAME) exec supervisord bash
else
$(ERROR_ONLY_FOR_HOST)
endif
ssh-mysql: ## Get bash inside mysql docker container
ifeq ($(INSIDE_DOCKER_CONTAINER), 0)
@HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) WEB_PORT_HTTP=$(WEB_PORT_HTTP) WEB_PORT_SSL=$(WEB_PORT_SSL) XDEBUG_CONFIG=$(XDEBUG_CONFIG) XDEBUG_VERSION=$(XDEBUG_VERSION) MYSQL_VERSION=$(MYSQL_VERSION) INNODB_USE_NATIVE_AIO=$(INNODB_USE_NATIVE_AIO) SQL_MODE=$(SQL_MODE) MYSQL_ROOT_PASSWORD=$(MYSQL_ROOT_PASSWORD) MYSQL_PORT=$(MYSQL_PORT) RABBITMQ_ERLANG_COOKIE=$(RABBITMQ_ERLANG_COOKIE) RABBITMQ_USER=$(RABBITMQ_USER) RABBITMQ_PASS=$(RABBITMQ_PASS) RABBITMQ_MANAGEMENT_PORT=$(RABBITMQ_MANAGEMENT_PORT) docker compose $(PROJECT_NAME) exec mysql bash
else
$(ERROR_ONLY_FOR_HOST)
endif
ssh-rabbitmq: ## Get bash inside rabbitmq docker container
ifeq ($(INSIDE_DOCKER_CONTAINER), 0)
@HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) WEB_PORT_HTTP=$(WEB_PORT_HTTP) WEB_PORT_SSL=$(WEB_PORT_SSL) XDEBUG_CONFIG=$(XDEBUG_CONFIG) XDEBUG_VERSION=$(XDEBUG_VERSION) MYSQL_VERSION=$(MYSQL_VERSION) INNODB_USE_NATIVE_AIO=$(INNODB_USE_NATIVE_AIO) SQL_MODE=$(SQL_MODE) MYSQL_ROOT_PASSWORD=$(MYSQL_ROOT_PASSWORD) MYSQL_PORT=$(MYSQL_PORT) RABBITMQ_ERLANG_COOKIE=$(RABBITMQ_ERLANG_COOKIE) RABBITMQ_USER=$(RABBITMQ_USER) RABBITMQ_PASS=$(RABBITMQ_PASS) RABBITMQ_MANAGEMENT_PORT=$(RABBITMQ_MANAGEMENT_PORT) docker compose $(PROJECT_NAME) exec rabbitmq /bin/sh
else
$(ERROR_ONLY_FOR_HOST)
endif
exec:
ifeq ($(INSIDE_DOCKER_CONTAINER), 1)
@$$cmd
else
@HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) WEB_PORT_HTTP=$(WEB_PORT_HTTP) WEB_PORT_SSL=$(WEB_PORT_SSL) XDEBUG_CONFIG=$(XDEBUG_CONFIG) XDEBUG_VERSION=$(XDEBUG_VERSION) MYSQL_VERSION=$(MYSQL_VERSION) INNODB_USE_NATIVE_AIO=$(INNODB_USE_NATIVE_AIO) SQL_MODE=$(SQL_MODE) MYSQL_ROOT_PASSWORD=$(MYSQL_ROOT_PASSWORD) MYSQL_PORT=$(MYSQL_PORT) RABBITMQ_ERLANG_COOKIE=$(RABBITMQ_ERLANG_COOKIE) RABBITMQ_USER=$(RABBITMQ_USER) RABBITMQ_PASS=$(RABBITMQ_PASS) RABBITMQ_MANAGEMENT_PORT=$(RABBITMQ_MANAGEMENT_PORT) docker compose $(PROJECT_NAME) exec $(OPTION_T) $(PHP_USER) symfony $$cmd
endif
exec-bash:
ifeq ($(INSIDE_DOCKER_CONTAINER), 1)
@bash -c "$(cmd)"
else
@HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) WEB_PORT_HTTP=$(WEB_PORT_HTTP) WEB_PORT_SSL=$(WEB_PORT_SSL) XDEBUG_CONFIG=$(XDEBUG_CONFIG) XDEBUG_VERSION=$(XDEBUG_VERSION) MYSQL_VERSION=$(MYSQL_VERSION) INNODB_USE_NATIVE_AIO=$(INNODB_USE_NATIVE_AIO) SQL_MODE=$(SQL_MODE) MYSQL_ROOT_PASSWORD=$(MYSQL_ROOT_PASSWORD) MYSQL_PORT=$(MYSQL_PORT) RABBITMQ_ERLANG_COOKIE=$(RABBITMQ_ERLANG_COOKIE) RABBITMQ_USER=$(RABBITMQ_USER) RABBITMQ_PASS=$(RABBITMQ_PASS) RABBITMQ_MANAGEMENT_PORT=$(RABBITMQ_MANAGEMENT_PORT) docker compose $(PROJECT_NAME) exec $(OPTION_T) $(PHP_USER) symfony bash -c "$(cmd)"
endif
exec-by-root:
ifeq ($(INSIDE_DOCKER_CONTAINER), 0)
@HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) WEB_PORT_HTTP=$(WEB_PORT_HTTP) WEB_PORT_SSL=$(WEB_PORT_SSL) XDEBUG_CONFIG=$(XDEBUG_CONFIG) XDEBUG_VERSION=$(XDEBUG_VERSION) MYSQL_VERSION=$(MYSQL_VERSION) INNODB_USE_NATIVE_AIO=$(INNODB_USE_NATIVE_AIO) SQL_MODE=$(SQL_MODE) MYSQL_ROOT_PASSWORD=$(MYSQL_ROOT_PASSWORD) MYSQL_PORT=$(MYSQL_PORT) RABBITMQ_ERLANG_COOKIE=$(RABBITMQ_ERLANG_COOKIE) RABBITMQ_USER=$(RABBITMQ_USER) RABBITMQ_PASS=$(RABBITMQ_PASS) RABBITMQ_MANAGEMENT_PORT=$(RABBITMQ_MANAGEMENT_PORT) docker compose $(PROJECT_NAME) exec $(OPTION_T) symfony $$cmd
else
$(ERROR_ONLY_FOR_HOST)
endif
report-prepare:
@make exec cmd="mkdir -p reports/coverage"
report-clean:
@make exec-by-root cmd="rm -rf reports/*"
wait-for-db:
@make exec cmd="php bin/console db:wait"
composer-install-no-dev: ## Installs composer no-dev dependencies
@make exec-bash cmd="COMPOSER_MEMORY_LIMIT=-1 composer install --optimize-autoloader --no-dev"
composer-install: ## Installs composer dependencies
@make exec-bash cmd="COMPOSER_MEMORY_LIMIT=-1 composer install --optimize-autoloader"
composer-update: ## Updates composer dependencies
@make exec-bash cmd="COMPOSER_MEMORY_LIMIT=-1 composer update"
info: ## Shows Php and Symfony version
@make exec cmd="php --version"
@make exec cmd="bin/console about"
@make exec cmd="composer --version"
logs: ## Shows logs from the symfony container. Use ctrl+c in order to exit
ifeq ($(INSIDE_DOCKER_CONTAINER), 0)
@docker logs -f ${COMPOSE_PROJECT_NAME}-symfony
else
$(ERROR_ONLY_FOR_HOST)
endif
logs-nginx: ## Shows logs from the nginx container. Use ctrl+c in order to exit
ifeq ($(INSIDE_DOCKER_CONTAINER), 0)
@docker logs -f ${COMPOSE_PROJECT_NAME}-nginx
else
$(ERROR_ONLY_FOR_HOST)
endif
logs-supervisord: ## Shows logs from the supervisord container. Use ctrl+c in order to exit
ifeq ($(INSIDE_DOCKER_CONTAINER), 0)
@docker logs -f ${COMPOSE_PROJECT_NAME}-supervisord
else
$(ERROR_ONLY_FOR_HOST)
endif
logs-mysql: ## Shows logs from the mysql container. Use ctrl+c in order to exit
ifeq ($(INSIDE_DOCKER_CONTAINER), 0)
@docker logs -f ${COMPOSE_PROJECT_NAME}-mysql
else
$(ERROR_ONLY_FOR_HOST)
endif
logs-rabbitmq: ## Shows logs from the rabbitmq container. Use ctrl+c in order to exit
ifeq ($(INSIDE_DOCKER_CONTAINER), 0)
@docker logs -f ${COMPOSE_PROJECT_NAME}-rabbitmq
else
$(ERROR_ONLY_FOR_HOST)
endif
drop-migrate: ## Drops databases and runs all migrations for the main/test databases
@make exec cmd="php bin/console doctrine:schema:drop --full-database --force"
@make exec cmd="php bin/console doctrine:schema:drop --full-database --force --env=test"
@make migrate
migrate-no-test: ## Runs all migrations for main database
@make exec cmd="php bin/console doctrine:migrations:migrate --no-interaction"
migrate: ## Runs all migrations for main/test databases
@make exec cmd="php bin/console doctrine:migrations:migrate --no-interaction"
@make exec cmd="php bin/console doctrine:migrations:migrate --no-interaction --env=test"
fixtures: ## Runs all fixtures for test database without --append option (tables will be dropped and recreated)
@make exec cmd="php bin/console doctrine:fixtures:load --env=test"
messenger-setup-transports: ## Initializes transports for Symfony Messenger bundle
@make exec cmd="php bin/console messenger:setup-transports"
phpunit: ## Runs PhpUnit tests
@make exec-bash cmd="rm -rf ./var/cache/test* && bin/console cache:warmup --env=test && ./vendor/bin/phpunit -c phpunit.xml.dist --coverage-html reports/coverage $(PHPUNIT_OPTIONS) --coverage-clover reports/clover.xml --log-junit reports/junit.xml"
report-code-coverage: ## Updates code coverage on coveralls.io. Note: COVERALLS_REPO_TOKEN should be set on CI side.
@make exec-bash cmd="export COVERALLS_REPO_TOKEN=${COVERALLS_REPO_TOKEN} && php ./vendor/bin/php-coveralls -v --coverage_clover reports/clover.xml --json_path reports/coverals.json"
phpcs: ## Runs PHP CodeSniffer
@make exec-bash cmd="./vendor/bin/phpcs --version && ./vendor/bin/phpcs --standard=PSR12 --colors -p src tests"
ecs: ## Runs Easy Coding Standard tool
@make exec-bash cmd="./vendor/bin/ecs --version && ./vendor/bin/ecs --clear-cache check src tests"
ecs-fix: ## Runs Easy Coding Standard tool to fix issues
@make exec-bash cmd="./vendor/bin/ecs --version && ./vendor/bin/ecs --clear-cache --fix check src tests"
phpmetrics: ## Generates phpmetrics static analysis report
ifeq ($(INSIDE_DOCKER_CONTAINER), 1)
@mkdir -p reports/phpmetrics
@if [ ! -f reports/junit.xml ] ; then \
printf "\033[32;49mjunit.xml not found, running tests...\033[39m\n" ; \
./vendor/bin/phpunit -c phpunit.xml.dist --coverage-html reports/coverage --coverage-clover reports/clover.xml --log-junit reports/junit.xml ; \
fi;
@echo "\033[32mRunning PhpMetrics\033[39m"
@php ./vendor/bin/phpmetrics --version
@php ./vendor/bin/phpmetrics --junit=reports/junit.xml --report-html=reports/phpmetrics .
else
@make exec-by-root cmd="make phpmetrics"
endif
phpcpd: ## Runs php copy/paste detector
@make exec cmd="php phpcpd.phar --fuzzy src tests"
phpmd: ## Runs php mess detector
@make exec cmd="php ./vendor/bin/phpmd src,tests text phpmd_ruleset.xml --suffixes php"
phpstan: ## Runs PhpStan static analysis tool
ifeq ($(INSIDE_DOCKER_CONTAINER), 1)
@echo "\033[32mRunning PHPStan - PHP Static Analysis Tool\033[39m"
@bin/console cache:clear --env=test
@./vendor/bin/phpstan --version
@./vendor/bin/phpstan analyze src tests
else
@make exec cmd="make phpstan"
endif
phpinsights: ## Runs Php Insights analysis tool
ifeq ($(INSIDE_DOCKER_CONTAINER), 1)
@echo "\033[32mRunning PHP Insights\033[39m"
@php -d error_reporting=0 ./vendor/bin/phpinsights analyse --no-interaction --min-quality=100 --min-complexity=84 --min-architecture=100 --min-style=100
else
@make exec cmd="make phpinsights"
endif
composer-normalize: ## Normalizes composer.json file content
@make exec cmd="composer normalize"
composer-validate: ## Validates composer.json file content
@make exec cmd="composer validate --no-check-version"
composer-require-checker: ## Checks the defined dependencies against your code
@make exec-bash cmd="XDEBUG_MODE=off php ./vendor/bin/composer-require-checker"
composer-unused: ## Shows unused packages by scanning and comparing package namespaces against your code
@make exec-bash cmd="XDEBUG_MODE=off php ./vendor/bin/composer-unused"