forked from IU-Capstone-Project-2025/Fluently
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile.new
More file actions
176 lines (145 loc) · 6.3 KB
/
Makefile.new
File metadata and controls
176 lines (145 loc) · 6.3 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
# ===========================================
# LOCAL DEVELOPMENT COMMANDS
# ===========================================
# Start all services for local development (no external volumes)
run-local:
docker compose -f docker-compose.yml -f docker-compose.local.yml up -d
# Start core services for local development
run-local-core:
docker compose -f docker-compose.yml -f docker-compose.local.yml up -d postgres backend ml-api nginx
# Build ML API with optimized settings for local development
build-ml-api-local:
docker compose -f docker-compose.yml -f docker-compose.local.yml build ml-api
# Create local volumes (run once before first local start)
setup-local:
docker volume create fluently_pgdata || true
docker volume create fluently_grafana_data || true
docker volume create fluently_prometheus_data || true
docker volume create fluently_sonarqube_data || true
@echo "✅ Local volumes created. You can now run 'make run-local'"
# ===========================================
# DEVELOPMENT COMMANDS
# ===========================================
# Generate Swagger docs and run backend with supporting services
run-backend:
cd backend && swag init --generalInfo cmd/main.go --output docs
docker compose -f docker-compose.yml -f docker-compose.local.yml up -d postgres ml-api directus
cd backend && air
# Run only the telegram bot service
run-telegram-bot:
docker compose up --build -d telegram-bot redis
# Run the ML API service
run-ml-api:
docker compose up --build -d ml-api
# ===========================================
# PRODUCTION COMMANDS (Use external volumes)
# ===========================================
# Start all production services (requires external volumes)
run-production:
docker compose up -d
# Start core services (backend, database, ML API) - production
run-core:
docker compose up -d postgres backend ml-api nginx
# Start monitoring stack
run-monitoring:
docker compose up -d prometheus grafana loki promtail node-exporter nginx-exporter cadvisor
# ===========================================
# TESTING COMMANDS
# ===========================================
# Start test database for GitHub Actions
run-test-db:
docker compose -f docker-compose.test.yml up -d
# Stop test database
stop-test-db:
docker compose -f docker-compose.test.yml down
# ===========================================
# MAINTENANCE COMMANDS
# ===========================================
# Stop all services
stop:
docker compose down
docker compose -f docker-compose.test.yml down
# Stop local development services
stop-local:
docker compose -f docker-compose.yml -f docker-compose.local.yml down
# Clean up all volumes and orphaned containers
clean:
docker compose down --volumes --remove-orphans
docker compose -f docker-compose.test.yml down --volumes --remove-orphans
rm -rf backend/tmp/* || true
rm -rf telegram-bot/tmp/* || true
# Clean up local development environment
clean-local:
docker compose -f docker-compose.yml -f docker-compose.local.yml down --volumes --remove-orphans
docker volume rm fluently_pgdata fluently_grafana_data fluently_prometheus_data fluently_sonarqube_data 2>/dev/null || true
rm -rf backend/tmp/* || true
rm -rf analysis/distractor_api/logs/* || true
# View logs for specific service
logs:
docker compose logs -f $(SERVICE)
# View logs for local development
logs-local:
docker compose -f docker-compose.yml -f docker-compose.local.yml logs -f $(SERVICE)
# Restart specific service
restart:
docker compose restart $(SERVICE)
# Restart local service
restart-local:
docker compose -f docker-compose.yml -f docker-compose.local.yml restart $(SERVICE)
# ===========================================
# DATABASE COMMANDS
# ===========================================
# Access main database
db-shell:
docker compose exec postgres psql -U $(shell grep DB_USER .env | cut -d '=' -f2) -d $(shell grep DB_NAME .env | cut -d '=' -f2)
# Access local database
db-shell-local:
docker compose -f docker-compose.yml -f docker-compose.local.yml exec postgres psql -U $(shell grep DB_USER .env | cut -d '=' -f2) -d $(shell grep DB_NAME .env | cut -d '=' -f2)
# Access test database
test-db-shell:
docker compose -f docker-compose.test.yml exec test-db psql -U test_user -d test_fluently_db
# ===========================================
# HELP
# ===========================================
help:
@echo "Available commands:"
@echo ""
@echo " 🏠 Local Development (Recommended for new users):"
@echo " setup-local - Create local volumes (run once)"
@echo " run-local - Start all services locally (no external volumes)"
@echo " run-local-core - Start core services locally"
@echo " stop-local - Stop local services"
@echo " clean-local - Clean up local environment"
@echo " logs-local - View logs for local services"
@echo " restart-local - Restart local service"
@echo " db-shell-local - Access local database"
@echo ""
@echo " 🔧 Development:"
@echo " run-backend - Start backend with dependencies and air for hot reload"
@echo " run-telegram-bot - Start telegram bot"
@echo " run-ml-api - Start ML API service"
@echo ""
@echo " 🚀 Production (Requires external volumes):"
@echo " run-production - Start all services (production mode)"
@echo " run-core - Start core services (backend, db, ml-api, nginx)"
@echo " run-monitoring - Start monitoring stack"
@echo ""
@echo " 🧪 Testing:"
@echo " run-test-db - Start test database"
@echo " stop-test-db - Stop test database"
@echo ""
@echo " 🛠️ Maintenance:"
@echo " stop - Stop all services"
@echo " clean - Clean up volumes and containers"
@echo " logs SERVICE=<n> - View logs for service"
@echo " restart SERVICE=<n> - Restart service"
@echo ""
@echo " 🗄️ Database:"
@echo " db-shell - Access main database"
@echo " test-db-shell - Access test database"
@echo ""
@echo " 💡 Quick Start for Local Development:"
@echo " make setup-local && make run-local"
@echo ""
@echo " ⚠️ Note: Use 'run-local' commands for development to avoid external volume issues"
.PHONY: help setup-local run-local run-local-core stop-local clean-local logs-local restart-local db-shell-local run-backend run-telegram-bot run-ml-api run-production run-core run-monitoring run-test-db stop-test-db stop clean logs restart db-shell test-db-shell