-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
194 lines (167 loc) · 5.64 KB
/
Makefile
File metadata and controls
194 lines (167 loc) · 5.64 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
.PHONY: help setup up down restart logs dev test test-watch lint format typecheck build clean generate db-extensions db-migrate db-studio db-push db-reset docker-clean all
# Default target - show help
help:
@echo "🚀 Fastify Gold Standard Starter - Make Commands"
@echo ""
@echo "⚡ Quick Start:"
@echo " make up - 🎯 Start everything (Docker + DB + migrations)"
@echo " make dev - Start development server"
@echo " make test-api - Test API with authentication (requires server running)"
@echo " make grafana - Open Grafana dashboard"
@echo " make down - Stop all services"
@echo ""
@echo "📦 Setup & Installation:"
@echo " make setup - Initial project setup (run once)"
@echo " make install - Install dependencies only"
@echo ""
@echo "🐳 Docker Services:"
@echo " make docker-up - Start Docker services only"
@echo " make restart - Restart all Docker services"
@echo " make logs - View Docker logs"
@echo ""
@echo "🚀 Development:"
@echo " make dev - Start development server"
@echo " make build - Build for production"
@echo ""
@echo "🧪 Testing & Quality:"
@echo " make test - Run all tests"
@echo " make test-watch - Run tests in watch mode"
@echo " make lint - Run ESLint"
@echo " make format - Format code with Prettier"
@echo " make typecheck - Run TypeScript type checking"
@echo ""
@echo "🗄️ Database:"
@echo " make db-extensions - Install PostgreSQL extensions (pgvector, etc.)"
@echo " make db-migrate - Run Prisma migrations"
@echo " make db-studio - Open Prisma Studio"
@echo " make db-push - Push schema changes"
@echo " make db-reset - Reset database (WARNING: destructive)"
@echo ""
@echo "🎨 Generators:"
@echo " make generate - Generate service (interactive)"
@echo " make dashboards - Generate Grafana dashboards"
@echo ""
@echo "🧹 Cleanup:"
@echo " make clean - Remove build artifacts"
@echo " make docker-clean - Remove Docker volumes (WARNING: destructive)"
@echo ""
@echo "⚡ Quick Combos:"
@echo " make all - setup + up + db-migrate + dev"
@echo ""
# Initial setup (run once)
setup:
@echo "🚀 Running initial setup..."
@./setup.sh
# Install dependencies
install:
@echo "📦 Installing dependencies..."
@npm install
# Docker commands
docker-up:
@echo "🐳 Starting Docker services..."
@npm run docker:up
down:
@echo "🛑 Stopping Docker services..."
@npm run docker:down
restart: down docker-up
logs:
@echo "📜 Showing Docker logs..."
@npm run docker:logs
# Initialize PostgreSQL extensions (required for pgvector, etc.)
db-extensions:
@echo "🔌 Ensuring PostgreSQL extensions are installed..."
@docker exec driftos_postgres psql -U postgres -d driftos_core -c 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; CREATE EXTENSION IF NOT EXISTS "pgcrypto"; CREATE EXTENSION IF NOT EXISTS "vector";' 2>/dev/null || true
# Main entry point - like DriftOS!
up: docker-up
@echo "⏳ Waiting for PostgreSQL to be ready..."
@sleep 8
@$(MAKE) db-extensions
@echo "🗄️ Pushing database schema..."
@npm run db:push
@echo "📊 Generating Grafana dashboards..."
@npm run generate:dashboards || echo "⚠️ No orchestrators found yet"
@echo ""
@echo "✨ Everything is ready!"
@echo ""
@echo "📍 Services running:"
@echo " • API: http://localhost:$${PORT:-3000}"
@echo " • Swagger: http://localhost:$${PORT:-3000}/documentation"
@echo " • Prometheus: http://localhost:$${PROMETHEUS_PORT:-9091}"
@echo " • Grafana: http://localhost:$${GRAFANA_PORT:-3010} (admin/admin)"
@echo ""
@echo "🚀 Start the dev server in another terminal:"
@echo " make dev"
@echo ""
@echo "Or open Grafana:"
@echo " make grafana"
@echo ""
# Open Grafana in browser
grafana:
@echo "🎨 Opening Grafana..."
@open http://localhost:$${GRAFANA_PORT:-3010} || xdg-open http://localhost:$${GRAFANA_PORT:-3010} || echo "Open http://localhost:$${GRAFANA_PORT:-3010} in your browser"
# Test the API with authentication
test-api:
@echo "🧪 Testing API endpoints..."
@./scripts/test-api.sh
# Development
dev:
@echo "🚀 Starting development server..."
@npm run dev
build:
@echo "🔨 Building for production..."
@npm run build
# Testing & Quality
test:
@echo "🧪 Running tests..."
@npm test
test-watch:
@echo "👀 Running tests in watch mode..."
@npm run test:watch
lint:
@echo "🔍 Running ESLint..."
@npm run lint
format:
@echo "✨ Formatting code..."
@npm run format
typecheck:
@echo "📝 Type checking..."
@npm run typecheck
# Database
db-migrate:
@echo "🗄️ Running database migrations..."
@npm run db:migrate
db-studio:
@echo "🎨 Opening Prisma Studio..."
@npm run db:studio
db-push:
@echo "⬆️ Pushing schema changes..."
@npm run db:push
db-reset:
@echo "⚠️ WARNING: This will delete all data!"
@read -p "Are you sure? [y/N] " -n 1 -r; \
echo; \
if [[ $$REPLY =~ ^[Yy]$$ ]]; then \
npx prisma migrate reset --force; \
fi
# Generators
generate:
@echo "🎨 Running service generator..."
@npm run generate
dashboards:
@echo "📊 Generating Grafana dashboards..."
@npm run generate:dashboards
# Cleanup
clean:
@echo "🧹 Cleaning build artifacts..."
@rm -rf dist node_modules/.cache
docker-clean:
@echo "⚠️ WARNING: This will delete all Docker volumes!"
@read -p "Are you sure? [y/N] " -n 1 -r; \
echo; \
if [[ $$REPLY =~ ^[Yy]$$ ]]; then \
docker-compose -f docker/docker-compose.yml down -v; \
fi
# Quick all-in-one
all: setup up db-migrate
@echo ""
@echo "✅ All set! Run 'make dev' to start the server"