-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
100 lines (76 loc) · 3.23 KB
/
Copy pathMakefile
File metadata and controls
100 lines (76 loc) · 3.23 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
### Makefile for Eco Challenges Project
# Load environment variables from .env.dev
ifneq (,$(wildcard ./.env.dev))
include .env.dev
export
endif
# Variables
DOCKER_COMPOSE = docker compose -f compose.dev.yaml --env-file .env.dev
GATEWAY = $(GATEWAY_PORT)
# Colors for terminal output
GREEN = \033[0;32m
NC = \033[0m # No Color
YELLOW = \033[0;33m
RED = \033[0;31m
.PHONY: help install start stop restart logs ps clean clean-all frontend-logs backend-logs db-logs shell-backend shell-frontend update seed codegen
help: ## Display this help message
@echo "$(GREEN)Available commands:$(NC)"
@cat $(MAKEFILE_LIST) | grep -E '^[a-zA-Z_-]+:.*?## .*$$' | awk 'BEGIN {FS = ":.*?## "}; {printf "$(YELLOW)%-30s$(NC) %s\n", $$1, $$2}'
update: restart seed codegen
@echo "$(GREEN)Project successfully updated!$(NC)"
start: ## Start all containers
@echo "$(GREEN)Starting containers...$(NC)"
@$(DOCKER_COMPOSE) up -d --build
@echo "$(GREEN)Services are running:$(NC)"
@echo "- Frontend: http://localhost:$(GATEWAY)"
@echo "- Adminer: http://localhost:$(GATEWAY)/vizualizer"
@echo "- Backend: http://localhost:$(GATEWAY)/api"
stop: ## Stop all containers
@echo "$(YELLOW)Stopping containers...$(NC)"
@$(DOCKER_COMPOSE) down
restart: stop start ## Restart all containers
logs: ## Display containers logs
@$(DOCKER_COMPOSE) logs -f
ps: ## List all running containers
@$(DOCKER_COMPOSE) ps
clean: ## Remove project containers and volumes (safe)
@echo "$(YELLOW)Cleaning up project containers and volumes...$(NC)"
@$(DOCKER_COMPOSE) down -v
@echo "$(GREEN)Project cleanup complete$(NC)"
clean-all: ## Remove all containers, volumes, and build cache (dangerous)
@echo "$(RED)⚠️ WARNING: This will remove ALL Docker resources, not just this project's resources!$(NC)"
@echo "$(RED)Are you sure? [y/N] $(NC)" && read ans && [ $${ans:-N} = y ]
@echo "$(RED)Cleaning up all Docker resources...$(NC)"
@$(DOCKER_COMPOSE) down -v
@docker system prune -f
@echo "$(GREEN)Global cleanup complete$(NC)"
frontend-logs: ## Display frontend container logs
@$(DOCKER_COMPOSE) logs -f frontend
backend-logs: ## Display backend container logs
@$(DOCKER_COMPOSE) logs -f backend
db-logs: ## Display database container logs
@$(DOCKER_COMPOSE) logs -f database
shell-backend: ## Open a shell in the backend container
@$(DOCKER_COMPOSE) exec backend sh
shell-frontend: ## Open a shell in the frontend container
@$(DOCKER_COMPOSE) exec frontend sh
seed: ## Seed the database
@docker exec -it backend-eco sh -c "npm run seed"
email: ## Create a new template for sending email
@cd backend && npm run email
codegen: ## Generate GraphQL types and hooks
@echo "$(GREEN)Generating GraphQL types...$(NC)"
@cd frontend && npm run codegen
@echo "$(GREEN)GraphQL types generated successfully$(NC)"
vitest: ## Run tests
@echo "$(GREEN)Running tests...$(NC)"
@cd frontend && npm run test
@echo "$(GREEN)Tests completed$(NC)"
playwright: ## Run tests
@echo "$(GREEN)Running tests...$(NC)"
@cd e2e && npx playwright test
@echo "$(GREEN)Tests completed$(NC)"
playwright-test: ## Run a specific Playwright test file (usage: make playwright-test TEST=e2e/login.spec.ts)
@echo "$(GREEN)Running test $(TEST)...$(NC)"
@cd e2e && npx playwright test $(TEST)
@echo "$(GREEN)Test completed$(NC)"