-
-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathMakefile
More file actions
182 lines (136 loc) · 6.24 KB
/
Makefile
File metadata and controls
182 lines (136 loc) · 6.24 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
# ──────────────────────────────────────────────────────────────
# NNTmux – Docker / Sail convenience targets
# ──────────────────────────────────────────────────────────────
#
# Run `make` or `make help` to see all available targets.
# See DOCKER.md for full documentation.
# ──────────────────────────────────────────────────────────────
.DEFAULT_GOAL := help
# Source SEARCH_DRIVER from .env and export as COMPOSE_PROFILES
# so the correct search engine container starts automatically.
-include .env
export COMPOSE_PROFILES ?= $(SEARCH_DRIVER)
SAIL := ./sail
DOCKER_COMPOSE := docker compose
# Colors
CYAN := \033[36m
GREEN := \033[32m
YELLOW := \033[33m
RESET := \033[0m
# ── Lifecycle ────────────────────────────────────────────────
.PHONY: up
up: ## Start all services in the background
@$(SAIL) up -d
.PHONY: down
down: ## Stop all services
@$(SAIL) down
.PHONY: stop
stop: down ## Alias for 'down'
.PHONY: restart
restart: ## Restart all services
@$(SAIL) restart
.PHONY: build
build: ## Build the app image
@$(SAIL) build
.PHONY: rebuild
rebuild: ## Build the app image from scratch (no cache)
@$(SAIL) build --no-cache
.PHONY: pull
pull: ## Pull the latest versions of all base images
@$(DOCKER_COMPOSE) pull
.PHONY: update
update: pull rebuild ## Pull latest images, rebuild, and restart
@$(SAIL) up -d
.PHONY: fresh
fresh: ## Destroy ALL volumes, rebuild, and start clean (DATA LOSS!)
@echo "$(YELLOW)⚠ This will destroy all Docker volumes (database, redis, search index).$(RESET)"
@read -p "Are you sure? [y/N] " confirm && [ "$$confirm" = "y" ] || exit 1
@$(SAIL) down -v
@$(SAIL) build --no-cache
@$(SAIL) up -d
@echo "$(GREEN)✔ Fresh environment is up. Run 'make artisan cmd=nntmux:install' to initialise.$(RESET)"
# ── Shell Access ─────────────────────────────────────────────
.PHONY: shell
shell: ## Open a bash shell in the app container
@$(SAIL) shell
.PHONY: root-shell
root-shell: ## Open a root bash shell in the app container
@$(SAIL) root-shell
.PHONY: tinker
tinker: ## Open a Laravel Tinker session
@$(SAIL) tinker
# ── Artisan / PHP ────────────────────────────────────────────
.PHONY: artisan
artisan: ## Run an artisan command (usage: make artisan cmd="migrate")
@$(SAIL) artisan $(cmd)
.PHONY: tmux-start
tmux-start: ## Start the NNTmux tmux processing engine
@$(SAIL) artisan tmux:start
.PHONY: tmux-stop
tmux-stop: ## Stop the NNTmux tmux processing engine
@$(SAIL) artisan tmux:stop
.PHONY: tmux-attach
tmux-attach: ## Attach to the running tmux session
@$(SAIL) artisan tmux:attach
.PHONY: horizon
horizon: ## Show Horizon status
@$(SAIL) artisan horizon:status
# ── Testing & Quality ────────────────────────────────────────
.PHONY: test
test: ## Run the PHPUnit test suite (usage: make test filter=TestName)
@$(SAIL) test $(if $(filter),--filter=$(filter),)
.PHONY: pint
pint: ## Run Laravel Pint code formatter on dirty files
@$(SAIL) pint --dirty
.PHONY: pint-all
pint-all: ## Run Laravel Pint on all files
@$(SAIL) pint
# ── Frontend ─────────────────────────────────────────────────
.PHONY: npm-build
npm-build: ## Run npm install and build inside the container
@$(SAIL) npm install
@$(SAIL) npm run build
.PHONY: npm-dev
npm-dev: ## Start Vite dev server inside the container
@$(SAIL) npm run dev
# ── Dependencies ─────────────────────────────────────────────
.PHONY: composer-install
composer-install: ## Run composer install inside the container
@$(SAIL) composer install
.PHONY: composer-update
composer-update: ## Run composer update inside the container
@$(SAIL) composer update
# ── Database / Services ──────────────────────────────────────
.PHONY: db
db: ## Open a MariaDB CLI session
@$(SAIL) mariadb
.PHONY: redis-cli
redis-cli: ## Open a Redis CLI session
@$(SAIL) redis
# ── Logs & Status ────────────────────────────────────────────
.PHONY: logs
logs: ## Tail logs from all containers
@$(DOCKER_COMPOSE) logs -f --tail=100
.PHONY: status
status: ## Show running containers and their status
@$(DOCKER_COMPOSE) ps
# ── Cleanup ──────────────────────────────────────────────────
.PHONY: clean
clean: ## Remove stopped containers and dangling images
@docker system prune -f
@echo "$(GREEN)✔ Cleaned up dangling resources.$(RESET)"
.PHONY: nuke
nuke: ## Remove ALL project containers, images, and volumes (DATA LOSS!)
@echo "$(YELLOW)⚠ This will remove ALL project containers, images, and volumes.$(RESET)"
@read -p "Are you sure? [y/N] " confirm && [ "$$confirm" = "y" ] || exit 1
@$(SAIL) down -v --rmi all
@echo "$(GREEN)✔ All project Docker resources removed.$(RESET)"
# ── Help ─────────────────────────────────────────────────────
.PHONY: help
help: ## Show this help message
@echo ""
@echo "$(CYAN)NNTmux Docker / Sail Commands$(RESET)"
@echo "$(CYAN)─────────────────────────────$(RESET)"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf " $(GREEN)%-20s$(RESET) %s\n", $$1, $$2}'
@echo ""