-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
107 lines (87 loc) · 2.97 KB
/
Makefile
File metadata and controls
107 lines (87 loc) · 2.97 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
.PHONY: start stop restart build logs clean dev db backend frontend install
# Load .env file if it exists
ifneq (,$(wildcard ./.env))
include .env
export
endif
STATIC_DIR = backend/src/main/resources/static
# Start everything (DB + build frontend into backend + start backend)
start: install build-frontend db-wait backend-start
@echo ""
@echo "GitHub Pulse is running!"
@echo " UI + API: http://localhost:8080"
# Start with separate dev servers (frontend HMR on :3000, backend on :8080)
start-dev: install db-wait backend-start frontend-start
@echo ""
@echo "GitHub Pulse is running in dev mode!"
@echo " Frontend (HMR): http://localhost:3000"
@echo " Backend API: http://localhost:8080"
# Install all dependencies
install: install-backend install-frontend
install-backend:
@echo "Installing backend dependencies..."
cd backend && ./mvnw dependency:resolve -q
install-frontend:
@echo "Installing frontend dependencies..."
cd frontend && npm install --silent
# Build frontend and copy into backend static resources
build-frontend:
@echo "Building frontend..."
cd frontend && npm run build
@echo "Copying frontend build to backend static resources..."
rm -rf $(STATIC_DIR)
mkdir -p $(STATIC_DIR)
cp -r frontend/dist/* $(STATIC_DIR)/
# Database
db:
docker compose up -d postgres
db-wait: db
@echo "Waiting for PostgreSQL..."
@until docker compose exec postgres pg_isready -U github_pulse -q 2>/dev/null; do sleep 1; done
@echo "PostgreSQL is ready."
# Backend (runs in background)
backend-start: db-wait
@echo "Starting backend..."
cd backend && ./mvnw spring-boot:run -q &
@echo "Waiting for backend to be ready..."
@until curl -sf http://localhost:8080/health > /dev/null 2>&1; do sleep 2; done
@echo "Backend is ready."
# Frontend dev server (runs in background)
frontend-start:
@echo "Starting frontend dev server..."
cd frontend && npm run dev &
@sleep 3
@echo "Frontend is ready."
# Stop everything
stop:
@echo "Stopping services..."
-@pkill -f "spring-boot:run" 2>/dev/null || true
-@pkill -f "vite" 2>/dev/null || true
docker compose down
@echo "Clearing any remaining processes on target ports..."
-@lsof -ti :8080 | xargs kill -9 2>/dev/null || true
-@lsof -ti :3000 | xargs kill -9 2>/dev/null || true
-@lsof -ti :5432 | xargs kill -9 2>/dev/null || true
@echo "All services stopped."
# Restart
restart: stop start
# Build for production (single JAR with embedded frontend)
build: install build-frontend
cd backend && ./mvnw package -DskipTests
# Docker Compose (full stack via containers)
up:
docker compose up -d --build
down:
docker compose down
logs:
docker compose logs -f
# Clean build artifacts
clean:
cd backend && ./mvnw clean -q
cd frontend && rm -rf dist node_modules/.vite
rm -rf $(STATIC_DIR)
# Development convenience - just the DB, run backend/frontend manually
dev: db-wait
@echo "PostgreSQL is running on localhost:5432"
@echo "Run backend: cd backend && ./mvnw spring-boot:run"
@echo "Run frontend: cd frontend && npm run dev"