-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
213 lines (176 loc) · 8 KB
/
Copy pathMakefile
File metadata and controls
213 lines (176 loc) · 8 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
# ==============================================================================
# SuperApp Monorepo - Automation & Workflow Makefile
# ==============================================================================
.DEFAULT_GOAL := help
SHELL := /bin/bash
# ANSI Color codes for clean output
BLUE := \033[36m
GREEN := \033[32m
YELLOW := \033[33m
RED := \033[31m
BOLD := \033[1m
RESET := \033[0m
JAVA_SERVICES := api-gateway identity-service kyc-service notification-service user-service
.PHONY: help
help: ## Display this help screen
@echo -e ""
@echo -e "${BOLD}SuperApp Monorepo Management${RESET}"
@echo -e "${YELLOW}Usage:${RESET} make ${GREEN}<target>${RESET}"
@echo -e ""
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " ${GREEN}%-20s${RESET} %s\n", $$1, $$2}' $(MAKEFILE_LIST)
@echo -e ""
# ==============================================================================
# ENVIRONMENT & SETUP
# ==============================================================================
.PHONY: setup
setup: ## Install pre-commit and pre-push Git hooks
@echo -e "${BLUE}==>${RESET} Setting up pre-commit and pre-push Git hooks..."
@pre-commit install --hook-type pre-commit --hook-type pre-push
@echo -e "${GREEN}✓ Git hooks installed successfully.${RESET}"
.PHONY: check-env
check-env: ## Verify that .env file exists
@if [ ! -f .env ]; then \
echo -e "${RED}✗ .env file not found! Copy .env.example to .env first.${RESET}"; \
exit 1; \
else \
echo -e "${GREEN}✓ .env file found.${RESET}"; \
fi
# ==============================================================================
# DOCKER COMPOSE & INFRASTRUCTURE
# ==============================================================================
.PHONY: up
up: check-env ## Build and start all components (infra, migrations, services, web)
@echo -e "${BLUE}==>${RESET} Starting all services..."
docker compose up -d --build
.PHONY: down
down: ## Stop and remove all containers and networks
@echo -e "${BLUE}==>${RESET} Stopping all services..."
docker compose down
.PHONY: restart
restart: down up ## Restart all services
.PHONY: ps
ps: ## List running containers and health status
@docker compose ps
.PHONY: logs
logs: ## Follow logs for all services (or use s=<service-name>)
@if [ -n "$(s)" ]; then \
docker compose logs -f $(s); \
else \
docker compose logs -f; \
fi
.PHONY: infra-up
infra-up: check-env ## Start only infrastructure (Postgres, Redis, Kafka, MinIO, Zipkin)
@echo -e "${BLUE}==>${RESET} Starting backing infrastructure..."
docker compose -f infra/compose/docker-compose.infra.yml up -d
.PHONY: infra-down
infra-down: ## Stop backing infrastructure
@echo -e "${BLUE}==>${RESET} Stopping backing infrastructure..."
docker compose -f infra/compose/docker-compose.infra.yml down
.PHONY: services-up
services-up: check-env ## Start only backend microservices
@echo -e "${BLUE}==>${RESET} Starting backend microservices..."
docker compose -f infra/compose/docker-compose.services.yml up -d --build
.PHONY: services-down
services-down: ## Stop backend microservices
@echo -e "${BLUE}==>${RESET} Stopping backend microservices..."
docker compose -f infra/compose/docker-compose.services.yml stop
.PHONY: migrate
migrate: check-env ## Run Flyway database migrations for all services
@echo -e "${BLUE}==>${RESET} Running database migrations..."
docker compose -f infra/compose/docker-compose.migrate.yml run --rm migrate-identity
docker compose -f infra/compose/docker-compose.migrate.yml run --rm migrate-user
docker compose -f infra/compose/docker-compose.migrate.yml run --rm migrate-kyc
@echo -e "${GREEN}✓ All database migrations applied.${RESET}"
.PHONY: web-up
web-up: check-env ## Start KYC Web Frontend in Docker
@echo -e "${BLUE}==>${RESET} Starting KYC Web container..."
docker compose -f infra/compose/docker-compose.web.yml up -d --build
.PHONY: web-down
web-down: ## Stop KYC Web Frontend container
@echo -e "${BLUE}==>${RESET} Stopping KYC Web container..."
docker compose -f infra/compose/docker-compose.web.yml down
# ==============================================================================
# JAVA MICROSERVICES (BUILD, TEST, CLEAN)
# ==============================================================================
.PHONY: build
build: ## Compile and build all Java microservices
@for svc in $(JAVA_SERVICES); do \
echo -e "${BLUE}==>${RESET} Building $$svc..."; \
(cd services/$$svc && (./gradlew classes || ./gradlew.bat classes)) || exit 1; \
done
@echo -e "${GREEN}✓ All microservices built successfully.${RESET}"
.PHONY: test
test: ## Run unit and integration tests across all Java microservices
@for svc in $(JAVA_SERVICES); do \
echo -e "${BLUE}==>${RESET} Testing $$svc..."; \
(cd services/$$svc && (./gradlew test || ./gradlew.bat test)) || exit 1; \
done
@echo -e "${GREEN}✓ All microservice tests passed.${RESET}"
.PHONY: clean
clean: ## Clean build directories, caches, and logs across all services
@for svc in $(JAVA_SERVICES); do \
echo -e "${YELLOW}==>${RESET} Cleaning $$svc..."; \
(cd services/$$svc && (./gradlew clean || ./gradlew.bat clean)) 2>/dev/null || true; \
rm -rf services/$$svc/.gradle services/$$svc/build services/$$svc/bin; \
done
@rm -f services/*/*.log services/*/*.iml
@echo -e "${GREEN}✓ Clean completed.${RESET}"
# ==============================================================================
# CODE QUALITY & SECURITY
# ==============================================================================
.PHONY: lint
lint: ## Run pre-commit hooks manually against all files
@echo -e "${BLUE}==>${RESET} Running pre-commit linters and validators..."
@pre-commit run --all-files
.PHONY: gitleaks
gitleaks: ## Scan repository for hardcoded secrets with Gitleaks
@echo -e "${BLUE}==>${RESET} Running Gitleaks secret detection..."
@pre-commit run gitleaks --all-files
# ==============================================================================
# KUBERNETES DEPLOYMENT
# ==============================================================================
.PHONY: k8s-apply
k8s-apply: ## Apply all Kubernetes manifests in order
@echo -e "${BLUE}==>${RESET} Applying Kubernetes manifests..."
kubectl apply -f k8s/00-secrets.yaml
kubectl apply -f k8s/01-configmap.yaml
kubectl apply -f k8s/02-postgres.yaml
kubectl apply -f k8s/03-redis.yaml
kubectl apply -f k8s/04-kafka.yaml
kubectl apply -f k8s/05-infra.yaml
kubectl apply -f k8s/06-services.yaml
@echo -e "${GREEN}✓ Kubernetes manifests applied.${RESET}"
.PHONY: k8s-delete
k8s-delete: ## Delete all Kubernetes resources
@echo -e "${RED}==>${RESET} Deleting Kubernetes resources..."
kubectl delete -f k8s/06-services.yaml --ignore-not-found
kubectl delete -f k8s/05-infra.yaml --ignore-not-found
kubectl delete -f k8s/04-kafka.yaml --ignore-not-found
kubectl delete -f k8s/03-redis.yaml --ignore-not-found
kubectl delete -f k8s/02-postgres.yaml --ignore-not-found
kubectl delete -f k8s/01-configmap.yaml --ignore-not-found
kubectl delete -f k8s/00-secrets.yaml --ignore-not-found
@echo -e "${GREEN}✓ Kubernetes resources deleted.${RESET}"
.PHONY: k8s-status
k8s-status: ## Show Kubernetes Pods, Services, and Deployments
@kubectl get pods,svc,deploy
# ==============================================================================
# FRONTEND & MOBILE APP
# ==============================================================================
.PHONY: mobile-run
mobile-run: ## Run Flutter mobile app in debug mode
@echo -e "${BLUE}==>${RESET} Running Flutter Mobile App..."
@(cd mobile && flutter run)
.PHONY: mobile-test
mobile-test: ## Run Flutter mobile app unit tests
@echo -e "${BLUE}==>${RESET} Running Flutter Mobile Tests..."
@(cd mobile && flutter test)
.PHONY: web-dev
web-dev: ## Run KYC Web Frontend locally
@echo -e "${BLUE}==>${RESET} Starting KYC Web dev server..."
@(cd web/kyc && npm install && npm run dev)
.PHONY: web-build
web-build: ## Build KYC Web Frontend production bundle
@echo -e "${BLUE}==>${RESET} Building KYC Web Frontend..."
@(cd web/kyc && npm install && npm run build)
@echo -e "${GREEN}✓ Web frontend built successfully.${RESET}"