-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
122 lines (93 loc) · 4.85 KB
/
Copy pathMakefile
File metadata and controls
122 lines (93 loc) · 4.85 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
# =============================================================================
# RedCrossQuest - Docker dev environment
# Entry point: `make` (alias of `make help`)
# Full bootstrap from a clean clone: `make init`
# =============================================================================
SHELL := /usr/bin/env bash
.DEFAULT_GOAL := help
DC := docker compose
PHP_EXEC := $(DC) exec -T php-fpm
NODE_EXEC:= $(DC) exec -T node-client
.PHONY: help init up down restart build rebuild logs logs-php logs-php-errors ps \
composer-install composer-update composer npm \
phinx-migrate phinx-rollback phinx \
gulp-serve gulp-build \
shell-php shell-node \
refresh-di \
clean nuke doctor
help: ## Show available targets
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " \033[36m%-22s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
# ----------------------------------------------------------------------------
# Lifecycle
# ----------------------------------------------------------------------------
init: ## One-shot bootstrap: .env + build + deps + up (Phinx migrations run manually)
@./run_local.sh
up: ## Start the stack in the background
$(DC) up -d
down: ## Stop and remove the containers (keeps volumes)
$(DC) down
restart: down up ## Restart the stack
build: ## Build all images
$(DC) build
rebuild: ## Rebuild images from scratch (no cache)
$(DC) build --no-cache --pull
logs: ## Tail logs from all services (Ctrl-C to quit)
$(DC) logs -f --tail=100
logs-php: ## Tail PHP-FPM logs (warnings/notices/deprecations are sent here, Ctrl-C to quit)
$(DC) logs -f --tail=200 php-fpm
logs-php-errors: ## Show recent PHP errors/warnings/deprecations from the last 30 minutes
@$(DC) logs --since=30m php-fpm 2>&1 | grep -iE 'deprecated|warning|notice|fatal|parse error|uncaught' || echo " (no PHP errors in the last 30 minutes)"
ps: ## List running services
$(DC) ps
# ----------------------------------------------------------------------------
# Dependencies
# ----------------------------------------------------------------------------
composer-install: ## composer install inside the php-fpm container
$(PHP_EXEC) composer install --no-interaction
composer-update: ## composer update
$(PHP_EXEC) composer update --no-interaction
composer: ## Arbitrary composer cmd: `make composer cmd="require foo/bar"`
$(PHP_EXEC) composer $(cmd)
refresh-di: ## Purge compiled PHP-DI container + regenerate optimized autoloader
$(DC) exec -T -w /app/server php-fpm bash regenerate-php-di-cache.sh
npm: ## npm in the node-client container: `make npm cmd="install"`
$(NODE_EXEC) npm $(cmd)
# ----------------------------------------------------------------------------
# Database migrations (Phinx) — run against the host's own phinx.yml; pick the
# environment with `env=<name>` (defaults to whatever `default_environment`
# points to in your phinx.yml).
# ----------------------------------------------------------------------------
PHINX_ENV := $(if $(env),-e $(env),)
phinx-migrate: ## Run all pending phinx migrations (override env with env=<name>)
$(PHP_EXEC) php vendor/bin/phinx migrate -c /app/server/phinx.yml $(PHINX_ENV)
phinx-rollback: ## Rollback the last migration (override env with env=<name>)
$(PHP_EXEC) php vendor/bin/phinx rollback -c /app/server/phinx.yml $(PHINX_ENV)
phinx: ## Arbitrary phinx cmd: `make phinx cmd="status" [env=local]`
$(PHP_EXEC) php vendor/bin/phinx $(cmd) -c /app/server/phinx.yml $(PHINX_ENV)
# ----------------------------------------------------------------------------
# Front-end
# ----------------------------------------------------------------------------
gulp-serve: ## Start `gulp serve` (attached, Ctrl-C to stop)
$(DC) exec node-client gulp serve
gulp-build: ## Run the production build (dist/)
$(NODE_EXEC) bash -c "./build.sh"
# ----------------------------------------------------------------------------
# Shells
# ----------------------------------------------------------------------------
shell-php: ## Open a shell in the php-fpm container
$(DC) exec php-fpm bash
shell-node: ## Open a shell in the node-client container
$(DC) exec node-client bash
# ----------------------------------------------------------------------------
# Maintenance
# ----------------------------------------------------------------------------
clean: ## Remove containers + named volumes (composer/npm caches only; DB is external)
$(DC) down -v
nuke: clean ## Remove containers, volumes AND images
$(DC) down -v --rmi local
doctor: ## Quick diagnostic of the running stack
@echo "== docker version ==" && docker version --format '{{.Server.Version}}'
@echo "== services ==" && $(DC) ps
@echo "== PHP info ==" && $(PHP_EXEC) php -v || true
@echo "== Node info ==" && $(NODE_EXEC) node -v || true
@echo "== rcq_mysql ==" && docker ps --filter name=rcq_mysql --format '{{.Names}}\t{{.Status}}' || true