-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
134 lines (112 loc) · 4.15 KB
/
Copy pathMakefile
File metadata and controls
134 lines (112 loc) · 4.15 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
# =============================================================================
# Selfhostly Makefile
# =============================================================================
#
# Run with different .env files:
# make run-local # Uses .env (default)
# make run-local ENV_FILE=.env.primary # Uses .env.primary
# make run-local ENV_FILE=.env.secondary # Uses .env.secondary
#
# Multi-Node Local Development:
# Terminal 1: make run-local ENV_FILE=.env.primary
# Terminal 2: make run-local ENV_FILE=.env.secondary
#
# =============================================================================
.PHONY: dev dev-backend dev-frontend prod down clean install-air run-local test test-verbose test-coverage help
# Development commands
dev: ## Start all services with live reload
docker-compose -f docker-compose.dev.yml up
dev-backend: ## Start only backend with live reload
docker-compose -f docker-compose.dev.yml up backend
dev-frontend: ## Start only frontend
docker-compose -f docker-compose.dev.yml up frontend
dev-build: ## Rebuild dev containers
docker-compose -f docker-compose.dev.yml build
# Production commands
prod: ## Start production services
docker-compose -f docker-compose.prod.yml up -d
prod-build: ## Build and start production services
docker-compose -f docker-compose.prod.yml up -d --build
# Control commands
down: ## Stop all running containers
docker-compose -f docker-compose.dev.yml down
docker-compose -f docker-compose.prod.yml down
clean: ## Clean build artifacts and containers
docker-compose -f docker-compose.dev.yml down -v
docker-compose -f docker-compose.prod.yml down -v
rm -rf tmp/
rm -rf tmp-gateway/
rm -f build-errors.log
rm -f build-errors-gateway.log
# Local development (no Docker)
install-air: ## Install Air for local development
go install github.com/air-verse/air@latest
run-local: ## Run backend with Air (usage: make run-local [ENV_FILE=.env.custom])
@if [ -n "$(ENV_FILE)" ]; then \
if [ ! -f "$(ENV_FILE)" ]; then \
echo "ERROR: $(ENV_FILE) not found."; \
exit 1; \
fi; \
echo "Starting with $(ENV_FILE)"; \
ENV_FILE=$(ENV_FILE) air; \
else \
echo "Starting with .env"; \
air; \
fi
run-local-no-air: ## Run backend without Air (usage: make run-local-no-air [ENV_FILE=.env.custom])
@if [ -n "$(ENV_FILE)" ]; then \
if [ ! -f "$(ENV_FILE)" ]; then \
echo "ERROR: $(ENV_FILE) not found."; \
exit 1; \
fi; \
echo "Starting with $(ENV_FILE)"; \
ENV_FILE=$(ENV_FILE) go run cmd/server/main.go; \
else \
echo "Starting with .env"; \
go run cmd/server/main.go; \
fi
run-gateway: ## Run API gateway with Air hot reload (usage: make run-gateway [ENV_FILE=.env.gateway])
@if [ -n "$(ENV_FILE)" ]; then \
if [ ! -f "$(ENV_FILE)" ]; then \
echo "ERROR: $(ENV_FILE) not found."; \
exit 1; \
fi; \
echo "Starting gateway with $(ENV_FILE)"; \
ENV_FILE=$(ENV_FILE) air -c .air-gateway.toml; \
else \
echo "Starting gateway with .env"; \
air -c .air-gateway.toml; \
fi
run-gateway-no-air: ## Run API gateway without Air (usage: make run-gateway-no-air [ENV_FILE=.env.gateway])
@if [ -n "$(ENV_FILE)" ]; then \
if [ ! -f "$(ENV_FILE)" ]; then \
echo "ERROR: $(ENV_FILE) not found."; \
exit 1; \
fi; \
echo "Starting gateway with $(ENV_FILE)"; \
ENV_FILE=$(ENV_FILE) go run cmd/gateway/main.go; \
else \
echo "Starting gateway with .env"; \
go run cmd/gateway/main.go; \
fi
build-gateway: ## Build gateway binary
go build -o bin/gateway ./cmd/gateway
# Testing commands
test: ## Run all tests
go test ./...
test-verbose: ## Run all tests with verbose output
go test -v ./...
test-coverage: ## Run all tests with coverage report
go test -cover ./...
# Utility commands
logs: ## Show logs from all services
docker-compose -f docker-compose.dev.yml logs -f
logs-backend: ## Show backend logs only
docker-compose -f docker-compose.dev.yml logs -f backend
restart-backend: ## Restart backend service
docker-compose -f docker-compose.dev.yml restart backend
help: ## Show this help message
@echo 'Usage: make [target]'
@echo ''
@echo 'Available targets:'
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " %-20s %s\n", $$1, $$2}' $(MAKEFILE_LIST)