-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
121 lines (87 loc) · 4.08 KB
/
Makefile
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
# This Makefile can be extended by another Makefile located in your project directory.
SHELL := /bin/bash
PHP_SERVICE := docker compose exec -u www-data:www-data php sh -c
# Define a static project name that will be prepended to each service name
export COMPOSE_PROJECT_NAME := proximis_$(shell echo $$(basename $$(pwd)) | tr '[:upper:]' '[:lower:]')
# Extract environment variables needed by the environment
export DOCKER_PHP_IMAGE := $(shell grep DOCKER_PHP_IMAGE ${MAKEFILE_DIRECTORY}docker/local/.env | awk -F '=' '{print $$NF}')
export PROJECT_LOCATION := $(shell echo ${MAKEFILE_DIRECTORY})
##
## ----------------------------------------------------------------------------
## Environment
## ----------------------------------------------------------------------------
##
backup: ## Backup the "mysql" volume
docker run --rm \
--volumes-from $$(docker compose ps -q mysql) \
--volume $$(pwd):/backup \
busybox sh -c "tar cvf /backup/backup.tar /var/lib/mysql"
build: ## Build the environment
docker compose build --pull
cache: ## Flush cache in Redis
docker compose exec redis sh -c "redis-cli FLUSHALL"
logs: ## Follow logs generated by all containers
docker compose logs -f --tail=0
logs-full: ## Follow logs generated by all containers from the containers creation
docker compose logs -f
mysql: ## Open a terminal in the "mysql" container
docker compose exec mysql sh
nginx: ## Open a terminal in the "nginx" container
docker compose exec -u nginx:nginx nginx sh -l
php: ## Open a terminal in the "php" container
docker compose exec -u www-data:www-data php bash -l -c "source ./project.sh use && /bin/bash"
phpl: ## Open a terminal in the "php" container and prompt source locale
@read -p "Enter locale: " locale; \
docker compose exec -u www-data:www-data php bash -l -c "source ./project.sh use $$locale && /bin/bash"
source: ## Set source with given locale
@read -p "Enter locale: " locale; \
source ./project.sh use $$locale
ps: ## List all containers managed by the environment
docker compose ps
purge: ## Purge all services and associated volumes
docker compose down -v
restart: stop start ## Restart the environment
restore: ## Restore the "mysql" volume
docker run --rm \
--volumes-from $$(docker compose ps -q mysql) \
--volume $$(pwd):/backup \
busybox sh -c "tar xvf /backup/backup.tar var/lib/mysql/"
docker compose restart mysql
start: ## Start the environment
@docker compose up --detach --remove-orphans
stats: ## Print real-time statistics about containers ressources usage
docker stats $(docker ps --format={{.Names}})
stop: ## Stop the environment
@docker compose stop
.PHONY: backup build cache logs logs mysql nginx php ps purge restart restore start stats stop
##
## ----------------------------------------------------------------------------
## Pipelines
## ----------------------------------------------------------------------------
##
ci: ## Run continuous integration analysis
@make phpcsfixer-audit phpstan eslint stylelint
ci-fix: ## Run continuous integration fixes
@make phpcsfixer eslint-fix stylelint-fix
phpcsfixer: ## Execute the code style analysis and fix on all PHP files
./vendor/bin/php-cs-fixer fix --verbose
phpcsfixer-audit: ## Executes the code style analysis in dry-run mode (no fix) on all PHP files
./vendor/bin/php-cs-fixer fix --dry-run --verbose
phpstan: ## Execute a static analysis on all PHP files
./vendor/bin/phpstan --memory-limit="-1" analyse
eslint: ## Execute the code style analysis on all js files
yarn run eslint
eslint-fix: ## Execute the code style analysis and fix on all js files
yarn run eslint-fix
stylelint: ## Execute the code style analysis on all scss files
yarn run stylelint
stylelint-fix: ## Execute the code style analysis and fix on all scss files
yarn run stylelint-fix
.PHONY: ci ci-fix phpcsfixer phpcsfixer-audit phpstan eslint eslint-fix stylelint stylelint-fix
.DEFAULT_GOAL := help
help:
@grep -E '(^[0-9a-zA-Z_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) \
| sed -e 's/^.*Makefile://g' \
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' \
| sed -e 's/\[32m##/[33m/'
.PHONY: help