-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
109 lines (93 loc) · 2.49 KB
/
Makefile
File metadata and controls
109 lines (93 loc) · 2.49 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
# Build the project
.PHONY: build
build:
go build -o bin/minipaas ./cmd/server
# Run the server locally
.PHONY: run
run:
go run ./cmd/server
# Run tests
.PHONY: test
test:
go test -v ./...
# Run tests with coverage
.PHONY: test-coverage
test-coverage:
go test -v -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
# Download dependencies
.PHONY: deps
deps:
go mod download
go mod tidy
# Build Docker image
.PHONY: docker-build
docker-build:
docker build -t minipaas:latest .
# Create kind cluster
.PHONY: kind-create
kind-create:
kind create cluster --name minipaas
# Delete kind cluster
.PHONY: kind-delete
kind-delete:
kind delete cluster --name minipaas
# Load image into kind
.PHONY: kind-load
kind-load: docker-build
kind load docker-image minipaas:latest --name minipaas
# Deploy to Kubernetes
.PHONY: k8s-deploy
k8s-deploy:
kubectl apply -f deploy/k8s/namespace.yaml
kubectl apply -f deploy/k8s/configmap.yaml
kubectl apply -f deploy/k8s/rbac.yaml
kubectl apply -f deploy/k8s/pvc.yaml
kubectl apply -f deploy/k8s/deployment.yaml
kubectl apply -f deploy/k8s/service.yaml
# Delete from Kubernetes
.PHONY: k8s-delete
k8s-delete:
kubectl delete -f deploy/k8s/ --ignore-not-found
# Port forward
.PHONY: port-forward
port-forward:
kubectl port-forward -n minipaas svc/minipaas 8080:80
# Full local setup
.PHONY: setup
setup: kind-create kind-load k8s-deploy
@echo "MiniPaaS is deployed! Run 'make port-forward' to access the API"
# Clean up everything
.PHONY: clean
clean: kind-delete
rm -rf bin/
rm -f coverage.out coverage.html
rm -f minipaas.db
# Lint
.PHONY: lint
lint:
golangci-lint run ./...
# Format code
.PHONY: fmt
fmt:
go fmt ./...
# Help
.PHONY: help
help:
@echo "Available targets:"
@echo " build - Build the binary"
@echo " run - Run the server locally"
@echo " test - Run tests"
@echo " test-coverage - Run tests with coverage"
@echo " deps - Download and tidy dependencies"
@echo " docker-build - Build Docker image"
@echo " kind-create - Create kind cluster"
@echo " kind-delete - Delete kind cluster"
@echo " kind-load - Load image into kind"
@echo " k8s-deploy - Deploy to Kubernetes"
@echo " k8s-delete - Delete from Kubernetes"
@echo " port-forward - Port forward to access API"
@echo " setup - Full local setup (kind + deploy)"
@echo " clean - Clean up everything"
@echo " lint - Run linter"
@echo " fmt - Format code"