-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
129 lines (96 loc) · 3.76 KB
/
Copy pathMakefile
File metadata and controls
129 lines (96 loc) · 3.76 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
# ============================================
# Makefile for Ethical Hacking Lab Platform
# ============================================
.PHONY: help dev dev-up dev-down build start stop restart logs shell migrate seed clean
# Colors
GREEN := \033[0;32m
YELLOW := \033[0;33m
NC := \033[0m # No Color
help: ## Show this help message
@echo "$(GREEN)Ethical Hacking Lab Platform - Docker Commands$(NC)"
@echo ""
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "$(YELLOW)%-20s$(NC) %s\n", $$1, $$2}'
# ============================================
# Development Commands
# ============================================
dev-up: ## Start development environment (database & redis only)
docker-compose -f docker-compose.dev.yml up -d
@echo "$(GREEN)Development services started!$(NC)"
@echo "PostgreSQL: localhost:5432"
@echo "Redis: localhost:6379"
@echo "PgAdmin: http://localhost:5050"
dev-down: ## Stop development environment
docker-compose -f docker-compose.dev.yml down
@echo "$(GREEN)Development services stopped!$(NC)"
dev: dev-up ## Start development (alias for dev-up)
@echo "$(GREEN)Run 'npm run dev' to start the Next.js app$(NC)"
# ============================================
# Production Commands
# ============================================
build: ## Build Docker images
docker-compose build
@echo "$(GREEN)Docker images built successfully!$(NC)"
start: ## Start all services in production mode
docker-compose up -d
@echo "$(GREEN)All services started!$(NC)"
stop: ## Stop all services
docker-compose down
@echo "$(GREEN)All services stopped!$(NC)"
restart: ## Restart all services
docker-compose restart
@echo "$(GREEN)All services restarted!$(NC)"
# ============================================
# Logs & Shell
# ============================================
logs: ## Show logs from all services
docker-compose logs -f
logs-app: ## Show logs from app service only
docker-compose logs -f app
logs-db: ## Show logs from database service only
docker-compose logs -f db
shell: ## Open shell in app container
docker-compose exec app sh
shell-db: ## Open psql shell in database container
docker-compose exec db psql -U postgres -d ethical_hacking_lab
# ============================================
# Database Commands
# ============================================
migrate: ## Run database migrations
docker-compose run --rm migrate
@echo "$(GREEN)Migrations completed!$(NC)"
migrate-dev: ## Run database migrations in development
npx prisma migrate dev
@echo "$(GREEN)Migrations completed!$(NC)"
seed: ## Seed the database
docker-compose exec app npx prisma db seed
@echo "$(GREEN)Database seeded!$(NC)"
seed-dev: ## Seed the database in development
npm run db:seed
@echo "$(GREEN)Database seeded!$(NC)"
studio: ## Open Prisma Studio
npx prisma studio
# ============================================
# Cleanup Commands
# ============================================
clean: ## Remove all containers and volumes
docker-compose down -v
docker-compose -f docker-compose.dev.yml down -v
@echo "$(GREEN)Containers and volumes removed!$(NC)"
clean-all: ## Remove all containers, volumes, and images
docker-compose down -v --rmi all
docker-compose -f docker-compose.dev.yml down -v --rmi all
@echo "$(GREEN)All containers, volumes, and images removed!$(NC)"
prune: ## Remove unused Docker resources
docker system prune -f
@echo "$(GREEN)Unused resources removed!$(NC)"
# ============================================
# Testing & CI Commands
# ============================================
lint: ## Run ESLint
npm run lint
type-check: ## Run TypeScript type check
npx tsc --noEmit
build-check: ## Build the application
npm run build
ci: lint type-check build-check ## Run all CI checks
@echo "$(GREEN)All CI checks passed!$(NC)"