forked from yiisoft/app
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
136 lines (109 loc) · 3.5 KB
/
Makefile
File metadata and controls
136 lines (109 loc) · 3.5 KB
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
CLI_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
$(eval $(sort $(subst :,\:,$(CLI_ARGS))):;@:)
ifeq ($(MAKECMDGOALS),)
PRIMARY_GOAL := help
else
PRIMARY_GOAL := $(firstword $(MAKECMDGOALS))
endif
include docker/.env
# Current user ID and group ID except MacOS where it conflicts with Docker abilities
ifeq ($(shell uname), Darwin)
export UID=1000
export GID=1000
else
export UID=$(shell id -u)
export GID=$(shell id -g)
endif
export COMPOSE_PROJECT_NAME=${STACK_NAME}
DOCKER_COMPOSE_DEV := docker compose -f docker/compose.yml -f docker/dev/compose.yml
DOCKER_COMPOSE_TEST := docker compose -f docker/compose.yml -f docker/test/compose.yml
#
# Development
#
ifeq ($(PRIMARY_GOAL),build)
build: ## Build docker images
$(DOCKER_COMPOSE_DEV) build $(CLI_ARGS)
endif
ifeq ($(PRIMARY_GOAL),up)
up: ## Up the dev environment
$(DOCKER_COMPOSE_DEV) up -d --remove-orphans
endif
ifeq ($(PRIMARY_GOAL),down)
down: ## Down the dev environment
$(DOCKER_COMPOSE_DEV) down --remove-orphans
endif
ifeq ($(PRIMARY_GOAL),stop)
stop: ## Stop the dev environment
$(DOCKER_COMPOSE_DEV) stop
endif
ifeq ($(PRIMARY_GOAL),clear)
clear: ## Remove development docker containers and volumes
$(DOCKER_COMPOSE_DEV) down --volumes --remove-orphans
endif
ifeq ($(PRIMARY_GOAL),shell)
shell: ## Get into container shell
$(DOCKER_COMPOSE_DEV) exec app /bin/bash
endif
ifeq ($(PRIMARY_GOAL),yii)
yii: ## Execute Yii command
$(DOCKER_COMPOSE_DEV) run --rm app ./yii $(CLI_ARGS)
.PHONY: yii
endif
ifeq ($(PRIMARY_GOAL),composer)
composer: ## Run Composer
$(DOCKER_COMPOSE_DEV) run --rm app composer $(CLI_ARGS)
endif
ifeq ($(PRIMARY_GOAL),rector)
rector: ## Run Rector
$(DOCKER_COMPOSE_DEV) run --rm app ./vendor/bin/rector $(CLI_ARGS)
endif
ifeq ($(PRIMARY_GOAL),cs-fix)
cs-fix: ## Run PHP CS Fixer
$(DOCKER_COMPOSE_DEV) run --rm app ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --diff
endif
#
# Tests and analysis
#
ifeq ($(PRIMARY_GOAL),test)
test:
$(DOCKER_COMPOSE_TEST) run --rm app ./vendor/bin/codecept run $(CLI_ARGS)
endif
ifeq ($(PRIMARY_GOAL),test-coverage)
test-coverage:
$(DOCKER_COMPOSE_TEST) run --rm app ./vendor/bin/codecept run --coverage --coverage-html --disable-coverage-php
endif
ifeq ($(PRIMARY_GOAL),codecept)
codecept: ## Run Codeception
$(DOCKER_COMPOSE_TEST) run --rm app ./vendor/bin/codecept $(CLI_ARGS)
endif
ifeq ($(PRIMARY_GOAL),psalm)
psalm: ## Run Psalm
$(DOCKER_COMPOSE_DEV) run --rm app ./vendor/bin/psalm $(CLI_ARGS)
endif
ifeq ($(PRIMARY_GOAL),composer-dependency-analyser)
composer-dependency-analyser: ## Run Composer Dependency Analyser
$(DOCKER_COMPOSE_DEV) run --rm app ./vendor/bin/composer-dependency-analyser --config=composer-dependency-analyser.php $(CLI_ARGS)
endif
#
# Production
#
ifeq ($(PRIMARY_GOAL),prod-build)
prod-build: ## PROD | Build an image
docker build --file docker/Dockerfile --target prod --pull -t ${IMAGE}:${IMAGE_TAG} .
endif
ifeq ($(PRIMARY_GOAL),prod-push)
prod-push: ## PROD | Push image to repository
docker push ${IMAGE}:${IMAGE_TAG}
endif
ifeq ($(PRIMARY_GOAL),prod-deploy)
prod-deploy: ## PROD | Deploy to production
docker -H ${PROD_SSH} stack deploy --prune --detach=false --with-registry-auth -c docker/compose.yml -c docker/prod/compose.yml ${STACK_NAME}
endif
#
# Other
#
ifeq ($(PRIMARY_GOAL),help)
# Output the help for each task, see https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
help: ## This help.
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
endif