Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
121 lines (95 loc) · 4.05 KB
/
Copy pathMakefile
File metadata and controls
121 lines (95 loc) · 4.05 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
# Root Makefile - Proxies to sub-project Makefiles
# Uses doppler for secrets management
REMOTE_USER_ID ?=
COMPOSE_LOCAL := docker compose -f docker-compose.local.yml
# Local stack's postgres (from docker-compose.local.yml). Seed/clone run on the
# host and talk to it over the published port.
LOCAL_DATABASE_URL := postgres://postgres:postgres@localhost:5432/root?sslmode=disable
.PHONY: help db wipe seed-db clone-user-data migrate-up migrate-status \
migrate-to migrate-force dev-frontend test-rag lint-frontend \
up up-build down down-v logs ps restart require-stack
# Default target
help:
@echo "Root Makefile - Common Commands"
@echo ""
@echo "Database:"
@echo " make db - Start PostgreSQL (Docker)"
@echo " make wipe - Wipe database and volumes"
@echo " make migrate-up - Run all migrations"
@echo " make migrate-status - Check migration version"
@echo " make migrate-to N - Migrate to specific version N"
@echo " make migrate-force N - Force migration version to N"
@echo ""
@echo "Data:"
@echo " make seed-db - Seed local admin and clone remote user data"
@echo " make clone-user-data - Clone user data from remote to local DB"
@echo ""
@echo "Local stack (Docker Compose: postgres + auth-server + go-api + fast-api + nginx):"
@echo " make up - Start the local stack (hot reload)"
@echo " make up-build - Rebuild images and start"
@echo " make down - Stop the stack (keeps DB data)"
@echo " make down-v - Stop the stack and wipe the DB volume"
@echo " make restart - Restart the stack"
@echo " make logs - Follow stack logs"
@echo " make ps - Show stack service status"
@echo ""
@echo "Development (run frontend on the host alongside the stack):"
@echo " make dev-frontend - Start Next.js frontend (port 3000)"
@echo ""
@echo "Testing:"
@echo " make test-rag - Run Python RAG service tests"
@echo ""
# =============================================================================
# Database
# =============================================================================
db:
@$(MAKE) -C go-api db
wipe:
@$(MAKE) -C go-api wipe
migrate-up:
@doppler run -- $(MAKE) -C go-api migrate-up
migrate-status:
@doppler run -- $(MAKE) -C go-api migrate-status
migrate-to:
@doppler run -- $(MAKE) -C go-api migrate-to $(filter-out $@,$(MAKECMDGOALS))
migrate-force:
@doppler run -- $(MAKE) -C go-api migrate-force $(filter-out $@,$(MAKECMDGOALS))
# =============================================================================
# Data Management
# =============================================================================
# Fail fast with a clear message if the local stack isn't up (seed/clone need it).
require-stack:
@curl -sf -o /dev/null http://localhost:8000/health || \
{ echo "Local stack not reachable on :8000. Run 'make up' first."; exit 1; }
seed-db: require-stack
@doppler run -- env DATABASE_URL="$(LOCAL_DATABASE_URL)" $(MAKE) -C scripts seed-db $(if $(REMOTE_USER_ID),REMOTE_USER_ID="$(REMOTE_USER_ID)",)
clone-user-data: require-stack
@doppler run -- env DATABASE_URL="$(LOCAL_DATABASE_URL)" $(MAKE) -C scripts clone-user-data $(if $(REMOTE_USER_ID),REMOTE_USER_ID="$(REMOTE_USER_ID)",)
# =============================================================================
# Local Stack (Docker Compose)
# =============================================================================
up:
@doppler run -- $(COMPOSE_LOCAL) up
up-build:
@doppler run -- $(COMPOSE_LOCAL) up --build
down:
@$(COMPOSE_LOCAL) down
down-v:
@$(COMPOSE_LOCAL) down -v
restart:
@$(COMPOSE_LOCAL) restart
logs:
@$(COMPOSE_LOCAL) logs -f
ps:
@$(COMPOSE_LOCAL) ps
# =============================================================================
# Development Servers
# =============================================================================
dev-frontend:
@cd frontend && doppler run -- pnpm dev
# Testing
test-rag:
@doppler run -- $(MAKE) -C fast-api test
# Catch-all for targets with arguments (migrate-to, migrate-force)
%:
@: