-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
162 lines (138 loc) · 6.19 KB
/
Makefile
File metadata and controls
162 lines (138 loc) · 6.19 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
.PHONY: help up down restart logs logs-f build clean test shell-backend shell-frontend
# Colors
BLUE := \033[0;34m
GREEN := \033[0;32m
YELLOW := \033[1;33m
RED := \033[0;31m
NC := \033[0m # No Color
help: ## Show this help message
@echo "$(BLUE)╔════════════════════════════════════════════════════════════════╗$(NC)"
@echo "$(BLUE)║$(NC) $(GREEN)ASISGUARD Camera Control System$(NC) $(BLUE)║$(NC)"
@echo "$(BLUE)╚════════════════════════════════════════════════════════════════╝$(NC)"
@echo ""
@echo "$(YELLOW)Available commands:$(NC)"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " $(GREEN)%-15s$(NC) %s\n", $$1, $$2}'
@echo ""
up: ## Start all services
@echo "$(BLUE)🚀 Starting ASISGUARD Camera Control System...$(NC)"
@docker compose up -d
@echo "$(GREEN)✅ System started!$(NC)"
@echo ""
@echo "$(YELLOW)Access:$(NC)"
@echo " 🌐 Web UI: http://localhost:3000"
@echo " 🔧 API: http://localhost:8000"
@echo " 📚 API Docs: http://localhost:8000/docs"
@echo ""
@echo "$(YELLOW)Default Login:$(NC)"
@echo " 👤 admin / admin123"
@echo ""
down: ## Stop all services
@echo "$(YELLOW)🛑 Stopping services...$(NC)"
@docker compose down
@echo "$(GREEN)✅ Services stopped$(NC)"
restart: ## Restart all services
@echo "$(YELLOW)🔄 Restarting services...$(NC)"
@docker compose restart
@echo "$(GREEN)✅ Services restarted$(NC)"
logs: ## View logs
@docker compose logs
logs-f: ## Follow logs
@docker compose logs -f
logs-backend: ## View backend logs
@docker compose logs backend
logs-frontend: ## View frontend logs
@docker compose logs frontend
build: ## Rebuild all images
@echo "$(BLUE)🔨 Building images...$(NC)"
@docker compose build
@echo "$(GREEN)✅ Build complete$(NC)"
rebuild: ## Rebuild and restart
@echo "$(BLUE)🔨 Rebuilding and restarting...$(NC)"
@docker compose up -d --build
@echo "$(GREEN)✅ Rebuild complete$(NC)"
clean: ## Stop and remove all containers, volumes, images
@echo "$(RED)🗑️ Cleaning up...$(NC)"
@docker compose down -v --rmi all
@echo "$(GREEN)✅ Cleanup complete$(NC)"
test: ## Run tests
@echo "$(BLUE)🧪 Running tests...$(NC)"
@docker compose exec backend pytest
@echo "$(GREEN)✅ Tests complete$(NC)"
shell-backend: ## Open shell in backend container
@docker compose exec backend /bin/bash
shell-frontend: ## Open shell in frontend container
@docker compose exec frontend /bin/sh
ps: ## Show running containers
@docker compose ps
health: ## Check system health
@echo "$(BLUE)🏥 Checking system health...$(NC)"
@curl -s http://localhost:8000/api/system/health | jq . || echo "$(RED)❌ Backend not responding$(NC)"
config-check: ## Validate configuration files
@echo "$(BLUE)✅ Validating configuration files...$(NC)"
@python3 -c "import yaml; yaml.safe_load(open('config.yaml'))" && echo "$(GREEN)✓ config.yaml$(NC)" || echo "$(RED)✗ config.yaml$(NC)"
@python3 -c "import yaml; yaml.safe_load(open('cameras.yaml'))" && echo "$(GREEN)✓ cameras.yaml$(NC)" || echo "$(RED)✗ cameras.yaml$(NC)"
@python3 -c "import yaml; yaml.safe_load(open('ui_layout.yaml'))" && echo "$(GREEN)✓ ui_layout.yaml$(NC)" || echo "$(RED)✗ ui_layout.yaml$(NC)"
dev: ## Start in development mode with hot reload
@echo "$(BLUE)🔥 Starting development mode...$(NC)"
@docker compose -f docker-compose.dev.yml up
backup: ## Backup recordings and configuration
@echo "$(BLUE)💾 Creating backup...$(NC)"
@mkdir -p backups
@tar -czf backups/backup-$$(date +%Y%m%d-%H%M%S).tar.gz config.yaml cameras.yaml ui_layout.yaml data/
@echo "$(GREEN)✅ Backup created in backups/$(NC)"
install: ## Initial setup
@echo "$(BLUE)📦 Installing ASISGUARD Camera Control System...$(NC)"
@echo ""
@echo "$(YELLOW)Step 1: Checking Docker...$(NC)"
@docker --version || (echo "$(RED)❌ Docker not found. Please install Docker first.$(NC)" && exit 1)
@docker compose version || (echo "$(RED)❌ Docker Compose not found. Please install Docker Compose first.$(NC)" && exit 1)
@echo "$(GREEN)✓ Docker OK$(NC)"
@echo ""
@echo "$(YELLOW)Step 2: Validating configuration...$(NC)"
@make config-check
@echo ""
@echo "$(YELLOW)Step 3: Building images...$(NC)"
@docker compose build
@echo "$(GREEN)✓ Build complete$(NC)"
@echo ""
@echo "$(YELLOW)Step 4: Starting services...$(NC)"
@docker compose up -d
@echo "$(GREEN)✓ Services started$(NC)"
@echo ""
@echo "$(GREEN)╔════════════════════════════════════════════════════════════════╗$(NC)"
@echo "$(GREEN)║$(NC) $(YELLOW)✅ Installation Complete!$(NC) $(GREEN)║$(NC)"
@echo "$(GREEN)╚════════════════════════════════════════════════════════════════╝$(NC)"
@echo ""
@echo "$(YELLOW)Next steps:$(NC)"
@echo " 1. Open http://localhost:3000 in your browser"
@echo " 2. Login with: admin / admin123"
@echo " 3. Configure your cameras in cameras.yaml"
@echo " 4. Run 'make restart' to apply changes"
@echo ""
uninstall: ## Remove everything
@echo "$(RED)⚠️ This will remove all containers, volumes, and images!$(NC)"
@read -p "Are you sure? [y/N] " -n 1 -r; \
echo; \
if [[ $$REPLY =~ ^[Yy]$$ ]]; then \
make clean; \
echo "$(GREEN)✅ Uninstall complete$(NC)"; \
else \
echo "$(YELLOW)Cancelled$(NC)"; \
fi
status: ## Show system status
@echo "$(BLUE)📊 System Status$(NC)"
@echo ""
@echo "$(YELLOW)Services:$(NC)"
@docker compose ps
@echo ""
@echo "$(YELLOW)Health:$(NC)"
@make health
@echo ""
@echo "$(YELLOW)Storage:$(NC)"
@du -sh data/ 2>/dev/null || echo "No data directory"
update: ## Update to latest version
@echo "$(BLUE)🔄 Updating system...$(NC)"
@git pull
@docker compose pull
@docker compose up -d --build
@echo "$(GREEN)✅ Update complete$(NC)"