-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
319 lines (278 loc) · 13.7 KB
/
Makefile
File metadata and controls
319 lines (278 loc) · 13.7 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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
.PHONY: help start stop restart logs build build-clean clean clean-images clean-build-cache clobber \
dev dev-rebuild dev-groq dev-groq-stop dev-groq-logs dev-groq-rebuild \
health status urls \
pull-model list-models backup-models \
shell-backend shell-frontend shell-ollama \
start-ollama start-backend start-frontend rebuild-frontend \
lint lint-frontend lint-backend format dev-setup \
reset
# Default target
.DEFAULT_GOAL := help
# Colors for output
GREEN=\033[0;32m
YELLOW=\033[1;33m
BLUE=\033[0;34m
RED=\033[0;31m
NC=\033[0m # No Color
PROJECT_NAME=ats-buddy
# Docker Compose file variables
NETWORK_COMPOSE=compose.network.yaml
OLLAMA_COMPOSE=compose.ollama.yaml
BACKEND_COMPOSE=compose.backend.yaml
FRONTEND_COMPOSE=compose.frontend.yaml
DEV_COMPOSE=compose.dev.yaml
DEV_GROQ_COMPOSE=compose.dev-groq.yaml
# Compose stack combinations
FULL_STACK=$(NETWORK_COMPOSE) -f $(OLLAMA_COMPOSE) -f $(BACKEND_COMPOSE) -f $(FRONTEND_COMPOSE)
OLLAMA_ONLY=$(NETWORK_COMPOSE) -f $(OLLAMA_COMPOSE)
BACKEND_ONLY=$(NETWORK_COMPOSE) -f $(BACKEND_COMPOSE)
FRONTEND_ONLY=$(NETWORK_COMPOSE) -f $(FRONTEND_COMPOSE)
help:
@echo "$(BLUE)ATS-Buddy: AI-powered resume optimizer$(NC)"
@echo ""
@echo "$(YELLOW)🚀 Quick Start:$(NC)"
@echo " $(GREEN)make dev-setup$(NC) Set up development environment"
@echo " $(GREEN)make dev-groq$(NC) Development with Groq API (recommended)"
@echo " $(GREEN)make start$(NC) Full setup with local AI models"
@echo ""
@echo "$(YELLOW)📋 Development Commands:$(NC)"
@awk 'BEGIN {FS = ":.*?## "} /^(dev|quick-|start-|rebuild-).*:.*?## / {printf " $(GREEN)%-18s$(NC) %s\n", $$1, $$2}' $(MAKEFILE_LIST)
@echo ""
@echo "$(YELLOW)🏗️ Build & Deploy:$(NC)"
@awk 'BEGIN {FS = ":.*?## "} /^(start|stop|restart|build|logs|status).*:.*?## / {printf " $(GREEN)%-18s$(NC) %s\n", $$1, $$2}' $(MAKEFILE_LIST)
@echo ""
@echo "$(YELLOW)🧹 Cleanup & Maintenance:$(NC)"
@awk 'BEGIN {FS = ":.*?## "} /^(clean|clobber|reset|backup-).*:.*?## / {printf " $(GREEN)%-18s$(NC) %s\n", $$1, $$2}' $(MAKEFILE_LIST)
@echo ""
@echo "$(YELLOW)🛠️ Utilities:$(NC)"
@awk 'BEGIN {FS = ":.*?## "} /^(health|urls|shell-|pull-|list-|lint|format|dev-setup).*:.*?## / {printf " $(GREEN)%-18s$(NC) %s\n", $$1, $$2}' $(MAKEFILE_LIST)
start: ## Start all services in production mode
@echo "$(BLUE)🚀 Starting ATS-Buddy...$(NC)"
docker compose -f $(FULL_STACK) up -d --build
@echo "$(GREEN)✅ Services starting up...$(NC)"
@echo "$(YELLOW)⏳ Waiting for services to be ready...$(NC)"
@sleep 15
@make health
@echo "$(BLUE)🧠 Setting up AI model...$(NC)"
@make pull-model || echo "$(YELLOW)⚠️ AI model download failed - you can run 'make pull-model' later$(NC)"
@echo "$(GREEN)🎉 ATS-Buddy is ready!$(NC)"
@make urls
stop: ## Stop all services
@echo "$(YELLOW)🛑 Stopping all services...$(NC)"
docker compose -f $(FULL_STACK) down
@echo "$(GREEN)✅ All services stopped$(NC)"
restart: ## Restart all services
@echo "$(YELLOW)🔄 Restarting all services...$(NC)"
docker compose -f $(FULL_STACK) restart
@echo "$(GREEN)✅ Services restarted$(NC)"
logs: ## Show logs from all services
@echo "$(BLUE)📋 Showing logs (Press Ctrl+C to exit)...$(NC)"
docker compose -f $(FULL_STACK) logs -f
build: ## Build all Docker images
@echo "$(BLUE)🔨 Building all Docker images...$(NC)"
docker compose -f $(FULL_STACK) build --no-cache
@echo "$(GREEN)✅ All images built$(NC)"
build-clean: ## Build all images and clean up dangling images afterward
@echo "$(BLUE)🔨 Building all Docker images with cleanup...$(NC)"
docker compose -f $(FULL_STACK) build --no-cache
@make clean-images
@echo "$(GREEN)✅ All images built and cleaned up$(NC)"
clean: ## Stop services and remove containers, networks, and volumes
@echo "$(RED)🧹 Cleaning up everything (including AI models)...$(NC)"
@echo "$(YELLOW)This will remove downloaded AI models. Continue? [y/N]$(NC)"
@read -r REPLY; \
if [ "$$REPLY" = "y" ] || [ "$$REPLY" = "Y" ]; then \
docker compose -f $(FULL_STACK) down -v --remove-orphans; \
docker system prune -f; \
echo "$(GREEN)✅ Cleanup complete$(NC)"; \
else \
echo "$(YELLOW)Cleanup cancelled$(NC)"; \
fi
clean-images: ## Remove dangling Docker images (tagged as <none>)
@echo "$(BLUE)🧹 Cleaning up dangling Docker images...$(NC)"
@if [ -n "$$(docker images -q --filter 'dangling=true')" ]; then \
docker rmi $$(docker images -q --filter 'dangling=true'); \
echo "$(GREEN)✅ Dangling images cleaned up$(NC)"; \
else \
echo "$(YELLOW)No dangling images found$(NC)"; \
fi
clean-build-cache: ## Clear Docker build cache
@echo "$(BLUE)🧹 Clearing Docker build cache...$(NC)"
docker builder prune -f
@echo "$(GREEN)✅ Build cache cleared$(NC)"
clobber: ## Remove ALL Docker containers, images, volumes, networks, and cache
@echo "$(RED)☢️ This will remove EVERYTHING Docker-related$(NC)"
@echo "$(RED)⚠️ This includes containers, images, volumes, networks from ALL projects!$(NC)"
@echo "$(YELLOW)Are you absolutely sure? This cannot be undone! [y/N]$(NC)"
@read -r REPLY; \
if [ "$$REPLY" = "y" ] || [ "$$REPLY" = "Y" ]; then \
echo "$(RED)🚀 Starting full cleanup...$(NC)"; \
echo "$(BLUE)1 - Stopping and removing all containers...$(NC)"; \
docker ps -a -q | xargs -r docker stop 2>/dev/null || true; \
docker ps -a -q | xargs -r docker rm -f 2>/dev/null || true; \
echo "$(BLUE)2 - Removing all images...$(NC)"; \
docker images -a -q | xargs -r docker rmi -f 2>/dev/null || true; \
echo "$(BLUE)3 - Removing all volumes...$(NC)"; \
docker volume ls -q | xargs -r docker volume rm -f 2>/dev/null || true; \
echo "$(BLUE)4 - Pruning networks...$(NC)"; \
docker network prune -f 2>/dev/null || true; \
echo "$(BLUE)5 - Clearing all build cache...$(NC)"; \
yes | docker buildx prune -a 2>/dev/null || true; \
echo "$(GREEN)☢️ Cleanup complete! All Docker resources destroyed$(NC)"; \
else \
echo "$(YELLOW)Cleanup cancelled$(NC)"; \
fi
dev: ## Start all services in development mode (with hot reload)
@echo "$(BLUE)🚀 Starting in development mode...$(NC)"
@echo "$(YELLOW)This includes Ollama for local AI processing$(NC)"
docker compose -f $(DEV_COMPOSE) up -d --build
@echo "$(GREEN)✅ Development services started$(NC)"
@echo "$(YELLOW)Full AI stack with local Ollama models$(NC)"
@echo "$(BLUE)Frontend: http://localhost:3000$(NC)"
@echo "$(BLUE)Backend: http://localhost:8000$(NC)"
@echo "$(BLUE)Ollama: http://localhost:11434$(NC)"
health: ## Check health of all services
@echo "$(BLUE)🏥 Checking service health...$(NC)"
@echo ""
@echo "$(YELLOW)Ollama:$(NC)"
@curl -s http://localhost:11434/api/tags > /dev/null && echo "$(GREEN)✅ Ollama is running$(NC)" || echo "$(RED)❌ Ollama is not responding$(NC)"
@echo ""
@echo "$(YELLOW)Backend:$(NC)"
@curl -s http://localhost:8000/health > /dev/null && echo "$(GREEN)✅ Backend is running$(NC)" || echo "$(RED)❌ Backend is not responding$(NC)"
@echo ""
@echo "$(YELLOW)Frontend:$(NC)"
@curl -s http://localhost:3000 > /dev/null && echo "$(GREEN)✅ Frontend is running$(NC)" || echo "$(RED)❌ Frontend is not responding$(NC)"
status: ## Show status of all containers
@echo "$(BLUE)📊 Container Status:$(NC)"
@docker compose -f $(FULL_STACK) ps
pull-model: ## Download/update the AI model (llama3.2)
@echo "$(BLUE)🧠 Downloading llama3.2 model...$(NC)"
@echo "$(YELLOW)🪑This may take a while depending on your internet connection$(NC)"
docker exec $(PROJECT_NAME)-ollama ollama pull llama3.2
@echo "$(GREEN)✅ Model downloaded successfully$(NC)"
list-models: ## List available AI models
@echo "$(BLUE)🧠 Available AI models:$(NC)"
docker exec $(PROJECT_NAME)-ollama ollama list
shell-backend: ## Open shell in backend container
@echo "$(BLUE)🐚 Opening shell in backend container...$(NC)"
docker exec -it $(PROJECT_NAME)-backend /bin/bash
shell-frontend: ## Open shell in frontend container
@echo "$(BLUE)🐚 Opening shell in frontend container...$(NC)"
docker exec -it $(PROJECT_NAME)-frontend /bin/sh
shell-ollama: ## Open shell in Ollama container
@echo "$(BLUE)🐚 Opening shell in Ollama container...$(NC)"
docker exec -it $(PROJECT_NAME)-ollama /bin/bash
dev-rebuild: ## Rebuild and restart all local development services
@echo "$(BLUE)🔄 Rebuilding development services...$(NC)"
docker compose -f $(FULL_STACK) up -d --build
@make clean-images
@echo "$(GREEN)✅ Development services rebuilt$(NC)"
backup-models: ## Backup AI models to local directory
@echo "$(BLUE)💾 Backing up AI models...$(NC)"
mkdir -p ./backups
docker run --rm -v ats-buddy_ollama_data:/data -v $(PWD)/backups:/backup alpine tar czf /backup/ollama-models-$$(date +%Y%m%d-%H%M%S).tar.gz -C /data .
@echo "$(GREEN)✅ Models backed up to ./backups/$(NC)"
reset: ## Reset everything (stop, clean, and restart)
@echo "$(RED)🔄 Full reset - this will remove all data$(NC)"
@echo "$(YELLOW)Continue? [y/N]$(NC)"
@read -r REPLY; \
if [ "$$REPLY" = "y" ] || [ "$$REPLY" = "Y" ]; then \
make clean; \
make start; \
else \
echo "$(YELLOW)Reset cancelled$(NC)"; \
fi
urls: ## Show all service URLs
@echo "$(BLUE)🌐 Service URLs:$(NC)"
@echo "$(GREEN)Frontend: $(NC)http://localhost:3000"
@echo "$(GREEN)Backend API: $(NC)http://localhost:8000"
@echo "$(GREEN)API Docs: $(NC)http://localhost:8000/docs"
@echo "$(GREEN)Ollama: $(NC)http://localhost:11434"
dev-groq: ## Start lightweight development setup (frontend + backend only, optimized for Groq API)
@echo "$(BLUE)⚡ Starting Groq-optimized development setup...$(NC)"
docker compose -f $(DEV_GROQ_COMPOSE) up -d --build --remove-orphans
@echo "$(GREEN)✅ Lightweight development services started with hot reload$(NC)"
@echo ""
@echo "$(BLUE)🌐 Service URLs:$(NC)"
@echo "$(GREEN)Frontend: $(NC)http://localhost:3000"
@echo "$(GREEN)Backend API: $(NC)http://localhost:8000"
@echo "$(GREEN)API Docs: $(NC)http://localhost:8000/docs"
dev-groq-stop: ## Stop Groq development services
@echo "$(YELLOW)🛑 Stopping Groq development services...$(NC)"
docker compose -f $(DEV_GROQ_COMPOSE) down
@echo "$(GREEN)✅ Groq development services stopped$(NC)"
dev-groq-logs: ## Show logs from Groq development services
@echo "$(BLUE)📋 Showing Groq dev logs (Press Ctrl+C to exit)...$(NC)"
docker compose -f $(DEV_GROQ_COMPOSE) logs -f
dev-groq-rebuild: ## Rebuild and restart Groq development services
@echo "$(BLUE)🔄 Rebuilding Groq development services...$(NC)"
docker compose -f $(DEV_GROQ_COMPOSE) up -d --build
@make clean-images
@echo "$(GREEN)✅ Groq development services rebuilt$(NC)"
start-ollama: ## Start only Ollama service
@echo "$(BLUE)🧠 Starting Ollama service...$(NC)"
docker compose -f $(OLLAMA_ONLY) up -d
@echo "$(GREEN)✅ Ollama service started$(NC)"
start-backend: ## Start only backend service
@echo "$(BLUE)⚙️ Starting backend service...$(NC)"
docker compose -f $(BACKEND_ONLY) up -d --build
@echo "$(GREEN)✅ Backend service started$(NC)"
start-frontend: ## Start only frontend service
@echo "$(BLUE)🌐 Starting frontend service...$(NC)"
docker compose -f $(FRONTEND_ONLY) up -d --build
@echo "$(GREEN)✅ Frontend service started$(NC)"
rebuild-frontend: ## Rebuild and restart only the frontend service
@echo "$(BLUE)🌐 Rebuilding frontend service...$(NC)"
docker compose -f $(FRONTEND_ONLY) build
docker compose -f $(FRONTEND_ONLY) up -d --force-recreate
@echo "$(GREEN)✅ Frontend service rebuilt$(NC)"
lint: lint-frontend lint-backend ## Run linting on both frontend and backend
lint-frontend: ## Run frontend linting (ESLint + Prettier check)
@echo "$(BLUE)🎨 Running frontend linting...$(NC)"
cd frontend && npm run lint:check
cd frontend && npm run format:check
cd frontend && npm run type-check
@echo "$(GREEN)✅ Frontend linting passed$(NC)"
lint-backend: ## Run backend linting (Black, flake8, mypy)
@echo "$(BLUE)🐍 Running backend linting...$(NC)"
cd backend && black --check .
cd backend && flake8 .
cd backend && mypy . --ignore-missing-imports || echo "$(YELLOW)⚠️ MyPy completed with warnings$(NC)"
@echo "$(GREEN)✅ Backend linting passed$(NC)"
format: ## Auto-fix formatting issues in both frontend and backend
@echo "$(BLUE)🔧 Auto-fixing formatting issues...$(NC)"
@echo "$(YELLOW)Frontend:$(NC)"
cd frontend && npm run lint
cd frontend && npm run format
@echo "$(YELLOW)Backend:$(NC)"
cd backend && python3 -m black . || black .
@echo "$(GREEN)✅ All formatting issues fixed$(NC)"
dev-setup: ## Set up local development tools (linting, formatting, pre-commit hooks)
@echo "$(BLUE)🛠️ Setting up local development tools...$(NC)"
@echo "$(YELLOW)Note: Application runs in Docker - this only installs linting tools$(NC)"
@echo ""
@echo "$(YELLOW)1. Installing pre-commit hooks (Husky)...$(NC)"
npm install
@echo ""
@echo "$(YELLOW)2. Installing frontend linting tools...$(NC)"
cd frontend && npm install --only=dev
@echo ""
@echo "$(YELLOW)3. Installing Python linting tools (using pipx)...$(NC)"
@command -v pipx >/dev/null 2>&1 || (echo "$(YELLOW)Installing pipx first...$(NC)" && brew install pipx)
@echo "$(YELLOW)Ensuring pipx PATH is configured...$(NC)"
@pipx ensurepath --quiet 2>/dev/null || true
@echo "$(YELLOW)Installing/updating Python tools...$(NC)"
@pipx install black --force --quiet || pipx install black --quiet
@pipx install flake8 --force --quiet || pipx install flake8 --quiet
@pipx install mypy --force --quiet || pipx install mypy --quiet
@echo ""
@echo "$(YELLOW)4. Setting up pre-commit hooks...$(NC)"
npx husky install
@echo ""
@echo "$(GREEN)✅ Development tools setup complete!$(NC)"
@echo ""
@echo "$(BLUE)🎯 Next steps:$(NC)"
@echo " $(GREEN)make dev-groq$(NC) Start development (Groq API)"
@echo " $(GREEN)make dev$(NC) Start development (local AI)"
@echo " $(GREEN)make lint$(NC) Check code quality"
@echo " $(GREEN)make format$(NC) Fix formatting issues"