1
- dir =${CURDIR}
2
-
3
1
ifndef APP_ENV
4
2
include .env
5
3
# Determine if .env.local file exist
6
- ifneq ("$(wildcard .env.local)","")
4
+ ifneq ("$(wildcard .env.local)", "")
7
5
include .env.local
8
6
endif
9
7
endif
10
8
11
- symfony_user =-u www-data
12
- project =-p ${COMPOSE_PROJECT_NAME}
13
- service =${COMPOSE_PROJECT_NAME}:latest
14
- openssl_bin: =$(shell which openssl)
15
- interactive: =$(shell [ -t 0 ] && echo 1)
16
- ifneq ($(interactive ) ,1)
17
- optionT=-T
9
+ ifndef INSIDE_DOCKER_CONTAINER
10
+ INSIDE_DOCKER_CONTAINER = 0
11
+ endif
12
+
13
+ HOST_UID := $(shell id -u)
14
+ HOST_GID := $(shell id -g)
15
+ PHP_USER := -u www-data
16
+ PROJECT_NAME := -p ${COMPOSE_PROJECT_NAME}
17
+ OPENSSL_BIN := $(shell which openssl)
18
+ INTERACTIVE := $(shell [ -t 0 ] && echo 1)
19
+ ERROR_ONLY_FOR_HOST = @printf "\033[33mThis command for host machine\033[39m\n"
20
+ ifneq ($(INTERACTIVE ) , 1)
21
+ OPTION_T := -T
18
22
endif
19
- ifeq ($(GITLAB_CI ) ,1)
23
+ ifeq ($(GITLAB_CI ) , 1)
20
24
# Determine additional params for phpunit in order to generate coverage badge on GitLabCI side
21
- phpunitOptions= --coverage-text --colors=never
25
+ PHPUNIT_OPTIONS := --coverage-text --colors=never
22
26
endif
23
27
24
28
build :
25
- @docker-compose -f docker-compose.yml build
29
+ ifeq ($(INSIDE_DOCKER_CONTAINER ) , 0)
30
+ @HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) docker-compose -f docker-compose.yml build
31
+ else
32
+ $(ERROR_ONLY_FOR_HOST)
33
+ endif
26
34
27
35
build-test :
28
- @docker-compose -f docker-compose-test-ci.yml build
36
+ ifeq ($(INSIDE_DOCKER_CONTAINER ) , 0)
37
+ @HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) docker-compose -f docker-compose-test-ci.yml build
38
+ else
39
+ $(ERROR_ONLY_FOR_HOST)
40
+ endif
29
41
30
42
build-staging :
31
- @docker-compose -f docker-compose-staging.yml build
43
+ ifeq ($(INSIDE_DOCKER_CONTAINER ) , 0)
44
+ @HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) docker-compose -f docker-compose-staging.yml build
45
+ else
46
+ $(ERROR_ONLY_FOR_HOST)
47
+ endif
32
48
33
49
build-prod :
34
- @docker-compose -f docker-compose-prod.yml build
50
+ ifeq ($(INSIDE_DOCKER_CONTAINER ) , 0)
51
+ @HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) docker-compose -f docker-compose-prod.yml build
52
+ else
53
+ $(ERROR_ONLY_FOR_HOST)
54
+ endif
35
55
36
56
start :
37
- @docker-compose -f docker-compose.yml $(project ) up -d
57
+ ifeq ($(INSIDE_DOCKER_CONTAINER ) , 0)
58
+ @HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) docker-compose -f docker-compose.yml $(PROJECT_NAME) up -d
59
+ else
60
+ $(ERROR_ONLY_FOR_HOST)
61
+ endif
38
62
39
63
start-test :
40
- @docker-compose -f docker-compose-test-ci.yml $(project ) up -d
64
+ ifeq ($(INSIDE_DOCKER_CONTAINER ) , 0)
65
+ @HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) docker-compose -f docker-compose-test-ci.yml $(PROJECT_NAME) up -d
66
+ else
67
+ $(ERROR_ONLY_FOR_HOST)
68
+ endif
41
69
42
70
start-staging :
43
- @docker-compose -f docker-compose-staging.yml $(project ) up -d
71
+ ifeq ($(INSIDE_DOCKER_CONTAINER ) , 0)
72
+ @HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) docker-compose -f docker-compose-staging.yml $(PROJECT_NAME) up -d
73
+ else
74
+ $(ERROR_ONLY_FOR_HOST)
75
+ endif
44
76
45
77
start-prod :
46
- @docker-compose -f docker-compose-prod.yml $(project ) up -d
78
+ ifeq ($(INSIDE_DOCKER_CONTAINER ) , 0)
79
+ @HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) docker-compose -f docker-compose-prod.yml $(PROJECT_NAME) up -d
80
+ else
81
+ $(ERROR_ONLY_FOR_HOST)
82
+ endif
47
83
48
84
stop :
49
- @docker-compose -f docker-compose.yml $(project ) down
85
+ ifeq ($(INSIDE_DOCKER_CONTAINER ) , 0)
86
+ @HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) docker-compose -f docker-compose.yml $(PROJECT_NAME) down
87
+ else
88
+ $(ERROR_ONLY_FOR_HOST)
89
+ endif
50
90
51
91
stop-test :
52
- @docker-compose -f docker-compose-test-ci.yml $(project ) down
92
+ ifeq ($(INSIDE_DOCKER_CONTAINER ) , 0)
93
+ @HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) docker-compose -f docker-compose-test-ci.yml $(PROJECT_NAME) down
94
+ else
95
+ $(ERROR_ONLY_FOR_HOST)
96
+ endif
53
97
54
98
stop-staging :
55
- @docker-compose -f docker-compose-staging.yml $(project ) down
99
+ ifeq ($(INSIDE_DOCKER_CONTAINER ) , 0)
100
+ @HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) docker-compose -f docker-compose-staging.yml $(PROJECT_NAME) down
101
+ else
102
+ $(ERROR_ONLY_FOR_HOST)
103
+ endif
56
104
57
105
stop-prod :
58
- @docker-compose -f docker-compose-prod.yml $(project ) down
106
+ ifeq ($(INSIDE_DOCKER_CONTAINER ) , 0)
107
+ @HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) docker-compose -f docker-compose-prod.yml $(PROJECT_NAME) down
108
+ else
109
+ $(ERROR_ONLY_FOR_HOST)
110
+ endif
59
111
60
112
restart : stop start
61
113
restart-test : stop-test start-test
@@ -69,34 +121,73 @@ env-staging:
69
121
@make exec cmd=" composer dump-env staging"
70
122
71
123
ssh :
72
- @docker-compose $(project ) exec $(optionT ) $(symfony_user ) symfony bash
124
+ ifeq ($(INSIDE_DOCKER_CONTAINER ) , 0)
125
+ @HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) docker-compose $(PROJECT_NAME) exec $(OPTION_T) $(PHP_USER) symfony bash
126
+ else
127
+ $(ERROR_ONLY_FOR_HOST)
128
+ endif
129
+
130
+ ssh-root :
131
+ ifeq ($(INSIDE_DOCKER_CONTAINER ) , 0)
132
+ @HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) docker-compose $(PROJECT_NAME) exec $(OPTION_T) symfony bash
133
+ else
134
+ $(ERROR_ONLY_FOR_HOST)
135
+ endif
73
136
74
137
ssh-nginx :
75
- @docker-compose $(project ) exec nginx /bin/sh
138
+ ifeq ($(INSIDE_DOCKER_CONTAINER ) , 0)
139
+ @HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) docker-compose $(PROJECT_NAME) exec nginx /bin/sh
140
+ else
141
+ $(ERROR_ONLY_FOR_HOST)
142
+ endif
76
143
77
144
ssh-supervisord :
78
- @docker-compose $(project ) exec supervisord bash
145
+ ifeq ($(INSIDE_DOCKER_CONTAINER ) , 0)
146
+ @HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) docker-compose $(PROJECT_NAME) exec supervisord bash
147
+ else
148
+ $(ERROR_ONLY_FOR_HOST)
149
+ endif
79
150
80
151
ssh-mysql :
81
- @docker-compose $(project ) exec mysql bash
152
+ ifeq ($(INSIDE_DOCKER_CONTAINER ) , 0)
153
+ @HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) docker-compose $(PROJECT_NAME) exec mysql bash
154
+ else
155
+ $(ERROR_ONLY_FOR_HOST)
156
+ endif
82
157
83
158
ssh-rabbitmq :
84
- @docker-compose $(project ) exec rabbitmq /bin/sh
159
+ ifeq ($(INSIDE_DOCKER_CONTAINER ) , 0)
160
+ @HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) docker-compose $(PROJECT_NAME) exec rabbitmq /bin/sh
161
+ else
162
+ $(ERROR_ONLY_FOR_HOST)
163
+ endif
85
164
86
165
exec :
87
- @docker-compose $(project ) exec $(optionT ) $(symfony_user ) symfony $$ cmd
166
+ ifeq ($(INSIDE_DOCKER_CONTAINER ) , 1)
167
+ @$$cmd
168
+ else
169
+ @HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) docker-compose $(PROJECT_NAME) exec $(OPTION_T) $(PHP_USER) symfony $$cmd
170
+ endif
88
171
89
172
exec-bash :
90
- @docker-compose $(project ) exec $(optionT ) $(symfony_user ) symfony bash -c " $( cmd) "
173
+ ifeq ($(INSIDE_DOCKER_CONTAINER ) , 1)
174
+ @bash -c "$(cmd)"
175
+ else
176
+ @HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) docker-compose $(PROJECT_NAME) exec $(OPTION_T) $(PHP_USER) symfony bash -c "$(cmd)"
177
+ endif
91
178
92
179
exec-by-root :
93
- @docker-compose $(project ) exec $(optionT ) symfony $$ cmd
180
+ ifeq ($(INSIDE_DOCKER_CONTAINER ) , 0)
181
+ @HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) docker-compose $(PROJECT_NAME) exec $(OPTION_T) symfony $$cmd
182
+ else
183
+ $(ERROR_ONLY_FOR_HOST)
184
+ endif
94
185
95
186
report-prepare :
96
- mkdir -p $( dir ) / reports/coverage
187
+ @make exec cmd= " mkdir -p reports/coverage"
97
188
98
189
report-clean :
99
- rm -rf $( dir ) / reports/*
190
+ @make exec-by-root cmd= " rm -rf reports/*"
100
191
101
192
wait-for-db :
102
193
@make exec cmd=" php bin/console db:wait"
@@ -115,19 +206,39 @@ info:
115
206
@make exec cmd=" bin/console about"
116
207
117
208
logs :
209
+ ifeq ($(INSIDE_DOCKER_CONTAINER ) , 0)
118
210
@docker logs -f ${COMPOSE_PROJECT_NAME}_symfony
211
+ else
212
+ $(ERROR_ONLY_FOR_HOST)
213
+ endif
119
214
120
215
logs-nginx :
216
+ ifeq ($(INSIDE_DOCKER_CONTAINER ) , 0)
121
217
@docker logs -f ${COMPOSE_PROJECT_NAME}_nginx
218
+ else
219
+ $(ERROR_ONLY_FOR_HOST)
220
+ endif
122
221
123
222
logs-supervisord :
223
+ ifeq ($(INSIDE_DOCKER_CONTAINER ) , 0)
124
224
@docker logs -f ${COMPOSE_PROJECT_NAME}_supervisord
225
+ else
226
+ $(ERROR_ONLY_FOR_HOST)
227
+ endif
125
228
126
229
logs-mysql :
230
+ ifeq ($(INSIDE_DOCKER_CONTAINER ) , 0)
127
231
@docker logs -f ${COMPOSE_PROJECT_NAME}_mysql
232
+ else
233
+ $(ERROR_ONLY_FOR_HOST)
234
+ endif
128
235
129
236
logs-rabbitmq :
237
+ ifeq ($(INSIDE_DOCKER_CONTAINER ) , 0)
130
238
@docker logs -f ${COMPOSE_PROJECT_NAME}_rabbitmq
239
+ else
240
+ $(ERROR_ONLY_FOR_HOST)
241
+ endif
131
242
132
243
drop-migrate :
133
244
@make exec cmd=" php bin/console doctrine:schema:drop --full-database --force"
@@ -148,31 +259,22 @@ messenger-setup-transports:
148
259
@make exec cmd=" php bin/console messenger:setup-transports"
149
260
150
261
phpunit :
151
- @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 $( phpunitOptions ) --coverage-clover reports/clover.xml --log-junit reports/junit.xml"
262
+ @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"
152
263
153
- # ##> php-coveralls ###
154
264
report-code-coverage : # # update code coverage on coveralls.io. Note: COVERALLS_REPO_TOKEN should be set on CI side.
155
265
@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"
156
- # ##< php-coveralls ###
157
266
158
- # ##> phpcs ###
159
- phpcs : # # Run PHP CodeSniffer
267
+ phpcs : # # Runs PHP CodeSniffer
160
268
@make exec-bash cmd=" ./vendor/bin/phpcs --version && ./vendor/bin/phpcs --standard=PSR12 --colors -p src tests"
161
- # ##< phpcs ###
162
269
163
- # ##> ecs ###
164
- ecs : # # Run Easy Coding Standard
270
+ ecs : # # Runs Easy Coding Standard
165
271
@make exec-bash cmd=" ./vendor/bin/ecs --version && ./vendor/bin/ecs --clear-cache check src tests"
166
272
167
273
ecs-fix : # # Run The Easy Coding Standard to fix issues
168
274
@make exec-bash cmd=" ./vendor/bin/ecs --version && ./vendor/bin/ecs --clear-cache --fix check src tests"
169
- # ##< ecs ###
170
275
171
- # ##> phpmetrics ###
172
- phpmetrics :
173
- @make exec-by-root cmd=" make phpmetrics-process"
174
-
175
- phpmetrics-process : # # Generates PhpMetrics static analysis, should be run inside symfony container
276
+ phpmetrics : # # Runs phpmetrics
277
+ ifeq ($(INSIDE_DOCKER_CONTAINER ) , 1)
176
278
@mkdir -p reports/phpmetrics
177
279
@if [ ! -f reports/junit.xml ] ; then \
178
280
printf "\033[32;49mjunit.xml not found, running tests...\033[39m\n" ; \
@@ -181,28 +283,30 @@ phpmetrics-process: ## Generates PhpMetrics static analysis, should be run insid
181
283
@echo "\033[32mRunning PhpMetrics\033[39m"
182
284
@php ./vendor/bin/phpmetrics --version
183
285
@php ./vendor/bin/phpmetrics --junit=reports/junit.xml --report-html=reports/phpmetrics .
184
- # ##< phpmetrics ###
286
+ else
287
+ @make exec-by-root cmd="make phpmetrics"
288
+ endif
185
289
186
- # ##> php copy/paste detector ###
187
- phpcpd :
290
+ phpcpd : # # Runs php copy/paste detector
188
291
@make exec cmd=" php phpcpd.phar --fuzzy src tests"
189
- # ##< php copy/paste detector ###
190
292
191
- # ##> php mess detector ###
192
- phpmd :
293
+ phpmd : # # Runs php mess detector
193
294
@make exec cmd=" php ./vendor/bin/phpmd src text phpmd_ruleset.xml --suffixes php"
194
- # ##< php mess detector ###
195
295
196
- # ##> PHPStan static analysis tool ###
197
- phpstan :
296
+ phpstan : # # Runs PHPStan static analysis tool
297
+ ifeq ( $( INSIDE_DOCKER_CONTAINER ) , 1)
198
298
@echo "\033[32mRunning PHPStan - PHP Static Analysis Tool\033[39m"
199
- @make exec cmd=" bin/console cache:clear --env=test"
200
- @make exec cmd=" ./vendor/bin/phpstan --version"
201
- @make exec cmd=" ./vendor/bin/phpstan analyze src tests"
202
- # ##< PHPStan static analysis tool ###
299
+ @bin/console cache:clear --env=test
300
+ @./vendor/bin/phpstan --version
301
+ @./vendor/bin/phpstan analyze src tests
302
+ else
303
+ @make exec cmd="make phpstan"
304
+ endif
203
305
204
- # ##> Phpinsights PHP quality checks ###
205
- phpinsights :
306
+ phpinsights : # # Runs Php Insights PHP quality checks
307
+ ifeq ( $( INSIDE_DOCKER_CONTAINER ) , 1)
206
308
@echo "\033[32mRunning PHP Insights\033[39m"
207
- @make exec cmd=" php -d error_reporting=0 ./vendor/bin/phpinsights analyse --no-interaction --min-quality=100 --min-complexity=85 --min-architecture=100 --min-style=100"
208
- # ##< Phpinsights PHP quality checks ###
309
+ @php -d error_reporting=0 ./vendor/bin/phpinsights analyse --no-interaction --min-quality=100 --min-complexity=84 --min-architecture=100 --min-style=100
310
+ else
311
+ @make exec cmd="make phpinsights"
312
+ endif
0 commit comments