-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
152 lines (118 loc) · 5.21 KB
/
Makefile
File metadata and controls
152 lines (118 loc) · 5.21 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
# ==============================================================================
# PurpleOPS BAS - Makefile
# ==============================================================================
# Descrição: Automação de tarefas comuns do projeto
# Autor: Mauro Risonho de Paula Assumpção
# Data Criação: 2024-01-01
# Data Alteração: 2026-01-06
# Descrição Detalhada:
# - Comandos para setup, build, deploy
# - Gestão de containers e serviços
# - Execução de testes e validações
# Licença: MIT
# ==============================================================================
.PHONY: help setup start stop restart logs clean build test test-ml migrate run validate logs-backend logs-orchestrator logs-frontend logs-postgres ps dev rebuild quick status health shell-backend shell-postgres backup-db restore-db deploy docker-build
help: ## Show this help
@echo "PurpleOPS BAS - Available Commands"
@echo "================================"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
setup: ## Initial setup (run once)
@./scripts/setup.sh
start: ## Start all services
@docker compose up -d
@echo " Services started. Access: http://localhost:8080"
run: start ## Alias for start
stop: ## Stop all services
@docker compose down
restart: ## Restart all services
@docker compose restart
logs: ## View logs (use CTRL+C to exit)
@docker compose logs -f
clean: ## Stop and remove all containers, volumes, and images
@echo "⚠️ This will delete all data. Press CTRL+C to cancel, or wait 5 seconds..."
@sleep 5
@docker compose down -v --remove-orphans
@docker rmi purpleops-bas-backend purpleops-bas-orchestrator purpleops-bas-frontend 2>/dev/null || true
@echo " Cleaned up"
build: ## Rebuild all Docker images
@docker compose build --no-cache
test: ## Run tests (TODO: implement tests)
@echo "Running tests..."
@cd backend && clj -M:test || echo "Tests not yet implemented"
migrate: ## Run database migrations
@./scripts/migrate.sh
quick: ## Quick start (build and run)
@./scripts/quick-start.sh
status: ## Show service status
@docker compose ps
health: ## Check service health
@echo "Backend Health:"
@curl -s http://localhost:3000/health | jq . || echo "❌ Backend not responding"
@echo ""
@echo "Frontend:"
@curl -s -o /dev/null -w "Status: %{http_code}\n" http://localhost:8080 || echo "❌ Frontend not responding"
shell-backend: ## Open shell in backend container
@docker compose exec backend sh
shell-postgres: ## Open psql shell
@docker compose exec postgres psql -U purpleops -d purpleops_bas
backup-db: ## Backup database
@docker compose exec postgres pg_dump -U purpleops purpleops_bas > backup-$(shell date +%Y%m%d-%H%M%S).sql
@echo " Database backed up"
restore-db: ## Restore database from backup (use: make restore-db FILE=backup.sql)
@docker compose exec -T postgres psql -U purpleops -d purpleops_bas < $(FILE)
@echo " Database restored"
validate: ## Validate deployment
@./scripts/validate.sh
logs-backend: ## View backend logs
@docker compose logs -f backend
logs-orchestrator: ## View orchestrator logs
@docker compose logs -f orchestrator
logs-frontend: ## View frontend logs
@docker compose logs -f frontend
logs-postgres: ## View postgres logs
@docker compose logs -f postgres
ps: status ## Alias for status
dev: ## Start in development mode (with logs)
@docker compose up
rebuild: clean build run ## Clean rebuild everything
# ==============================================================================
# Machine Learning Module - New Commands
# ==============================================================================
test-ml: ## Run ML module tests
@echo "🧪 Running ML module tests..."
@clojure -X:test/ml
@echo " ML tests completed"
test-unit: ## Run all unit tests
@echo "🧪 Running unit tests..."
@clojure -X:test
@echo " Unit tests completed"
docker-build: ## Build Docker backend image
@echo "🐳 Building Docker image..."
@docker build -f infra/Dockerfile.backend -t purpleops/backend:latest .
@echo " Docker image built: purpleops/backend:latest"
deploy: test-ml test docker-build ## Full deployment (tests + docker build)
@echo " Deployment ready!"
@echo " Backend JAR: target/purpleops-backend.jar"
@echo " Docker image: purpleops/backend:latest"
ml-info: ## Show ML module information
@echo " PurpleOPS BAS - Machine Learning Module"
@echo "========================================"
@echo "Modules: 10"
@echo " - matrix.clj (matrix operations)"
@echo " - regression.clj (regression algorithms)"
@echo " - classification.clj (classification)"
@echo " - neural.clj (neural networks)"
@echo " - svm.clj (SVM classifiers)"
@echo " - clustering.clj (clustering)"
@echo " - anomaly.clj (anomaly detection)"
@echo " - evaluation.clj (model evaluation)"
@echo " - largescale.clj (distributed ML)"
@echo " - core.clj (unified API)"
@echo ""
@echo "Algorithms: 45+"
@echo "Lines of Code: ~5,500"
@echo "Test Coverage: 40+ tests"
@echo "========================================"
build-info: ## Show build information
@clojure -T:build info
all: clean build test-ml docker-build ## Build everything (clean, compile, test, docker)