@@ -26,53 +26,57 @@ DOCKER_COMPOSE_TEST := docker compose -f docker/compose.yml -f docker/test/compo
2626#
2727
2828ifeq ($(PRIMARY_GOAL ) ,build)
29- build : # # Build docker images
29+ build : # # Build docker images.
3030 $(DOCKER_COMPOSE_DEV ) build $(CLI_ARGS )
3131endif
3232
3333ifeq ($(PRIMARY_GOAL ) ,up)
34- up : # # Up the dev environment
34+ up : # # Up the dev environment.
3535 $(DOCKER_COMPOSE_DEV ) up -d --remove-orphans
3636endif
3737
3838ifeq ($(PRIMARY_GOAL ) ,down)
39- down : # # Down the dev environment
39+ down : # # Down the dev environment.
4040 $(DOCKER_COMPOSE_DEV ) down --remove-orphans
4141endif
4242
4343ifeq ($(PRIMARY_GOAL ) ,stop)
44- stop : # # Stop the dev environment
44+ stop : # # Stop the dev environment.
4545 $(DOCKER_COMPOSE_DEV ) stop
4646endif
4747
4848ifeq ($(PRIMARY_GOAL ) ,clear)
49- clear : # # Remove development docker containers and volumes
49+ clear : # # Remove development docker containers and volumes.
5050 $(DOCKER_COMPOSE_DEV ) down --volumes --remove-orphans
5151endif
5252
5353ifeq ($(PRIMARY_GOAL ) ,shell)
54- shell : # # Get into container shell
54+ shell : # # Get into container shell.
5555 $(DOCKER_COMPOSE_DEV ) exec app /bin/bash
5656endif
5757
58+ #
59+ # Tools
60+ #
61+
5862ifeq ($(PRIMARY_GOAL ) ,yii)
59- yii : # # Execute Yii command
63+ yii : # # Execute Yii command.
6064 $(DOCKER_COMPOSE_DEV ) run --rm app ./yii $(CLI_ARGS )
6165.PHONY : yii
6266endif
6367
6468ifeq ($(PRIMARY_GOAL ) ,composer)
65- composer : # # Run Composer
69+ composer : # # Run Composer.
6670 $(DOCKER_COMPOSE_DEV ) run --rm app composer $(CLI_ARGS )
6771endif
6872
6973ifeq ($(PRIMARY_GOAL ) ,rector)
70- rector : # # Run Rector
74+ rector : # # Run Rector.
7175 $(DOCKER_COMPOSE_DEV ) run --rm app ./vendor/bin/rector $(CLI_ARGS )
7276endif
7377
7478ifeq ($(PRIMARY_GOAL ) ,cs-fix)
75- cs-fix : # # Run PHP CS Fixer
79+ cs-fix : # # Run PHP CS Fixer.
7680 $(DOCKER_COMPOSE_DEV ) run --rm app ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --diff
7781endif
7882
@@ -81,27 +85,27 @@ endif
8185#
8286
8387ifeq ($(PRIMARY_GOAL ) ,test)
84- test :
88+ test : # # Run tests.
8589 $(DOCKER_COMPOSE_TEST ) run --rm app ./vendor/bin/codecept run $(CLI_ARGS )
8690endif
8791
8892ifeq ($(PRIMARY_GOAL ) ,test-coverage)
89- test-coverage :
93+ test-coverage : # # Run tests with coverage.
9094 $(DOCKER_COMPOSE_TEST ) run --rm app ./vendor/bin/codecept run --coverage --coverage-html --disable-coverage-php
9195endif
9296
9397ifeq ($(PRIMARY_GOAL ) ,codecept)
94- codecept : # # Run Codeception
98+ codecept : # # Run Codeception.
9599 $(DOCKER_COMPOSE_TEST ) run --rm app ./vendor/bin/codecept $(CLI_ARGS )
96100endif
97101
98102ifeq ($(PRIMARY_GOAL ) ,psalm)
99- psalm : # # Run Psalm
103+ psalm : # # Run Psalm.
100104 $(DOCKER_COMPOSE_DEV ) run --rm app ./vendor/bin/psalm $(CLI_ARGS )
101105endif
102106
103107ifeq ($(PRIMARY_GOAL ) ,composer-dependency-analyser)
104- composer-dependency-analyser : # # Run Composer Dependency Analyser
108+ composer-dependency-analyser : # # Run Composer Dependency Analyser.
105109 $(DOCKER_COMPOSE_DEV ) run --rm app ./vendor/bin/composer-dependency-analyser --config=composer-dependency-analyser.php $(CLI_ARGS )
106110endif
107111
@@ -110,17 +114,17 @@ endif
110114#
111115
112116ifeq ($(PRIMARY_GOAL ) ,prod-build)
113- prod-build : # # PROD | Build an image
117+ prod-build : # # Build an image.
114118 docker build --file docker/Dockerfile --target prod --pull -t ${IMAGE} :${IMAGE_TAG} .
115119endif
116120
117121ifeq ($(PRIMARY_GOAL ) ,prod-push)
118- prod-push : # # PROD | Push image to repository
122+ prod-push : # # Push image to repository.
119123 docker push ${IMAGE} :${IMAGE_TAG}
120124endif
121125
122126ifeq ($(PRIMARY_GOAL ) ,prod-deploy)
123- prod-deploy : # # PROD | Deploy to production
127+ prod-deploy : # # Deploy to production.
124128 set -euo pipefail \
125129 docker -H ${PROD_SSH} stack deploy --prune --detach=false --with-registry-auth -c docker/compose.yml -c docker/prod/compose.yml ${STACK_NAME} 2>&1 | tee deploy.log \
126130 if grep -qiE ' rollback:|update rolled back' deploy.log then \
@@ -141,7 +145,16 @@ endif
141145#
142146
143147ifeq ($(PRIMARY_GOAL ) ,help)
144- # Output the help for each task, see https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
145148help : # # This help.
146- @awk ' BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST )
149+ @awk ' BEGIN { printf "\nUsage:\n make \033[36m<target>\033[0m\n" } \
150+ /^# $$/ { blank = 1; next } \
151+ blank && /^# [a-zA-Z]/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 3); blank = 0; next } \
152+ /^[a-zA-Z_-]+:([^= ]| $$ )/ { \
153+ split($$ 0, parts, " ##" ); \
154+ target = parts[1]; sub(/:.* /, " " , target); \
155+ desc = parts[2]; \
156+ gsub(/^[[:space:]]+| [[:space:]]+$$ /, " " , desc); \
157+ printf " \033[36m%-25s\033[0m %s\n" , target, desc; \
158+ blank = 0; \
159+ }' $(MAKEFILE_LIST)
147160endif
0 commit comments