-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
217 lines (184 loc) · 6.87 KB
/
Makefile
File metadata and controls
217 lines (184 loc) · 6.87 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# Makefile for Event Sourcing Chess Example
# Run commands in Docker containers
.PHONY: help build up down restart shell test phpstan phpcs phpmd grumphp migrate fixtures cache-clear cache-warmup logs
# Default target
help: ## Show this help message
@echo "Available commands:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'
# Docker Compose commands
build: ## Build the Docker images
docker compose build
up: ## Start all services
docker compose up -d
down: ## Stop all services
docker compose down
restart: ## Restart all services
docker compose restart
logs: ## Show logs from all services
docker compose logs -f
logs-%: ## Show logs from a specific service (e.g., make logs-php)
docker compose logs -f $*
# PHP container shell access
shell: ## Get a shell in the PHP container
@if docker compose ps php | grep -q "Up"; then \
docker compose exec php bash; \
else \
echo "PHP container not running, using local shell"; \
bash; \
fi
# Testing and code quality
test: ## Run PHPUnit tests
@if docker compose ps php | grep -q "Up"; then \
docker compose exec php ./bin/phpunit; \
else \
echo "PHP container not running, running locally"; \
./bin/phpunit; \
fi
test-coverage: ## Run PHPUnit tests with coverage
@if docker compose ps php | grep -q "Up"; then \
docker compose exec php ./bin/phpunit --coverage-html=var/coverage; \
else \
echo "PHP container not running, running locally"; \
./bin/phpunit --coverage-html=var/coverage; \
fi
test-filter: ## Run PHPUnit tests with filter (usage: make test-filter FILTER=TestClass::testMethod)
@if docker compose ps php | grep -q "Up"; then \
docker compose exec php ./bin/phpunit --filter=$(FILTER); \
else \
echo "PHP container not running, running locally"; \
./bin/phpunit --filter=$(FILTER); \
fi
# Code analysis
phpstan: ## Run PHPStan static analysis
@if docker compose ps php | grep -q "Up"; then \
docker compose exec php ./bin/phpstan analyse; \
else \
echo "PHP container not running, running locally"; \
./bin/phpstan analyse; \
fi
phpcs: ## Run PHP CodeSniffer
@if docker compose ps php | grep -q "Up"; then \
docker compose exec php ./bin/phpcs; \
else \
echo "PHP container not running, running locally"; \
./bin/phpcs; \
fi
phpcbf: ## Run PHP CodeSniffer fix
@if docker compose ps php | grep -q "Up"; then \
docker compose exec php ./bin/phpcbf; \
else \
echo "PHP container not running, running locally"; \
./bin/phpcbf; \
fi
phpmd: ## Run PHP Mess Detector
@if docker compose ps php | grep -q "Up"; then \
docker compose exec php ./bin/phpmd src,tests text phpmd.xml; \
else \
echo "PHP container not running, running locally"; \
./bin/phpmd src,tests text phpmd.xml; \
fi
grumphp: ## Run GrumPHP (includes multiple tools)
@if docker compose ps php | grep -q "Up"; then \
docker compose exec php ./bin/grumphp run; \
else \
echo "PHP container not running, running locally"; \
./bin/grumphp run; \
fi
# Database commands
migrate: ## Run Doctrine migrations
@if docker compose ps php | grep -q "Up"; then \
docker compose exec php ./bin/console doctrine:migrations:migrate --no-interaction; \
else \
echo "PHP container not running, running locally"; \
./bin/console doctrine:migrations:migrate --no-interaction; \
fi
migrate-status: ## Show Doctrine migration status
@if docker compose ps php | grep -q "Up"; then \
docker compose exec php ./bin/console doctrine:migrations:status; \
else \
echo "PHP container not running, running locally"; \
./bin/console doctrine:migrations:status; \
fi
fixtures: ## Load Doctrine fixtures
@if docker compose ps php | grep -q "Up"; then \
docker compose exec php ./bin/console doctrine:fixtures:load --no-interaction; \
else \
echo "PHP container not running, running locally"; \
./bin/console doctrine:fixtures:load --no-interaction; \
fi
db-create: ## Create the database
@if docker compose ps php | grep -q "Up"; then \
docker compose exec php ./bin/console doctrine:database:create --if-not-exists; \
else \
echo "PHP container not running, running locally"; \
./bin/console doctrine:database:create --if-not-exists; \
fi
db-drop: ## Drop the database
@if docker compose ps php | grep -q "Up"; then \
docker compose exec php ./bin/console doctrine:database:drop --force; \
else \
echo "PHP container not running, running locally"; \
./bin/console doctrine:database:drop --force; \
fi
db-reset: ## Reset database (drop and recreate)
@if docker compose ps php | grep -q "Up"; then \
docker compose exec php ./bin/console doctrine:database:drop --force --if-exists; \
docker compose exec php ./bin/console doctrine:database:create; \
else \
echo "PHP container not running, running locally"; \
./bin/console doctrine:database:drop --force --if-exists; \
./bin/console doctrine:database:create; \
fi
recreate-db: ## Recreate database and run migrations (from composer scripts)
@if docker compose ps php | grep -q "Up"; then \
docker compose exec php composer run-script recreate-db; \
else \
echo "PHP container not running, running locally"; \
composer run-script recreate-db; \
fi
# Cache commands
cache-clear: ## Clear Symfony cache
@if docker compose ps php | grep -q "Up"; then \
docker compose exec php ./bin/console cache:clear; \
else \
echo "PHP container not running, running locally"; \
./bin/console cache:clear; \
fi
cache-warmup: ## Warm up Symfony cache
@if docker compose ps php | grep -q "Up"; then \
docker compose exec php ./bin/console cache:warmup; \
else \
echo "PHP container not running, running locally"; \
./bin/console cache:warmup; \
fi
# Console commands
console: ## Run Symfony console (usage: make console CMD="debug:router")
@if docker compose ps php | grep -q "Up"; then \
docker compose exec php ./bin/console $(CMD); \
else \
echo "PHP container not running, running locally"; \
./bin/console $(CMD); \
fi
# Composer commands
composer-install: ## Install Composer dependencies
docker compose exec php composer install
composer-update: ## Update Composer dependencies
docker compose exec php composer update
# RabbitMQ commands
rabbitmq-status: ## Check RabbitMQ status
docker compose exec rabbitmq rabbitmqctl status
# Redis commands
redis-cli: ## Access Redis CLI
docker compose exec redis redis-cli
# Full development setup
setup: ## Full development setup (build, up, install deps, migrate, fixtures)
docker compose build
docker compose up -d
docker compose exec php composer install
docker compose exec php ./bin/console doctrine:database:create --if-not-exists
docker compose exec php ./bin/console doctrine:migrations:migrate --no-interaction
docker compose exec php ./bin/console doctrine:fixtures:load --no-interaction
docker compose exec php ./bin/console cache:warmup
# Clean up
clean: ## Clean up Docker containers and volumes
docker compose down -v --remove-orphans