-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
180 lines (134 loc) · 4.34 KB
/
Makefile
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
SHELL := /bin/bash
OS := $(shell uname)
define start-services
@docker compose -f compose.yaml up --force-recreate -d --remove-orphans sonar fluentbit newrelic db kafka kafdrop elasticsearch prometheus grafana telegraf influxdb keycloak localstack
endef
define start-check
@docker compose -f sonar-compose.yaml up --force-recreate -d --remove-orphans sonar-db sonar
endef
define start-app
@docker compose -f compose.yaml up -d web worker
endef
define teardown
@docker compose -f compose.yaml rm -f -v -s
@docker system prune -f --volumes
endef
define check-teardown
@docker compose -f sonar-compose.yaml rm -f -v -s
@docker system prune -f --volumes
endef
define local-setup
$(call start-services)
endef
define local-app
$(call start-app)
endef
define setup
@docker compose -f compose.yaml up -d --build --force-recreate --remove-orphans
endef
define cp-githooks
@cp scripts/pre-commit .git/hooks/pre-commit
@cp scripts/pre-push .git/hooks/pre-push
endef
define k8s-apply
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.0.0/deploy/static/provider/cloud/deploy.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.0.0/deploy/static/provider/baremetal/deploy.yaml
kubectl apply -f k8s/mysql.yaml
kubectl apply -f k8s/kafka.yaml
kubectl apply -f k8s/kafdrop.yaml
kubectl create -f https://download.elastic.co/downloads/eck/2.9.0/crds.yaml
kubectl apply -f https://download.elastic.co/downloads/eck/2.9.0/operator.yaml
kubectl apply -f k8s/es.yaml
kubectl create namespace prometheus
helm repo add bitnami https://charts.bitnami.com/bitnami
helm install prometheus bitnami/kube-prometheus -n prometheus
kubectl apply -f k8s/app.yaml
kubectl apply -f k8s/grafana.yaml
endef
define k8s-delete-app
@kubectl delete -f ./k8s/app.yaml
endef
define del-local-app
@docker stop template-service-java-springboot-worker
@docker stop template-service-java-springboot-web
@docker rm template-service-java-springboot-worker
@docker rm template-service-java-springboot-web
@docker image rm template-service-java-springboot
@docker image rm shubham01/template-service-java-springboot
endef
.PHONY: help install setup teardown
help:
@echo "######### Targets ##########"
@echo "help: Display the help menu"
@echo "install: Display the help menu"
@echo "local-setup: Setup test resources locally"
@echo "local-app: Setup application locally"
@echo "format: Formats the java codebase"
@echo "setup: Setup test resources"
@echo "teardown: Destroy test resources"
@echo "start-services: Start dependent services for testing"
@echo "tests: Run tests in local"
@echo "run-test: Run specific test"
@echo "############################"
start-check:
$(call start-check)
check:
./gradlew sonar
check-teardown:
$(call check-teardown)
local-setup: teardown
$(call local-setup)
setup: teardown build
$(call setup, "Setting up...")
start-services:
$(call start-services)
teardown:
$(call teardown, "Tearing down...")
cp-githooks:
$(call cp-githooks)
run-test:
@docker-compose -f compose.yaml up --build --force-recreate -d service
migrations:
checkformat:
sudo ./gradlew checkformat
format:
sudo ./gradlew format
install: setup
clean:
clear
./gradlew clean
build-local: clean
./gradlew build -x test
build-local-test: clean
./gradlew build
rm-images: clean
docker image rm shubham01/template-service-java-springboot
docker image rm template-service-java-springboot
docker-build:
docker build -t shubham01/template-service-java-springboot:latest .
build: clean build-local docker-build
rebuild: rm-images build
run-local: build-local
./gradlew bootRun
run: build
docker run -p 8080:8080 shubham01/template-service-java-springboot:latest --network="host"
k8s-apply:
$(call k8s-apply)
k8s-delete-app:
$(call k8s-delete-app)
del-local-app:
$(call del-local-app)
local-app: format build
$(call local-app)
local-app-re: del-local-app local-app
coverage:
./gradlew jacocoTestCoverageVerification
tests: local-setup
sudo ./gradlew test
make teardown
pipeline-build: local-setup
./gradlew build
# condb:
# mysql -h 127.0.0.1 -P 3306 -u test template-service-java-springboot -p