-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
184 lines (145 loc) · 6.15 KB
/
Makefile
File metadata and controls
184 lines (145 loc) · 6.15 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
# ============================================================================
# DAFU - Data Analytics Functional Utilities
# Makefile for Common Operations
# ============================================================================
.PHONY: help start stop restart logs status clean rebuild test
# Default target
.DEFAULT_GOAL := help
# Colors
BLUE := \033[0;34m
GREEN := \033[0;32m
YELLOW := \033[1;33m
NC := \033[0m
##@ General
help: ## Display this help message
@echo "$(BLUE)"
@echo "============================================================"
@echo " DAFU - Data Analytics Functional Utilities"
@echo " Available Commands"
@echo "============================================================"
@echo "$(NC)"
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make $(GREEN)<target>$(NC)\n"} /^[a-zA-Z_-]+:.*?##/ { printf " $(GREEN)%-15s$(NC) %s\n", $$1, $$2 } /^##@/ { printf "\n$(BLUE)%s$(NC)\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
##@ Docker Operations
start: ## Start all services with docker-compose
@echo "$(BLUE)Starting DAFU platform...$(NC)"
@chmod +x start.sh
@./start.sh up
start-tools: ## Start all services including management tools
@echo "$(BLUE)Starting DAFU platform with tools...$(NC)"
@chmod +x start.sh
@./start.sh up tools
stop: ## Stop all services
@echo "$(YELLOW)Stopping all services...$(NC)"
@docker-compose down
@echo "$(GREEN)✓ Services stopped$(NC)"
restart: ## Restart all services
@echo "$(BLUE)Restarting all services...$(NC)"
@docker-compose restart
@echo "$(GREEN)✓ Services restarted$(NC)"
rebuild: ## Rebuild and restart all services
@echo "$(BLUE)Rebuilding services...$(NC)"
@docker-compose down
@docker-compose up -d --build
@echo "$(GREEN)✓ Services rebuilt$(NC)"
clean: ## Remove all containers and volumes (DESTRUCTIVE)
@echo "$(YELLOW)Warning: This will remove all data!$(NC)"
@read -p "Are you sure? [y/N] " -n 1 -r; \
echo; \
if [[ $$REPLY =~ ^[Yy]$$ ]]; then \
docker-compose down -v; \
echo "$(GREEN)✓ Cleaned$(NC)"; \
fi
##@ Monitoring & Logs
logs: ## View logs from all services
@docker-compose logs -f
logs-api: ## View API logs only
@docker-compose logs -f fraud-detection-api
logs-db: ## View database logs only
@docker-compose logs -f postgres
logs-celery: ## View Celery worker logs only
@docker-compose logs -f celery-worker
status: ## Show status of all services
@docker-compose ps
health: ## Check health of all services
@echo "$(BLUE)Checking service health...$(NC)"
@curl -s http://localhost:8000/health | python3 -m json.tool || echo "$(YELLOW)API not responding$(NC)"
##@ Development
shell-api: ## Open shell in API container
@docker-compose exec fraud-detection-api bash
shell-db: ## Open PostgreSQL shell
@docker-compose exec postgres psql -U dafu -d dafu
shell-redis: ## Open Redis CLI
@docker-compose exec redis redis-cli
test: ## Run tests in API container
@docker-compose exec fraud-detection-api pytest tests/ -v
lint: ## Run linting in API container
@docker-compose exec fraud-detection-api black src/ tests/
@docker-compose exec fraud-detection-api flake8 src/ tests/
##@ Database
db-migrate: ## Run database migrations
@docker-compose exec fraud-detection-api alembic upgrade head
db-backup: ## Backup PostgreSQL database
@echo "$(BLUE)Backing up database...$(NC)"
@mkdir -p backups
@docker-compose exec -T postgres pg_dump -U dafu dafu > backups/backup_$$(date +%Y%m%d_%H%M%S).sql
@echo "$(GREEN)✓ Database backed up to backups/$(NC)"
db-restore: ## Restore PostgreSQL database (provide BACKUP=filename)
@echo "$(YELLOW)Restoring database from $(BACKUP)...$(NC)"
@docker-compose exec -T postgres psql -U dafu dafu < $(BACKUP)
@echo "$(GREEN)✓ Database restored$(NC)"
##@ Setup
setup: ## Initial setup - create .env (Docker services commented out)
@echo "$(YELLOW)============================================================$(NC)"
@echo "$(YELLOW) ⚠️ Docker Services Are Currently Commented Out$(NC)"
@echo "$(YELLOW)============================================================$(NC)"
@echo ""
@echo "$(RED)All services in docker-compose.yml are commented out.$(NC)"
@echo ""
@echo "$(GREEN)To use DAFU ML models NOW:$(NC)"
@echo " cd dafu"
@echo " python3 -m venv venv"
@echo " source venv/bin/activate"
@echo " pip install -r requirements.txt"
@echo " cd core/features/fraud_detection/src/models"
@echo " python main.py"
@echo ""
@echo "$(YELLOW)Docker services will be activated after API-ML integration.$(NC)"
@echo "See DOCKER_STATUS.md for details."
@echo ""
##@ Monitoring
open-api: ## Open API documentation in browser
@open http://localhost:8000/docs || xdg-open http://localhost:8000/docs || echo "Open http://localhost:8000/docs"
open-grafana: ## Open Grafana in browser
@open http://localhost:3000 || xdg-open http://localhost:3000 || echo "Open http://localhost:3000"
open-prometheus: ## Open Prometheus in browser
@open http://localhost:9090 || xdg-open http://localhost:9090 || echo "Open http://localhost:9090"
open-rabbitmq: ## Open RabbitMQ management in browser
@open http://localhost:15672 || xdg-open http://localhost:15672 || echo "Open http://localhost:15672"
##@ Documentation
docs: ## Display quick reference
@echo "$(BLUE)"
@echo "============================================================"
@echo " DAFU Quick Reference"
@echo "============================================================"
@echo "$(NC)"
@echo "$(YELLOW)⚠️ Docker services are commented out$(NC)"
@echo ""
@echo "$(GREEN)Use ML models NOW (no Docker needed):$(NC)"
@echo " cd dafu"
@echo " python3 -m venv venv && source venv/bin/activate"
@echo " pip install -r requirements.txt"
@echo " cd core/features/fraud_detection/src/models && python main.py"
@echo ""
@echo "$(BLUE)Future Service URLs (when Docker is active):$(NC)"
@echo " API Documentation: http://localhost:8000/docs"
@echo " Grafana: http://localhost:3000"
@echo " Prometheus: http://localhost:9090"
@echo ""
@echo "For full help: make help"
@echo "For Docker status: cat DOCKER_STATUS.md"
version: ## Display version information
@echo "DAFU Platform v1.0.0"
@echo "Docker version:"
@docker --version
@echo "Docker Compose version:"
@docker-compose --version