-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
85 lines (69 loc) · 2.64 KB
/
Makefile
File metadata and controls
85 lines (69 loc) · 2.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
.PHONY: help dev dev-backend dev-frontend build build-backend build-frontend migrate migrate-generate prod down logs lint format
# Project directories
FRONTEND_DIR := web
BACKEND_DIR := core
PROD_COMPOSE_FILE := docker-compose.prod.yml
# Default shell (use bash for trap support)
SHELL := /bin/bash
help:
@echo "Makefile commands:"
@echo " dev - Run backend + frontend for development (Ctrl-C to stop)"
@echo " dev-backend - Run backend development server (bun)"
@echo " dev-frontend - Run frontend development server (pnpm)"
@echo " build - Build backend and frontend for production"
@echo " migrate - Run database migrations (backend)"
@echo " migrate-generate - Generate a new migration (backend)"
@echo " prod - Start production stack via Docker Compose"
@echo " down - Stop the production stack"
@echo " logs - Follow production service logs"
@echo " lint - Run linters (backend & frontend)"
@echo " format - Run formatters (backend & frontend)"
## Development
dev-backend:
@echo "==> Starting backend (in foreground)"
@cd $(BACKEND_DIR) && bun run dev
dev-frontend:
@echo "==> Starting frontend (in foreground)"
@cd $(FRONTEND_DIR) && pnpm dev
# Runs both servers in parallel and traps Ctrl-C to stop both
dev:
@echo "Starting backend and frontend (press Ctrl-C to stop)..."
@cd $(BACKEND_DIR) && bun run dev & BK_PID=$$!; \
cd $(CURDIR)/$(FRONTEND_DIR) && pnpm dev & FG_PID=$$!; \
trap 'echo "Stopping servers..."; kill $$BK_PID $$FG_PID 2>/dev/null || true; exit' INT TERM; \
wait $$BK_PID $$FG_PID
## Build & Packaging
build-backend:
@echo "==> Building backend"
@cd $(BACKEND_DIR) && bun run build
build-frontend:
@echo "==> Building frontend"
@cd $(FRONTEND_DIR) && pnpm build
build: build-backend build-frontend
@echo "Build complete"
## Database
migrate:
@echo "==> Running migrations"
@cd $(BACKEND_DIR) && bun run db:migrate
migrate-generate:
@echo "==> Generating migration (opens editor)"
@cd $(BACKEND_DIR) && bun run db:generate
## Production (Docker Compose)
prod:
@echo "==> Starting production stack (detached)"
@docker compose -f $(PROD_COMPOSE_FILE) up -d
down:
@echo "==> Bringing down production stack"
@docker compose -f $(PROD_COMPOSE_FILE) down
logs:
@echo "==> Following logs"
@docker compose -f $(PROD_COMPOSE_FILE) logs -f
## Quality
lint:
@echo "==> Running linters"
@cd $(BACKEND_DIR) && bun run lint || true
@cd $(FRONTEND_DIR) && pnpm lint || true
format:
@echo "==> Running formatters"
@cd $(BACKEND_DIR) && bun run format || true
@cd $(FRONTEND_DIR) && pnpm format || true