3
3
CLI_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS ) ) ,$(MAKECMDGOALS ) )
4
4
$(eval $(CLI_ARGS ) :;@:)
5
5
6
+ PRIMARY_GOAL := $(firstword $(MAKECMDGOALS ) )
7
+
6
8
include docker/.env
7
9
8
10
# Current user ID and group ID except MacOS where it conflicts with Docker abilities
@@ -22,70 +24,106 @@ DOCKER_COMPOSE_TEST := docker compose -f docker/compose.yml -f docker/test/compo
22
24
# Development
23
25
#
24
26
27
+ ifeq ($(PRIMARY_GOAL ) ,build)
25
28
build : # # Build docker images
26
29
$(DOCKER_COMPOSE_DEV ) build $(CLI_ARGS )
30
+ endif
27
31
32
+ ifeq ($(PRIMARY_GOAL ) ,up)
28
33
up : # # Up the dev environment
29
34
$(DOCKER_COMPOSE_DEV ) up -d --remove-orphans
35
+ endif
30
36
37
+ ifeq ($(PRIMARY_GOAL ) ,down)
31
38
down : # # Down the dev environment
32
39
$(DOCKER_COMPOSE_DEV ) down --remove-orphans
40
+ endif
33
41
42
+ ifeq ($(PRIMARY_GOAL ) ,clear)
34
43
clear : # # Remove development docker containers and volumes
35
44
$(DOCKER_COMPOSE_DEV ) down --volumes --remove-orphans
45
+ endif
36
46
47
+ ifeq ($(PRIMARY_GOAL ) ,shell)
37
48
shell : # # Get into container shell
38
49
$(DOCKER_COMPOSE_DEV ) exec app /bin/bash
50
+ endif
39
51
52
+ ifeq ($(PRIMARY_GOAL ) ,yii)
40
53
yii : # # Execute Yii command
41
54
$(DOCKER_COMPOSE_DEV ) run --rm app ./yii $(CLI_ARGS )
42
55
.PHONY : yii
56
+ endif
43
57
58
+ ifeq ($(PRIMARY_GOAL ) ,composer)
44
59
composer : # # Run Composer
45
60
$(DOCKER_COMPOSE_DEV ) run --rm app composer $(CLI_ARGS )
61
+ endif
46
62
63
+ ifeq ($(PRIMARY_GOAL ) ,rector)
47
64
rector : # # Run Rector
48
65
$(DOCKER_COMPOSE_DEV ) run --rm app ./vendor/bin/rector $(CLI_ARGS )
66
+ endif
49
67
68
+ ifeq ($(PRIMARY_GOAL ) ,cs-fix)
50
69
cs-fix : # # Run PHP CS Fixer
51
70
$(DOCKER_COMPOSE_DEV ) run --rm app ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --diff
71
+ endif
52
72
53
73
#
54
74
# Tests and analysis
55
75
#
56
76
77
+ ifeq ($(PRIMARY_GOAL ) ,test)
57
78
test :
58
79
$(DOCKER_COMPOSE_TEST ) run --rm app ./vendor/bin/codecept run $(CLI_ARGS )
80
+ endif
59
81
82
+ ifeq ($(PRIMARY_GOAL ) ,test-coverage)
60
83
test-coverage :
61
84
$(DOCKER_COMPOSE_TEST ) run --rm app ./vendor/bin/codecept run --coverage --coverage-html --disable-coverage-php
85
+ endif
62
86
87
+ ifeq ($(PRIMARY_GOAL ) ,codecept)
63
88
codecept : # # Run Codeception
64
89
$(DOCKER_COMPOSE_TEST ) run --rm app ./vendor/bin/codecept $(CLI_ARGS )
90
+ endif
65
91
92
+ ifeq ($(PRIMARY_GOAL ) ,psalm)
66
93
psalm : # # Run Psalm
67
94
$(DOCKER_COMPOSE_DEV ) run --rm app ./vendor/bin/psalm $(CLI_ARGS )
95
+ endif
68
96
97
+ ifeq ($(PRIMARY_GOAL ) ,composer-dependency-analyser)
69
98
composer-dependency-analyser : # # Run Composer Dependency Analyser
70
99
$(DOCKER_COMPOSE_DEV ) run --rm app ./vendor/bin/composer-dependency-analyser --config=composer-dependency-analyser.php $(CLI_ARGS )
100
+ endif
71
101
72
102
#
73
103
# Production
74
104
#
75
105
106
+ ifeq ($(PRIMARY_GOAL ) ,prod-build)
76
107
prod-build : # # PROD | Build an image
77
108
docker build --file docker/Dockerfile --target prod --pull -t ${IMAGE} :${IMAGE_TAG} .
109
+ endif
78
110
111
+ ifeq ($(PRIMARY_GOAL ) ,prod-push)
79
112
prod-push : # # PROD | Push image to repository
80
113
docker push ${IMAGE} :${IMAGE_TAG}
114
+ endif
81
115
116
+ ifeq ($(PRIMARY_GOAL ) ,prod-deploy)
82
117
prod-deploy : # # PROD | Deploy to production
83
118
docker -H ${PROD_SSH} stack deploy --with-registry-auth -d -c docker/compose.yml -c docker/prod/compose.yml ${STACK_NAME}
119
+ endif
84
120
85
121
#
86
122
# Other
87
123
#
88
124
125
+ ifeq ($(PRIMARY_GOAL ) ,help)
89
126
# Output the help for each task, see https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
90
127
help : # # This help.
91
128
@awk ' BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST )
129
+ endif
0 commit comments