-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
217 lines (176 loc) · 7.57 KB
/
Makefile
File metadata and controls
217 lines (176 loc) · 7.57 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
###############################################################################
# Coqui — Development Makefile
#
# Self-documenting: run `make` or `make help` to see all targets.
#
# Naming convention:
# bare names — native (no Docker)
# docker-* — Docker compose operations
#
# Port defaults: API=3300, Dashboard=3380, Webgrind=3390
###############################################################################
.PHONY: help \
start stop status repl api api-stop restart \
dashboard dashboard-stop dashboard-install \
dev serve \
docker-build docker-start docker-stop docker-status \
docker-repl docker-api docker-api-stop docker-api-logs \
docker-dashboard docker-dashboard-stop \
docker-serve docker-all docker-dev docker-shell \
test test-coverage install clean clean-workspace clean-pids \
composer xdebug-clear
# Default target
help: ## Show this help message
@echo ""
@echo " Coqui — Development Environment"
@echo ""
@echo "Usage: make [target]"
@echo ""
@echo " Native:"
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / && !/^docker-/ {printf " %-22s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
@echo ""
@echo " Docker:"
@awk 'BEGIN {FS = ":.*?## "} /^docker-[a-zA-Z_-]+:.*?## / {printf " %-22s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
@echo ""
# =============================================================================
# Native
# =============================================================================
start: ## Start REPL + API (default)
@./bin/coqui-launcher $(ARGS)
stop: ## Stop all running services
@./bin/coqui-launcher stop
status: ## Show running service status
@./bin/coqui-launcher status
repl: ## Start REPL only (no background API)
@./bin/coqui-launcher --repl-only $(ARGS)
api: ## Start API only (foreground, port 3300)
ifdef PORT
@./bin/coqui-launcher --api-only --port $(PORT) $(ARGS)
else
@./bin/coqui-launcher --api-only $(ARGS)
endif
api-stop: ## Stop the API server
@./bin/coqui-launcher stop-api
restart: ## Restart REPL + API (clean stop then start)
@./bin/coqui-launcher stop 2>/dev/null || true
@./bin/coqui-launcher $(ARGS)
dashboard: ## Start the Dashboard (foreground, port 3380)
ifdef PORT
@./bin/coqui-launcher --dashboard --dashboard-port $(PORT) $(ARGS)
else
@./bin/coqui-launcher --dashboard $(ARGS)
endif
dashboard-stop: ## Stop the Dashboard
@./bin/coqui-launcher stop-dashboard
dashboard-install: ## Install Dashboard Composer dependencies
@cd public && composer install --no-dev
@echo "Dashboard dependencies installed"
dev: ## Start REPL + API in dev mode (Xdebug)
@XDEBUG_MODE=debug XDEBUG_CONFIG="client_host=localhost" ./bin/coqui-launcher $(ARGS)
serve: ## Start API + Dashboard (background)
@./bin/coqui-launcher --api-only --background $(ARGS)
@./bin/coqui-launcher --dashboard --background $(ARGS)
# =============================================================================
# Docker
# =============================================================================
COMPOSE_API := -f compose.yaml -f compose.api.yaml
COMPOSE_DASH := -f compose.yaml -f compose.dashboard.yaml
COMPOSE_DEV := -f compose.yaml -f compose.dev.yaml
COMPOSE_TEST := -f compose.yaml -f compose.test.yaml
COMPOSE_ALL := -f compose.yaml -f compose.api.yaml -f compose.dashboard.yaml
docker-build: ## Build the Coqui Docker image
@docker compose build
@echo "Image built"
docker-start: ## Start REPL (interactive) + API (background)
@docker compose $(COMPOSE_API) up -d coqui-api
@echo "API running at http://localhost:$${COQUI_API_PORT:-3300}"
@docker compose run --rm coqui $(ARGS)
docker-stop: ## Stop all Docker services
@docker compose $(COMPOSE_ALL) -f compose.dev.yaml -f compose.test.yaml \
down --remove-orphans 2>/dev/null || true
@echo "All services stopped"
docker-status: ## Show Docker container status
@docker compose $(COMPOSE_ALL) ps 2>/dev/null || true
docker-repl: ## Start REPL only (Docker)
@docker compose run --rm coqui $(ARGS)
docker-api: ## Start API only (daemon, port 3300)
ifdef PORT
@COQUI_API_PORT=$(PORT) docker compose $(COMPOSE_API) up -d coqui-api
@echo "API running at http://localhost:$(PORT)"
else
@docker compose $(COMPOSE_API) up -d coqui-api
@echo "API running at http://localhost:$${COQUI_API_PORT:-3300}"
endif
docker-api-stop: ## Stop the API container
@docker compose $(COMPOSE_API) stop coqui-api
@echo "API stopped"
docker-api-logs: ## Follow API server logs
@docker compose $(COMPOSE_API) logs -f coqui-api
docker-dashboard: ## Start Dashboard (daemon, port 3380)
ifdef PORT
@COQUI_DASHBOARD_PORT=$(PORT) docker compose $(COMPOSE_DASH) up -d dashboard
@echo "Dashboard running at http://localhost:$(PORT)"
else
@docker compose $(COMPOSE_DASH) up -d dashboard
@echo "Dashboard running at http://localhost:$${COQUI_DASHBOARD_PORT:-3380}"
endif
docker-dashboard-stop: ## Stop the Dashboard container
@docker compose $(COMPOSE_DASH) stop dashboard
@echo "Dashboard stopped"
docker-serve: ## Start API + Dashboard (daemon)
@docker compose $(COMPOSE_ALL) up -d coqui-api dashboard
@echo "API: http://localhost:$${COQUI_API_PORT:-3300}"
@echo "Dashboard: http://localhost:$${COQUI_DASHBOARD_PORT:-3380}"
docker-all: ## Start REPL + API + Dashboard
@docker compose $(COMPOSE_ALL) up -d coqui-api dashboard
@echo "API: http://localhost:$${COQUI_API_PORT:-3300}"
@echo "Dashboard: http://localhost:$${COQUI_DASHBOARD_PORT:-3380}"
@docker compose run --rm coqui $(ARGS)
docker-dev: ## Dev mode: REPL + Xdebug + Webgrind
@docker compose $(COMPOSE_DEV) up -d webgrind
@echo "Webgrind: http://localhost:$${COQUI_WEBGRIND_PORT:-3390}"
@docker compose $(COMPOSE_DEV) run --rm coqui $(ARGS)
docker-shell: ## Open a bash shell in the container
@docker compose run --rm --entrypoint /bin/bash coqui
# =============================================================================
# Build & Test
# =============================================================================
test: ## Run Pest tests (Docker)
@docker compose $(COMPOSE_TEST) run --rm coqui
@echo "Tests complete"
test-coverage: ## Run tests with code coverage
@docker compose $(COMPOSE_TEST) run --rm coqui \
vendor/bin/pest --coverage --min=0
@echo "Coverage report complete"
install: ## Run composer install (Docker)
@docker compose run --rm --entrypoint composer coqui install
composer: ## Run composer command (make composer CMD="require foo/bar")
@if [ -z "$(CMD)" ]; then \
echo "Usage: make composer CMD=\"require foo/bar\""; \
exit 1; \
fi
@docker compose run --rm --entrypoint composer coqui $(CMD)
xdebug-clear: ## Clear Xdebug profiler output
@docker compose run --rm --entrypoint clear-xdebug coqui
@echo "Xdebug files cleared"
# =============================================================================
# Cleanup
# =============================================================================
clean: ## Remove all Docker containers, images, and volumes
@docker compose $(COMPOSE_ALL) -f compose.dev.yaml -f compose.test.yaml \
down -v --remove-orphans --rmi local 2>/dev/null || true
@echo "Cleaned up"
clean-workspace: ## Remove only the workspace volume
@docker volume rm coqui_workspace 2>/dev/null || true
@echo "Workspace volume removed"
clean-pids: ## Remove PID files and kill orphaned processes on known ports
@rm -f .workspace/pids/*.pid 2>/dev/null || true
@rm -f /tmp/coqui-pids-$$(id -u)/*.pid 2>/dev/null || true
@for port in 3300 3380; do \
pids=$$(lsof -ti tcp:$$port 2>/dev/null || true); \
if [ -n "$$pids" ]; then \
echo "Killing process(es) on port $$port: $$pids"; \
echo "$$pids" | xargs kill 2>/dev/null || true; \
fi; \
done
@echo "PID files cleaned"