-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
234 lines (193 loc) · 9.25 KB
/
Makefile
File metadata and controls
234 lines (193 loc) · 9.25 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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# Hackathon Project - Centralized Makefile
# E-commerce Backend + AI Agent + Frontend
.PHONY: help dev-start dev-stop dev-restart dev-clean dev-logs health
# Variables
DOCKER_COMPOSE = docker compose -f docker-compose.dev.yml
POSTGRES_CONTAINER = hackathon-postgres
BACKEND_CONTAINER = hackathon-backend
AGENT_CONTAINER = hackathon-agent
FRONTEND_CONTAINER = hackathon-frontend
INGESTION_CONTAINER = hackathon-ingestion
# Colors for output
CYAN = \033[36m
GREEN = \033[32m
YELLOW = \033[33m
RED = \033[31m
NC = \033[0m # No Color
# Default target
help: ## Show this help message
@echo "$(CYAN)Hackathon Project - Development Environment$(NC)"
@echo ""
@echo "$(GREEN)Available commands:$(NC)"
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " $(CYAN)%-20s$(NC) %s\n", $$1, $$2}' $(MAKEFILE_LIST)
# Development Environment
dev-start: ## Start all services in development mode
@echo "$(GREEN)Starting development environment...$(NC)"
@echo "$(YELLOW)Starting core services (this may take several minutes for TEI model loading)...$(NC)"
$(DOCKER_COMPOSE) up -d --build postgres qdrant tei backend agent frontend search-api
@echo "$(GREEN)Starting data ingestion (will wait for TEI and Qdrant to be ready)...$(NC)"
$(DOCKER_COMPOSE) up --build ingestion
@echo "$(GREEN)✓ All services started and data ingestion completed!$(NC)"
@echo "$(YELLOW)Backend API:$(NC) http://localhost:8080"
@echo "$(YELLOW)AI Agent:$(NC) http://localhost:8081"
@echo "$(YELLOW)Frontend:$(NC) http://localhost:3001"
@echo "$(YELLOW)Qdrant:$(NC) http://localhost:6333"
@echo "$(YELLOW)Search API:$(NC) http://localhost:8083"
dev-start-no-ingestion: ## Start all services without data ingestion
@echo "$(GREEN)Starting development environment (without data ingestion)...$(NC)"
@echo "$(YELLOW)Starting core services (this may take several minutes for TEI model loading)...$(NC)"
$(DOCKER_COMPOSE) up -d --build postgres qdrant tei backend agent frontend search-api
@echo "$(GREEN)✓ All services started successfully!$(NC)"
@echo "$(YELLOW)Backend API:$(NC) http://localhost:8080"
@echo "$(YELLOW)AI Agent:$(NC) http://localhost:8081"
@echo "$(YELLOW)Frontend:$(NC) http://localhost:3001"
@echo "$(YELLOW)Qdrant:$(NC) http://localhost:6333"
@echo "$(YELLOW)Search API:$(NC) http://localhost:8083"
@echo "$(CYAN)Note: To ingest data later, run 'make ingest-data'$(NC)"
dev-stop: ## Stop all services
@echo "$(YELLOW)Stopping all services...$(NC)"
$(DOCKER_COMPOSE) down
@echo "$(GREEN)✓ All services stopped$(NC)"
dev-restart: ## Restart all services
@echo "$(YELLOW)Restarting all services...$(NC)"
$(DOCKER_COMPOSE) restart
@echo "$(GREEN)✓ All services restarted$(NC)"
dev-clean: ## Clean all containers, volumes and networks
@echo "$(RED)Cleaning all Docker resources...$(NC)"
$(DOCKER_COMPOSE) down -v --remove-orphans
docker system prune -f
@echo "$(GREEN)✓ Cleanup completed$(NC)"
# Individual Service Management
start-backend: ## Start only backend services (postgres + api)
@echo "$(GREEN)Starting backend services...$(NC)"
$(DOCKER_COMPOSE) up -d postgres backend
start-agent: ## Start only AI agent
@echo "$(GREEN)Starting AI agent...$(NC)"
$(DOCKER_COMPOSE) up -d agent
start-frontend: ## Start only frontend
@echo "$(GREEN)Starting frontend...$(NC)"
$(DOCKER_COMPOSE) up -d frontend
start-ingestion: ## Start data ingestion process
@echo "$(GREEN)Starting data ingestion...$(NC)"
$(DOCKER_COMPOSE) up --build ingestion
start-tei: ## Start only TEI (Text Embedding Interface) service
@echo "$(GREEN)Starting TEI service...$(NC)"
$(DOCKER_COMPOSE) up -d tei
@echo "$(GREEN)✓ TEI service started successfully!$(NC)"
@echo "$(YELLOW)TEI API:$(NC) http://localhost:8082"
# Logging
logs: ## Show logs for all services
$(DOCKER_COMPOSE) logs -f
logs-backend: ## Show backend API logs
$(DOCKER_COMPOSE) logs -f backend
logs-agent: ## Show AI agent logs
$(DOCKER_COMPOSE) logs -f agent
logs-frontend: ## Show frontend logs
$(DOCKER_COMPOSE) logs -f frontend
logs-db: ## Show PostgreSQL logs
$(DOCKER_COMPOSE) logs -f postgres
logs-ingestion: ## Show data ingestion logs
$(DOCKER_COMPOSE) logs -f ingestion
logs-qdrant: ## Show Qdrant logs
$(DOCKER_COMPOSE) logs -f qdrant
logs-tei: ## Show TEI (Text Embedding Interface) logs
$(DOCKER_COMPOSE) logs -f tei
# Database Operations
db-shell: ## Connect to PostgreSQL shell
@echo "$(CYAN)Connecting to PostgreSQL...$(NC)"
docker exec -it $(POSTGRES_CONTAINER) psql -U postgres -d ecommerce
db-reset: ## Reset database (WARNING: This will delete all data)
@echo "$(RED)⚠️ This will delete all database data!$(NC)"
@read -p "Are you sure? (y/N): " confirm && [ "$$confirm" = "y" ]
$(DOCKER_COMPOSE) down -v
docker volume rm backend_postgres_data 2>/dev/null || true
$(DOCKER_COMPOSE) up -d postgres
@echo "$(GREEN)✓ Database reset completed$(NC)"
# Health Checks
health: ## Check health of all services
@echo "$(CYAN)Checking service health...$(NC)"
@echo ""
@echo "$(YELLOW)PostgreSQL:$(NC)"
@docker exec $(POSTGRES_CONTAINER) pg_isready -U postgres -d ecommerce 2>/dev/null && echo "$(GREEN)✓ Healthy$(NC)" || echo "$(RED)✗ Not Ready$(NC)"
@echo ""
@echo "$(YELLOW)Backend API:$(NC)"
@curl -sf http://localhost:8080/health 2>/dev/null && echo "$(GREEN)✓ Healthy$(NC)" || echo "$(RED)✗ Not Responding$(NC)"
@echo ""
@echo "$(YELLOW)AI Agent:$(NC)"
@curl -sf http://localhost:8081/health 2>/dev/null && echo "$(GREEN)✓ Healthy$(NC)" || echo "$(RED)✗ Not Responding$(NC)"
@echo ""
@echo "$(YELLOW)Frontend:$(NC)"
@curl -sf http://localhost:3001 2>/dev/null >/dev/null && echo "$(GREEN)✓ Healthy$(NC)" || echo "$(RED)✗ Not Responding$(NC)"
@echo ""
@echo "$(YELLOW)Qdrant:$(NC)"
@curl -sf http://localhost:6333/collections 2>/dev/null >/dev/null && echo "$(GREEN)✓ Healthy$(NC)" || echo "$(RED)✗ Not Responding$(NC)"
@echo ""
@echo "$(YELLOW)TEI (Text Embedding):$(NC)"
@curl -sf http://localhost:8082/health 2>/dev/null >/dev/null && echo "$(GREEN)✓ Healthy$(NC)" || echo "$(RED)✗ Not Responding$(NC)"
@echo ""
@echo "$(YELLOW)Search API:$(NC)"
@curl -sf http://localhost:8083/health 2>/dev/null >/dev/null && echo "$(GREEN)✓ Healthy$(NC)" || echo "$(RED)✗ Not Responding$(NC)"
# Development Helpers
rebuild: ## Rebuild and restart all services
@echo "$(YELLOW)Rebuilding all services...$(NC)"
$(DOCKER_COMPOSE) down
$(DOCKER_COMPOSE) up -d --build --force-recreate
@echo "$(GREEN)✓ Rebuild completed$(NC)"
rebuild-backend: ## Rebuild only backend service
@echo "$(YELLOW)Rebuilding backend...$(NC)"
$(DOCKER_COMPOSE) up -d --build --force-recreate backend
rebuild-agent: ## Rebuild only AI agent service
@echo "$(YELLOW)Rebuilding AI agent...$(NC)"
$(DOCKER_COMPOSE) up -d --build --force-recreate agent
rebuild-frontend: ## Rebuild only frontend service
@echo "$(YELLOW)Rebuilding frontend...$(NC)"
$(DOCKER_COMPOSE) up -d --build --force-recreate frontend
rebuild-ingestion: ## Rebuild and run data ingestion
@echo "$(YELLOW)Rebuilding and running data ingestion...$(NC)"
$(DOCKER_COMPOSE) up --build --force-recreate ingestion
rebuild-tei: ## Rebuild only TEI (Text Embedding Interface) service
@echo "$(YELLOW)Rebuilding TEI service...$(NC)"
$(DOCKER_COMPOSE) up -d --build --force-recreate tei
@echo "$(GREEN)✓ TEI service rebuilt and restarted$(NC)"
# Monitoring
status: ## Show status of all containers
@echo "$(CYAN)Container Status:$(NC)"
$(DOCKER_COMPOSE) ps
top: ## Show running processes in containers
$(DOCKER_COMPOSE) top
# Data Management
ingest-data: ## Run data ingestion to Qdrant
@echo "$(GREEN)Starting data ingestion process...$(NC)"
@echo "$(YELLOW)Ensuring Qdrant and TEI are running...$(NC)"
$(DOCKER_COMPOSE) up -d qdrant tei
@echo "$(GREEN)Running data ingestion (will wait for dependencies to be healthy)...$(NC)"
$(DOCKER_COMPOSE) up --build ingestion
@echo "$(GREEN)✓ Data ingestion completed$(NC)"
# Qdrant Search API Management
start-search-api: ## Start Qdrant search and recommendation API
@echo "$(GREEN)Starting Qdrant Search API...$(NC)"
$(DOCKER_COMPOSE) up -d --build search-api
@echo "$(GREEN)✓ Qdrant Search API started successfully!$(NC)"
@echo "$(YELLOW)Search API:$(NC) http://localhost:8083"
@echo "$(YELLOW)API Documentation:$(NC) http://localhost:8083/docs"
stop-search-api: ## Stop Qdrant search API
@echo "$(YELLOW)Stopping Qdrant Search API...$(NC)"
$(DOCKER_COMPOSE) stop search-api
@echo "$(GREEN)✓ Qdrant Search API stopped$(NC)"
restart-search-api: ## Restart Qdrant search API
@echo "$(YELLOW)Restarting Qdrant Search API...$(NC)"
$(DOCKER_COMPOSE) restart search-api
@echo "$(GREEN)✓ Qdrant Search API restarted$(NC)"
restart-tei: ## Restart TEI (Text Embedding Interface) service
@echo "$(YELLOW)Restarting TEI service...$(NC)"
$(DOCKER_COMPOSE) restart tei
@echo "$(GREEN)✓ TEI service restarted$(NC)"
rebuild-search-api: ## Rebuild and restart Qdrant search API
@echo "$(YELLOW)Rebuilding Qdrant Search API...$(NC)"
$(DOCKER_COMPOSE) up -d --build --force-recreate search-api
@echo "$(GREEN)✓ Qdrant Search API rebuilt and restarted$(NC)"
logs-search-api: ## Show Qdrant search API logs
$(DOCKER_COMPOSE) logs -f search-api
check-qdrant: ## Check Qdrant collections and status
@echo "$(CYAN)Checking Qdrant collections...$(NC)"
@curl -s http://localhost:6333/collections | python3 -m json.tool 2>/dev/null || echo "$(RED)Qdrant not responding$(NC)"