-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
144 lines (108 loc) · 4.42 KB
/
Makefile
File metadata and controls
144 lines (108 loc) · 4.42 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
.PHONY: help dev build up down logs clean deploy-k8s cli probe agent test-db test-api test-web test
# Default registry (override with: make build REGISTRY=your-registry.com)
REGISTRY ?= your-registry
TAG ?= latest
help: ## Show this help message
@echo "Sigma - VPS Fleet Management"
@echo ""
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'
dev: ## Start development environment with Docker Compose
docker compose up -d
@echo "✅ Services started:"
@echo " Web: http://localhost"
@echo " API: http://localhost:3000/api"
@echo " DB: localhost:5432"
build: ## Build Docker images
@echo "🔨 Building API..."
cd sigma-api && docker build -t $(REGISTRY)/sigma-api:$(TAG) .
@echo "🔨 Building Web..."
cd sigma-web && docker build -t $(REGISTRY)/sigma-web:$(TAG) .
@echo "🔨 Building Probe..."
cd sigma-probe && docker build -t $(REGISTRY)/sigma-probe:$(TAG) .
@echo "🔨 Building Agent..."
cd sigma-agent && docker build -t $(REGISTRY)/sigma-agent:$(TAG) .
@echo "✅ Build complete"
push: build ## Build and push images to registry
@echo "⬆️ Pushing images..."
docker push $(REGISTRY)/sigma-api:$(TAG)
docker push $(REGISTRY)/sigma-web:$(TAG)
@echo "✅ Push complete"
up: ## Start all services
docker compose up -d
down: ## Stop all services
docker compose down
logs: ## Tail logs from all services
docker compose logs -f
logs-api: ## Tail API logs
docker compose logs -f api
logs-web: ## Tail web logs
docker compose logs -f web
logs-db: ## Tail database logs
docker compose logs -f db
restart: ## Restart all services
docker compose restart
restart-api: ## Restart API service
docker compose restart api
restart-web: ## Restart web service
docker compose restart web
ps: ## Show running containers
docker compose ps
clean: ## Stop services and remove volumes (⚠️ DELETES DATA)
docker compose down -v
db-backup: ## Backup PostgreSQL database
@echo "📦 Creating backup..."
docker compose exec -T db pg_dump -U sigma sigma > backup_$(shell date +%Y%m%d_%H%M%S).sql
@echo "✅ Backup created"
db-restore: ## Restore PostgreSQL database (usage: make db-restore FILE=backup.sql)
@if [ -z "$(FILE)" ]; then echo "❌ Error: FILE not specified. Usage: make db-restore FILE=backup.sql"; exit 1; fi
@echo "⚠️ Restoring database from $(FILE)..."
docker compose exec -T db psql -U sigma sigma < $(FILE)
@echo "✅ Restore complete"
db-shell: ## Open PostgreSQL shell
docker compose exec db psql -U sigma
deploy-k8s: ## Apply Kubernetes manifests
kubectl apply -f k8s/
k8s-status: ## Check Kubernetes deployment status
kubectl get all -n sigma
k8s-logs-api: ## Tail API logs in Kubernetes
kubectl logs -f deployment/sigma-api -n sigma
k8s-logs-web: ## Tail web logs in Kubernetes
kubectl logs -f deployment/sigma-web -n sigma
k8s-delete: ## Delete Kubernetes deployment
kubectl delete namespace sigma
cli: ## Build sigma CLI client
cd sigma-cli && cargo build --release
@echo "✅ CLI built: sigma-cli/target/release/sigma"
cli-install: cli ## Build and install sigma CLI to ~/.cargo/bin
cp sigma-cli/target/release/sigma ~/.cargo/bin/sigma
@echo "✅ Installed sigma to ~/.cargo/bin/sigma"
probe: ## Build sigma-probe binary
cd sigma-probe && cargo build --release
@echo "✅ Probe built: sigma-probe/target/release/sigma-probe"
logs-probe: ## Tail probe logs
docker compose logs -f probe
agent: ## Build sigma-agent binary
cd sigma-agent && cargo build --release
@echo "✅ Agent built: sigma-agent/target/release/sigma-agent"
logs-agent: ## Tail agent logs
docker compose logs -f agent
test-db: ## Start test database
docker compose up -d test-db
@echo "⏳ Waiting for test database..."
@sleep 2
test-api: test-db ## Run backend tests
DATABASE_URL=postgres://sigma_test:sigma_test@localhost:5433/sigma_test \
REDIS_URL=redis://localhost:6379 \
cargo test --manifest-path sigma-api/Cargo.toml -- --test-threads=1
test-web: ## Run frontend tests
cd sigma-web && npx vitest run
test: test-api test-web ## Run all tests
check-api: ## Test API health (curl)
@echo "🧪 Testing API..."
@curl -s -H "X-Api-Key: ${API_KEY:-change-me}" http://localhost:3000/api/stats | jq . || echo "❌ API not responding"
check-web: ## Test web frontend (curl)
@echo "🧪 Testing Web..."
@curl -s http://localhost/ > /dev/null && echo "✅ Web is up" || echo "❌ Web not responding"