|
1 | 1 | .DEFAULT_GOAL := help |
2 | 2 |
|
3 | | -# Run silent. |
4 | | -MAKEFLAGS += --silent |
5 | | - |
6 | | -RUN_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) |
7 | | -$(eval $(RUN_ARGS):;@:) |
| 3 | +CLI_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) |
| 4 | +$(eval $(CLI_ARGS):;@:) |
8 | 5 |
|
9 | 6 | include docker/.env |
10 | 7 |
|
11 | | -# Current user ID and group ID. |
| 8 | +# Current user ID and group ID |
12 | 9 | export UID=$(shell id -u) |
13 | 10 | export GID=$(shell id -g) |
14 | 11 |
|
15 | 12 | export COMPOSE_PROJECT_NAME=${STACK_NAME} |
| 13 | +DOCKER_COMPOSE_DEV := docker compose -f docker/compose.yml -f docker/compose.dev.yml |
| 14 | +DOCKER_COMPOSE_TEST := docker compose -f docker/compose.yml -f docker/compose.test.yml |
16 | 15 |
|
17 | | -up: ## Up the dev environment. |
18 | | - docker compose -f docker/compose.yml -f docker/compose.dev.yml up -d --remove-orphans |
19 | | - |
20 | | -up-build: ## Up the dev environment rebuilding images. |
21 | | - docker compose -f docker/compose.yml -f docker/compose.dev.yml up -d --remove-orphans --build |
22 | | - |
23 | | -down: ## Down the dev environment. |
24 | | - docker compose -f docker/compose.yml -f docker/compose.dev.yml down --remove-orphans |
| 16 | +# |
| 17 | +# Development |
| 18 | +# |
25 | 19 |
|
26 | | -exec: ## Run a command within the existing container. |
27 | | - docker compose -f docker/compose.yml -f docker/compose.dev.yml exec app $(CMD) $(RUN_ARGS) |
| 20 | +build: ## Build docker images |
| 21 | + $(DOCKER_COMPOSE_DEV) build $(CLI_ARGS) |
28 | 22 |
|
29 | | -run: ## Run a command within a temporary container. |
30 | | - docker compose -f docker/compose.yml -f docker/compose.dev.yml run --rm --entrypoint $(CMD) app $(RUN_ARGS) |
| 23 | +up: ## Up the dev environment |
| 24 | + $(DOCKER_COMPOSE_DEV) up -d --remove-orphans |
31 | 25 |
|
32 | | -run-test: ## Run a command in testing environment. |
33 | | - docker compose -f docker/compose.yml -f docker/compose.test.yml run --rm --entrypoint $(CMD) app $(RUN_ARGS) |
| 26 | +down: ## Down the dev environment |
| 27 | + $(DOCKER_COMPOSE_DEV) down --remove-orphans |
34 | 28 |
|
35 | | -shell: CMD="/bin/sh" ## Get into container shell. |
36 | | -shell: exec |
| 29 | +shell: ## Get into container shell |
| 30 | + $(DOCKER_COMPOSE_DEV) exec app /bin/sh |
37 | 31 |
|
38 | | -yii: CMD="./yii" ## Execute Yii command. |
39 | | -yii: run |
| 32 | +yii: ## Execute Yii command |
| 33 | + $(DOCKER_COMPOSE_DEV) run --rm app ./yii $(CLI_ARGS) |
| 34 | +.PHONY: yii |
40 | 35 |
|
41 | | -composer: CMD="composer" ## Run Composer. |
42 | | -composer: run |
| 36 | +composer: ## Run Composer |
| 37 | + $(DOCKER_COMPOSE_DEV) run --rm app composer $(CLI_ARGS) |
43 | 38 |
|
44 | | -codecept: CMD="./vendor/bin/codecept" ## Run Codeception. |
45 | | -codecept: run-test |
| 39 | +codecept: ## Run Codeception |
| 40 | + $(DOCKER_COMPOSE_TEST) run --rm app ./vendor/bin/codecept $(CLI_ARGS) |
46 | 41 |
|
47 | | -psalm: CMD="./vendor/bin/psalm" ## Run Psalm. |
48 | | -psalm: run |
| 42 | +psalm: ## Run Psalm |
| 43 | + $(DOCKER_COMPOSE_DEV) run --rm app ./vendor/bin/psalm $(CLI_ARGS) |
49 | 44 |
|
50 | | -rector: CMD="./vendor/bin/rector" ## Run Rector. |
51 | | -rector: run |
| 45 | +rector: ## Run Rector |
| 46 | + $(DOCKER_COMPOSE_DEV) run --rm app ./vendor/bin/rector $(CLI_ARGS) |
52 | 47 |
|
53 | 48 | cs-fix: |
54 | | - docker compose -f docker/compose.yml -f docker/compose.dev.yml run --rm --entrypoint ./vendor/bin/php-cs-fixer app fix --config=.php-cs-fixer.php --diff |
| 49 | + $(DOCKER_COMPOSE_DEV) run --rm app ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --diff |
55 | 50 |
|
56 | | -build-prod: ## Build an image. |
| 51 | +# |
| 52 | +# Production |
| 53 | +# |
| 54 | + |
| 55 | +prod-build: ## PROD | Build an image |
57 | 56 | docker build --file docker/Dockerfile --target prod --pull -t ${IMAGE}:${IMAGE_TAG} . |
58 | 57 |
|
59 | | -push-prod: ## Push image to repository. |
| 58 | +prod-push: ## PROD | Push image to repository |
60 | 59 | docker push ${IMAGE}:${IMAGE_TAG} |
61 | 60 |
|
62 | | -deploy-prod: ## Deploy to production. |
| 61 | +prod-deploy: ## PROD | Deploy to production |
63 | 62 | docker -H ${PROD_SSH} stack deploy --with-registry-auth -d -c docker/compose.yml -c docker/compose.prod.yml ${STACK_NAME} |
64 | 63 |
|
| 64 | +# |
| 65 | +# Other |
| 66 | +# |
| 67 | + |
65 | 68 | # Output the help for each task, see https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html |
66 | | -.PHONY: help |
67 | 69 | help: ## This help. |
68 | 70 | @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) |
0 commit comments