|
| 1 | +DOCKER_COMPOSE?=docker-compose |
| 2 | +EXEC?=$(DOCKER_COMPOSE) exec app |
| 3 | +CONSOLE=bin/console |
| 4 | +PHPCSFIXER?=$(EXEC) php -d memory_limit=1024m vendor/bin/php-cs-fixer |
| 5 | + |
| 6 | +.DEFAULT_GOAL := help |
| 7 | +.PHONY: help start stop restart install uninstall reset clear-cache tty clear clean |
| 8 | +.PHONY: db-diff db-migrate db-rollback db-reset db-validate wait-for-db |
| 9 | +.PHONY: watch assets assets-build |
| 10 | +.PHONY: tests lint lint-symfony lint-yaml lint-twig lint-twig php-cs php-cs-fix security-check test-schema test-all |
| 11 | +.PHONY: deps |
| 12 | +.PHONY: build up perm |
| 13 | +.PHONY: docker-compose.override.yml |
| 14 | + |
| 15 | +help: |
| 16 | + @grep -E '(^[a-zA-Z_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/' |
| 17 | + |
| 18 | +## |
| 19 | +## Project setup |
| 20 | +##--------------------------------------------------------------------------- |
| 21 | + |
| 22 | +start: ## Start docker containers |
| 23 | + $(DOCKER_COMPOSE) start |
| 24 | + |
| 25 | +stop: ## Stop docker containers |
| 26 | + $(DOCKER_COMPOSE) stop |
| 27 | + |
| 28 | +restart: ## Restart docker containers |
| 29 | + $(DOCKER_COMPOSE) restart |
| 30 | + |
| 31 | +install: docker-compose.override.yml build up deps perm ## Create and start docker containers |
| 32 | + |
| 33 | +uninstall: stop ## Remove docker containers |
| 34 | + $(DOCKER_COMPOSE) rm -vf |
| 35 | + |
| 36 | +reset: uninstall install ## Remove and re-create docker containers |
| 37 | + |
| 38 | +clear-cache: perm |
| 39 | + $(EXEC) $(CONSOLE) cache:clear --no-warmup |
| 40 | + $(EXEC) $(CONSOLE) cache:warmup |
| 41 | + |
| 42 | +tty: ## Run app container in interactive mode |
| 43 | + $(EXEC) /bin/bash |
| 44 | + |
| 45 | +clear: perm ## Remove all the cache, the logs, the sessions and the built assets |
| 46 | + $(EXEC) rm -rf var/cache/* |
| 47 | + $(EXEC) $(CONSOLE) redis:flushall -n |
| 48 | + rm -rf var/log/* |
| 49 | + rm -rf public/build |
| 50 | + rm -f var/.php_cs.cache |
| 51 | + |
| 52 | +clean: clear ## Clear and remove dependencies |
| 53 | + rm -rf vendor node_modules |
| 54 | + |
| 55 | + |
| 56 | +## |
| 57 | +## Database |
| 58 | +##--------------------------------------------------------------------------- |
| 59 | + |
| 60 | +wait-for-db: |
| 61 | + $(EXEC) php -r "set_time_limit(60);for(;;){if(@fsockopen('db',3306)){break;}echo \"Waiting for MySQL\n\";sleep(1);}" |
| 62 | + |
| 63 | +db-diff: vendor wait-for-db ## Generate a migration by comparing your current database to your mapping information |
| 64 | + $(EXEC) $(CONSOLE) doctrine:migration:diff |
| 65 | + |
| 66 | +db-migrate: vendor wait-for-db ## Migrate database schema to the latest available version |
| 67 | + $(EXEC) $(CONSOLE) doctrine:migration:migrate -n |
| 68 | + |
| 69 | +db-rollback: vendor wait-for-db ## Rollback the latest executed migration |
| 70 | + $(EXEC) $(CONSOLE) doctrine:migration:migrate prev -n |
| 71 | + |
| 72 | +db-reset: vendor wait-for-db ## Reset the database |
| 73 | + $(EXEC) $(CONSOLE) doctrine:database:drop --force --if-exists |
| 74 | + $(EXEC) $(CONSOLE) doctrine:database:create --if-not-exists |
| 75 | + $(EXEC) $(CONSOLE) doctrine:migrations:migrate -n |
| 76 | + |
| 77 | +db-fixtures: vendor wait-for-db ## Apply doctrine fixtures |
| 78 | + $(EXEC) $(CONSOLE) doctrine:fixtures:load -n |
| 79 | + |
| 80 | +db-validate: vendor wait-for-db ## Check the ORM mapping |
| 81 | + $(EXEC) $(CONSOLE) doctrine:schema:validate |
| 82 | + |
| 83 | + |
| 84 | +## |
| 85 | +## Assets |
| 86 | +##--------------------------------------------------------------------------- |
| 87 | + |
| 88 | +watch: node_modules ## Watch the assets and build their development version on change |
| 89 | + $(EXEC) yarn watch |
| 90 | + |
| 91 | +assets: node_modules ## Build the development version of the assets |
| 92 | + $(EXEC) yarn dev |
| 93 | + |
| 94 | +assets-build: node_modules ## Build the production version of the assets |
| 95 | + $(EXEC) yarn build |
| 96 | + |
| 97 | +## |
| 98 | +## Tests |
| 99 | +##--------------------------------------------------------------------------- |
| 100 | + |
| 101 | +tests: ## Run all the PHP tests |
| 102 | + $(EXEC) bin/phpunit |
| 103 | + |
| 104 | +lint: lint-symfony php-cs ## Run lint on Twig, YAML, PHP and Javascript files |
| 105 | + |
| 106 | +lint-symfony: lint-yaml lint-twig lint-xliff ## Lint Symfony (Twig and YAML) files |
| 107 | + |
| 108 | +lint-yaml: ## Lint YAML files |
| 109 | + $(EXEC) $(CONSOLE) lint:yaml config |
| 110 | + |
| 111 | +lint-twig: ## Lint Twig files |
| 112 | + $(EXEC) $(CONSOLE) lint:twig templates |
| 113 | + |
| 114 | +lint-xliff: ## Lint Translation files |
| 115 | + $(EXEC) $(CONSOLE) lint:xliff translations |
| 116 | + |
| 117 | +php-cs: vendor ## Lint PHP code |
| 118 | + $(PHPCSFIXER) fix --diff --dry-run --no-interaction -v |
| 119 | + |
| 120 | +php-cs-fix: vendor ## Lint and fix PHP code to follow the convention |
| 121 | + $(PHPCSFIXER) fix |
| 122 | + |
| 123 | +security-check: vendor ## Check for vulnerable dependencies |
| 124 | + $(EXEC) vendor/bin/security-checker security:check |
| 125 | + |
| 126 | +test-schema: vendor ## Test the doctrine Schema |
| 127 | + $(EXEC) $(CONSOLE) doctrine:schema:validate --skip-sync -vvv --no-interaction |
| 128 | + |
| 129 | +test-all: lint test-schema security-check tests ## Lint all, check vulnerable dependencies, run PHP tests |
| 130 | + |
| 131 | +## |
| 132 | +## Dependencies |
| 133 | +##--------------------------------------------------------------------------- |
| 134 | + |
| 135 | +deps: vendor assets ## Install the project PHP and JS dependencies |
| 136 | + |
| 137 | + |
| 138 | +## |
| 139 | + |
| 140 | + |
| 141 | +# Internal rules |
| 142 | + |
| 143 | +build: |
| 144 | + $(DOCKER_COMPOSE) pull --ignore-pull-failures |
| 145 | + $(DOCKER_COMPOSE) build --force-rm |
| 146 | + |
| 147 | +up: |
| 148 | + $(DOCKER_COMPOSE) up -d --remove-orphans |
| 149 | + |
| 150 | +perm: |
| 151 | + $(EXEC) chmod -R 777 var public/build node_modules vendor |
| 152 | + $(EXEC) chown -R www-data:root var public/build node_modules vendor |
| 153 | + |
| 154 | +docker-compose.override.yml: |
| 155 | +ifneq ($(wildcard docker-compose.override.yml),docker-compose.override.yml) |
| 156 | + @echo docker-compose.override.yml do not exists, copy docker-compose.override.yml.dist to create it, and fill it. |
| 157 | + exit 1 |
| 158 | +endif |
| 159 | + |
| 160 | + |
| 161 | +# Rules from files |
| 162 | + |
| 163 | +vendor: composer.lock |
| 164 | + $(EXEC) composer install -n |
| 165 | + |
| 166 | +composer.lock: composer.json |
| 167 | + @echo compose.lock is not up to date. |
| 168 | + |
| 169 | +node_modules: yarn.lock |
| 170 | + $(EXEC) yarn install |
| 171 | + |
| 172 | +yarn.lock: package.json |
| 173 | + @echo yarn.lock is not up to date. |
0 commit comments