-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
231 lines (196 loc) · 7.64 KB
/
Copy pathMakefile
File metadata and controls
231 lines (196 loc) · 7.64 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
# ============================================================================
# IterBot-UTFPR Makefile
# ============================================================================
# Simplified commands for common operations
#
# Usage: make <command>
# Example: make setup
# ============================================================================
.PHONY: help setup validate start stop restart logs logs-waha logs-backend status clean rebuild test migrate makemigrations createsuperuser shell pre-commit-install pre-commit-run pre-commit-update cz-commit changelog lint format dev-install dev-run dev-test ci-check
# Default target
.DEFAULT_GOAL := help
# Colors
BLUE := \033[0;34m
GREEN := \033[0;32m
YELLOW := \033[1;33m
NC := \033[0m
## help: Show this help message
help:
@echo "$(BLUE)============================================$(NC)"
@echo "$(BLUE)IterBot-UTFPR - Available Commands$(NC)"
@echo "$(BLUE)============================================$(NC)"
@echo ""
@grep -E '^## ' $(MAKEFILE_LIST) | sed 's/## / $(GREEN)/' | sed 's/:/$(NC):/'
@echo ""
## setup: Initial setup (secrets + validation)
setup:
@echo "$(BLUE)🔧 Setting up IterBot...$(NC)"
@bash ./deployment/scripts/setup_secrets.sh
@bash ./deployment/scripts/validate_environment.sh
## validate: Validate environment configuration
validate:
@bash ./deployment/scripts/validate_environment.sh
## dev-install: Install Python dependencies with Poetry
dev-install:
@echo "$(BLUE)📦 Installing dependencies with Poetry...$(NC)"
@poetry install --all-extras
@echo "$(GREEN)✅ Dependencies installed!$(NC)"
## dev-run: Start services with Docker Compose (development mode)
dev-run:
@echo "$(BLUE)🚀 Starting IterBot (dev mode)...$(NC)"
@docker compose up -d
@echo "$(GREEN)✅ Services started!$(NC)"
@make status
## start: Start all services
start:
@echo "$(BLUE)🚀 Starting IterBot...$(NC)"
@docker compose up -d
@echo "$(GREEN)✅ Services started!$(NC)"
@echo ""
@make status
## stop: Stop all services
stop:
@echo "$(BLUE)🛑 Stopping IterBot...$(NC)"
@docker compose stop
@echo "$(GREEN)✅ Services stopped!$(NC)"
## restart: Restart all services
restart:
@echo "$(BLUE)🔄 Restarting IterBot...$(NC)"
@docker compose restart
@echo "$(GREEN)✅ Services restarted!$(NC)"
## logs: Show logs from all services
logs:
@docker compose logs -f
## logs-waha: Show logs from WAHA service
logs-waha:
@docker compose logs -f waha
## logs-backend: Show logs from backend service
logs-backend:
@docker compose logs -f backend
## status: Show status of all services
status:
@echo "$(BLUE)📊 Service Status:$(NC)"
@docker compose ps
@echo ""
@echo "$(BLUE)🔗 Access URLs:$(NC)"
@echo " $(GREEN)WAHA Dashboard:$(NC) http://localhost:3000/dashboard"
@echo " $(GREEN)Backend Dashboard:$(NC) http://localhost:8000/dashboard/"
@echo " $(GREEN)Django Admin:$(NC) http://localhost:8000/admin/"
@echo " $(GREEN)API Docs:$(NC) http://localhost:8000/api/docs/"
@echo " $(GREEN)Traefik:$(NC) http://localhost:8080"
## clean: Stop and remove all containers, volumes
clean:
@echo "$(YELLOW)⚠️ This will remove all containers and volumes!$(NC)"
@read -p "Are you sure? (y/N): " confirm && [ "$$confirm" = "y" ] || exit 1
@docker compose down -v
@echo "$(GREEN)✅ Cleaned!$(NC)"
## rebuild: Rebuild and restart all services
rebuild:
@echo "$(BLUE)🔨 Rebuilding IterBot...$(NC)"
@docker compose down
@docker compose build --no-cache
@docker compose up -d
@echo "$(GREEN)✅ Rebuilt and started!$(NC)"
## dev-test: Run tests in Docker container
dev-test:
@echo "$(BLUE)🧪 Running tests (containerized)...$(NC)"
@docker compose exec backend pytest
@echo "$(GREEN)✅ Tests completed!$(NC)"
## test: Run tests
test:
@echo "$(BLUE)🧪 Running tests...$(NC)"
@docker compose exec backend pytest
@echo "$(GREEN)✅ Tests completed!$(NC)"
## migrate: Run database migrations
migrate:
@echo "$(BLUE)📦 Running migrations...$(NC)"
@docker compose exec backend python manage.py migrate
@echo "$(GREEN)✅ Migrations completed!$(NC)"
## makemigrations: Create new migrations
makemigrations:
@echo "$(BLUE)📝 Creating migrations...$(NC)"
@docker compose exec backend python manage.py makemigrations
@echo "$(GREEN)✅ Migrations created!$(NC)"
## createsuperuser: Create Django superuser
createsuperuser:
@echo "$(BLUE)👤 Creating superuser...$(NC)"
@docker compose exec backend python manage.py createsuperuser
## shell: Open Django shell
shell:
@docker compose exec backend python manage.py shell
## waha-restart: Restart only WAHA service
waha-restart:
@echo "$(BLUE)🔄 Restarting WAHA...$(NC)"
@docker compose stop waha
@docker compose rm -f waha
@docker compose up -d waha
@echo "$(GREEN)✅ WAHA restarted!$(NC)"
@echo ""
@echo "$(BLUE)📋 WAHA Credentials:$(NC)"
@echo " URL: $(GREEN)http://localhost:3000/dashboard$(NC)"
@echo " Username: $(GREEN)admin$(NC)"
@echo " Password: $(YELLOW)cat secrets/waha_dashboard_password.txt$(NC)"
## waha-logs: Show WAHA logs with secret validation
waha-logs:
@echo "$(BLUE)🔍 WAHA Logs:$(NC)"
@docker compose logs waha | grep -E "(🔐|✅|❌|⚠️|🚀)"
## health: Check health of all services
health:
@echo "$(BLUE)🏥 Health Check:$(NC)"
@echo -n " Backend: "
@curl -sf http://localhost:8000/health/ > /dev/null && echo "$(GREEN)✅ OK$(NC)" || echo "$(YELLOW)⚠️ Down$(NC)"
@echo -n " WAHA: "
@curl -sf http://localhost:3000/health > /dev/null && echo "$(GREEN)✅ OK$(NC)" || echo "$(YELLOW)⚠️ Down$(NC)"
@echo -n " PostgreSQL: "
@docker compose exec -T db pg_isready > /dev/null 2>&1 && echo "$(GREEN)✅ OK$(NC)" || echo "$(YELLOW)⚠️ Down$(NC)"
@echo -n " Redis: "
@docker compose exec -T redis redis-cli ping > /dev/null 2>&1 && echo "$(GREEN)✅ OK$(NC)" || echo "$(YELLOW)⚠️ Down$(NC)"
## backup: Backup database and secrets
backup:
@echo "$(BLUE)💾 Creating backup...$(NC)"
@mkdir -p backups
@docker compose exec -T db pg_dump -U iterbot_user iterbot > backups/db_backup_$$(date +%Y%m%d_%H%M%S).sql
@tar -czf backups/secrets_backup_$$(date +%Y%m%d_%H%M%S).tar.gz secrets/
@echo "$(GREEN)✅ Backup created in backups/$(NC)"
## ci-check: Run all CI quality checks (ruff + mypy)
ci-check:
@echo "$(BLUE)🔍 Running CI checks...$(NC)"
@poetry run ruff check .
@poetry run ruff format --check .
@poetry run mypy .
@echo "$(GREEN)✅ All CI checks passed!$(NC)"
## lint: Run code linters
lint:
@echo "$(BLUE)🔍 Running linters...$(NC)"
@poetry run ruff check .
@echo "$(GREEN)✅ Linting completed!$(NC)"
## format: Format code with ruff
format:
@echo "$(BLUE)✨ Formatting code...$(NC)"
@poetry run ruff format .
@echo "$(GREEN)✅ Code formatted!$(NC)"
## pre-commit-install: Install pre-commit hooks
pre-commit-install:
@echo "$(BLUE)🪝 Installing pre-commit hooks...$(NC)"
@poetry run pre-commit install
@poetry run pre-commit install --hook-type commit-msg
@echo "$(GREEN)✅ Pre-commit hooks installed!$(NC)"
## pre-commit-run: Run pre-commit on all files
pre-commit-run:
@echo "$(BLUE)🪝 Running pre-commit hooks...$(NC)"
@poetry run pre-commit run --all-files
@echo "$(GREEN)✅ Pre-commit hooks passed!$(NC)"
## pre-commit-update: Update pre-commit hook versions
pre-commit-update:
@echo "$(BLUE)🪝 Updating pre-commit hooks...$(NC)"
@poetry run pre-commit autoupdate
@echo "$(GREEN)✅ Pre-commit hooks updated!$(NC)"
## cz-commit: Create a commit with commitizen (conventional commits)
cz-commit:
@echo "$(BLUE)📝 Creating conventional commit...$(NC)"
@poetry run cz commit
## changelog: Generate/update CHANGELOG.md
changelog:
@echo "$(BLUE)📝 Generating changelog...$(NC)"
@poetry run cz changelog
@echo "$(GREEN)✅ Changelog generated!$(NC)"