-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
141 lines (117 loc) · 4.89 KB
/
Makefile
File metadata and controls
141 lines (117 loc) · 4.89 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
# =============================================================================
# DyingStar Technical Documentation - Makefile
# =============================================================================
# Colors for output
CYAN := \033[36m
GREEN := \033[32m
YELLOW := \033[33m
RED := \033[31m
RESET := \033[0m
EXECUTOR := docker compose
# if podman is available, use it instead of docker
ifneq (, $(shell which podman 2>/dev/null))
$(info ❗❗ Using podman for compose commands❗❗)
EXECUTOR := podman compose
endif
# Get absolute path to project root
ROOT_DIR := $(shell pwd)
COMPOSE := $(EXECUTOR) -f $(ROOT_DIR)/docker/docker-compose.yml --env-file $(ROOT_DIR)/.env
DEV_SERVICE := dev
APP_SERVICE := app
# =============================================================================
# Check .env file exists
# =============================================================================
.PHONY: check-env
check-env:
@if [ ! -f .env ]; then \
echo "$(RED)❌ .env file not found!$(RESET)"; \
echo "$(YELLOW)💡 Copy .env.sample to .env and configure it:$(RESET)"; \
echo " cp .env.sample .env"; \
exit 1; \
fi
.PHONY: stop
stop: ## Stop all running services
@echo "$(CYAN)🛑 Stopping all services...$(RESET)"
@$(COMPOSE) down
# =============================================================================
# Dev Profile - Development commands
# =============================================================================
.PHONY: up
up: check-env ## Start only dev for development (no app)
@echo "$(CYAN)🔧 Starting development environment...$(RESET)"
@$(COMPOSE) up $(DEV_SERVICE) -d
@echo "$(GREEN)✅ Development environment ready!$(RESET)"
@echo "$(YELLOW)Use 'make pnpm <command>' to run pnpm commands$(RESET)"
.PHONY: down
down: ## Stop development environment
@echo "$(CYAN)🛑 Stopping development environment...$(RESET)"
@$(COMPOSE) down
.PHONY: dev
dev: ## Run the development environment
@echo "$(CYAN)📦 Running: pnpm start$(RESET)"
@$(COMPOSE) exec $(DEV_SERVICE) sh -c "corepack enable && corepack install && pnpm start"
# Generic pnpm command runner
.PHONY: pnpm
pnpm: check-env ## Run any pnpm command (usage: make pnpm install, make pnpm dev, etc.)
@if [ -z "$(filter-out $@,$(MAKECMDGOALS))" ]; then \
echo "$(RED)❌ Please provide a pnpm command. Usage: make pnpm <command>$(RESET)"; \
echo "$(YELLOW)Examples: make pnpm install, make pnpm dev, make pnpm build$(RESET)"; \
exit 1; \
fi
@echo "$(CYAN)📦 Running: pnpm $(filter-out $@,$(MAKECMDGOALS))$(RESET)"
@$(COMPOSE) exec $(DEV_SERVICE) sh -c "corepack enable && corepack install && pnpm $(filter-out $@,$(MAKECMDGOALS))"
# =============================================================================
# Utility commands
# =============================================================================
.PHONY: logs
logs: ## Show logs for all services
@$(COMPOSE) logs -f
.PHONY: logs-dev
logs-dev: ## Show logs for dev service only
@$(COMPOSE) logs -f $(DEV_SERVICE)
.PHONY: shell
shell: ## Open shell in dev container
@echo "$(CYAN)🐚 Opening shell in dev container...$(RESET)"
@$(COMPOSE) exec $(DEV_SERVICE) sh
.PHONY: status
status: ## Show status of all services
@echo "$(CYAN)📊 Service Status:$(RESET)"
@$(COMPOSE) ps
.PHONY: clean
clean: ## Remove .cache and dist folders (WARNING: This will delete all compiled files!)
@echo "$(RED)⚠️ This will delete .cache build node_modules folders !$(RESET)"
@read -p "Are you sure? (y/N) " answer; \
if [ "$$answer" = "y" ] || [ "$$answer" = "Y" ]; then \
sudo rm -rf .cache build node_modules; \
echo "$(GREEN)✅ Folders cleaned$(RESET)"; \
else \
echo "$(YELLOW)Cancelled$(RESET)"; \
fi
.PHONY: clean-volumes
clean-volumes: ## Remove all volumes (WARNING: This will delete all data!)
@echo "$(RED)⚠️ This will delete all Docker volumes and data!$(RESET)"
@read -p "Are you sure? (y/N) " answer; \
if [ "$$answer" = "y" ] || [ "$$answer" = "Y" ]; then \
$(COMPOSE) down -v; \
echo "$(GREEN)✅ Volumes cleaned$(RESET)"; \
else \
echo "$(YELLOW)Cancelled$(RESET)"; \
fi
# =============================================================================
# Help
# =============================================================================
.PHONY: help
help: ## Show this help message
@echo "$(CYAN)DyingStar Technical Documentation - Available Commands:$(RESET)"
@echo ""
@echo "$(YELLOW)Dev Profile (Development):$(RESET)"
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / && ($$1 == "up" || $$1 == "down" || $$1 == "pnpm" || $$1 == "dev") {printf " $(CYAN)%-15s$(RESET) %s\n", $$1, $$2}' $(MAKEFILE_LIST)
@echo ""
@echo "$(YELLOW)Utilities:$(RESET)"
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / && ($$1 == "logs" || $$1 == "shell" || $$1 == "status" || $$1 == "clean-volumes") {printf " $(CYAN)%-15s$(RESET) %s\n", $$1, $$2}' $(MAKEFILE_LIST)
@echo ""
# Default target
.DEFAULT_GOAL := help
# Allow arguments to be passed to make commands
%:
@: