-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
114 lines (97 loc) · 4.6 KB
/
Makefile
File metadata and controls
114 lines (97 loc) · 4.6 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
# Makefile for Employee Management Full-Stack App
# ─── Variables ────────────────────────────────────────────────────────────────
BACKEND_DIR := backend
FRONTEND_DIR := frontend
DOCKER_COMPOSE_FILE := docker-compose.yaml
K8S_DIR := kubernetes
OPENAPI_SPEC := openapi.yaml
# Docker image names
BACKEND_IMAGE := employee-management-app-backend
FRONTEND_IMAGE := employee-management-app-frontend
# ─── Default Target ──────────────────────────────────────────────────────────
.PHONY: help
help:
@echo ""
@echo "Usage: make <target>"
@echo ""
@echo "Targets:"
@echo " backend-build Build backend (Maven)"
@echo " backend-run Run backend locally"
@echo " backend-test Run backend JUnit tests"
@echo ""
@echo " frontend-install Install frontend deps (npm)"
@echo " frontend-build Build frontend for production"
@echo " frontend-run Run frontend dev server"
@echo " frontend-test Run frontend tests"
@echo ""
@echo " docker-build Build Docker images"
@echo " docker-up Spin up containers via docker-compose"
@echo " docker-down Tear down containers"
@echo ""
@echo " k8s-apply Deploy to Kubernetes"
@echo " k8s-delete Remove Kubernetes resources"
@echo ""
@echo " openapi-gen-client Generate API client from OpenAPI spec"
@echo " clean Clean all build artifacts"
@echo ""
# ─── Backend ─────────────────────────────────────────────────────────────────
.PHONY: backend-build backend-run backend-test
backend-build:
@echo "→ Building backend with Maven..."
cd $(BACKEND_DIR) && mvn clean install
backend-run:
@echo "→ Starting backend (Spring Boot)..."
cd $(BACKEND_DIR) && mvn spring-boot:run
backend-test:
@echo "→ Running backend tests..."
cd $(BACKEND_DIR) && mvn test
# ─── Frontend ────────────────────────────────────────────────────────────────
.PHONY: frontend-install frontend-build frontend-run frontend-test
frontend-install:
@echo "→ Installing frontend dependencies..."
cd $(FRONTEND_DIR) && npm ci
frontend-build:
@echo "→ Building frontend for production..."
cd $(FRONTEND_DIR) && npm run build
frontend-run:
@echo "→ Starting frontend dev server..."
cd $(FRONTEND_DIR) && npm start
frontend-test:
@echo "→ Running frontend tests..."
cd $(FRONTEND_DIR) && npm test
# ─── Docker / Docker-Compose ─────────────────────────────────────────────────
.PHONY: docker-build docker-up docker-down
docker-build:
@echo "→ Building Docker images..."
docker build -t $(BACKEND_IMAGE):latest $(BACKEND_DIR)
docker build -t $(FRONTEND_IMAGE):latest $(FRONTEND_DIR)
docker-up:
@echo "→ Starting services via docker-compose..."
docker compose -f $(DOCKER_COMPOSE_FILE) up --build
docker-down:
@echo "→ Stopping services..."
docker compose -f $(DOCKER_COMPOSE_FILE) down
# ─── Kubernetes ──────────────────────────────────────────────────────────────
.PHONY: k8s-apply k8s-delete
k8s-apply:
@echo "→ Applying Kubernetes manifests..."
kubectl apply -f $(K8S_DIR)
k8s-delete:
@echo "→ Deleting Kubernetes resources..."
kubectl delete -f $(K8S_DIR)
# ─── OpenAPI Client Generation ────────────────────────────────────────────────
.PHONY: openapi-gen-client
openapi-gen-client:
@echo "→ Generating OpenAPI client (default: javascript)..."
cd $(shell pwd) && \
openapi-generator-cli generate \
-i $(OPENAPI_SPEC) \
-g javascript \
-o ./client
# ─── Utilities ────────────────────────────────────────────────────────────────
.PHONY: clean
clean:
@echo "→ Cleaning all build artifacts..."
cd $(BACKEND_DIR) && mvn clean
cd $(FRONTEND_DIR) && rm -rf node_modules build
docker image prune -f