-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
154 lines (116 loc) · 6.08 KB
/
Makefile
File metadata and controls
154 lines (116 loc) · 6.08 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
SHELL := /bin/bash
VERSION := $(shell sed -n -e 's:.*<version>\(.*\)</version>.*:\1:p' pom.xml | head -1)
IMAGE_NAME := librarygames
SERVER_IMAGE_NAME := librarygames-server
PROFILE := librarygames
NAMESPACE := librarygames
RELEASE_NAME := librarygames
define node_ip
$(shell kubectl --context ${PROFILE} get nodes --namespace ${NAMESPACE} -o jsonpath="{.items[0].status.addresses[0].address}")
endef
define node_port
$(shell kubectl --context ${PROFILE} get --namespace ${NAMESPACE} -o jsonpath="{.spec.ports[0].nodePort}" services ${RELEASE_NAME})
endef
define grafana_ip
$(shell kubectl --context ${PROFILE} get nodes --namespace observability -o jsonpath="{.items[0].status.addresses[0].address}")
endef
define grafana_port
$(shell kubectl --context ${PROFILE} get --namespace grafana -o jsonpath="{.spec.ports[0].nodePort}" services grafana)
endef
define sonar_ip
$(shell kubectl --context ${PROFILE} get nodes --namespace sonarqube -o jsonpath="{.items[0].status.addresses[0].address}")
endef
define sonar_port
$(shell kubectl --context ${PROFILE} get --namespace sonarqube -o jsonpath="{.spec.ports[0].nodePort}" services sonarqube-sonarqube)
endef
image-client:
@docker build --build-arg VERSION=${VERSION} -t ${IMAGE_NAME}:${VERSION} --file client.Dockerfile .
image-server:
@docker build --build-arg VERSION=${VERSION} -t ${SERVER_IMAGE_NAME}:${VERSION} --file server.Dockerfile .
image-test-server:
@docker build --build-arg VERSION=${VERSION} --build-arg SONAR_ADDRESS=http://$(call sonar_ip):$(call sonar_port) -t ${SERVER_IMAGE_NAME}-test:${VERSION} --file server.Dockerfile --target go-test .
@docker run --rm --net=host ${SERVER_IMAGE_NAME}-test:${VERSION}
image-client-debug:
@docker build --build-arg VERSION=${VERSION} -t ${IMAGE_NAME}-debug:${VERSION} --file client.Dockerfile --target mvn-build .
test-server:
@cd server; \
go test -v ./...
proto:
@protoc --proto_path=pbs pbs/*.proto --go_out=server/internal/pbs --go-grpc_out=server/internal/pbs
run:
@docker run --rm --net=host -e LIBRARY_GAMES_SERVER_ADDRESS=$(call node_ip):$(call node_port) ${IMAGE_NAME}:${VERSION}
run-wsl:
@docker run --rm -v /tmp/.X11-unix:/tmp/.X11-unix -v /mnt/wslg:/mnt/wslg --net=host -e LIBRARY_GAMES_SERVER_ADDRESS=$(call node_ip):$(call node_port) ${IMAGE_NAME}:${VERSION}
run-offline:
@docker run --rm -v /tmp/.X11-unix:/tmp/.X11-unix -v /mnt/wslg:/mnt/wslg --net=host ${IMAGE_NAME}:${VERSION}
clean:
@docker image prune
start-minikube:
@minikube -p ${PROFILE} start
stop-minikube:
@minikube -p ${PROFILE} stop
delete-minikube:
@minikube -p ${PROFILE} delete
observability-minikube:
@helm --kube-context ${PROFILE} -n elasticsearch install --create-namespace elasticsearch elastic/elasticsearch --version=8.5.1 -f observability/elasticsearch_values.yaml --wait || true
@helm --kube-context ${PROFILE} -n fluent install --create-namespace fluent-bit fluent/fluent-bit --version=0.29.0 -f observability/fluentbit_values.yaml --wait || true
@helm --kube-context ${PROFILE} -n tempo install --create-namespace tempo grafana/tempo --version=1.0.0 -f observability/tempo_values.yaml --wait || true
@helm --kube-context ${PROFILE} -n monitoring install --create-namespace kube-prometheus-stack prometheus/kube-prometheus-stack --version=45.23.0 -f observability/prometheus_values.yaml --wait || true
@helm --kube-context ${PROFILE} -n grafana install --create-namespace grafana grafana/grafana --version=6.50.7 -f observability/grafana_values.yaml --wait || true
@helm --kube-context ${PROFILE} -n sonarqube install --create-namespace sonarqube sonarqube/sonarqube --version=10.0.0 -f observability/sonarqube_values.yaml --wait || true
clean-observability-minikube:
@helm --kube-context ${PROFILE} -n elasticsearch delete elasticsearch --wait
@helm --kube-context ${PROFILE} -n fluent delete fluent-bit --wait
@helm --kube-context ${PROFILE} -n tempo delete tempo grafana/tempo --wait
@helm --kube-context ${PROFILE} -n monitoring delete kube-prometheus-stack --wait
@helm --kube-context ${PROFILE} -n grafana delete grafana --wait
clean-fluent:
@helm --kube-context ${PROFILE} -n fluent delete fluent-bit --wait
clean-grafana:
@helm --kube-context ${PROFILE} -n grafana delete grafana --wait
clean-sonar:
@helm --kube-context ${PROFILE} -n sonarqube delete sonarqube --wait
grafana:
@echo http://$(call grafana_ip):$(call grafana_port)
@python -mwebbrowser http://$(call grafana_ip):$(call grafana_port)
sonar:
@echo http://$(call sonar_ip):$(call sonar_port)
@python -mwebbrowser http://$(call sonar_ip):$(call sonar_port)
load:
@minikube -p ${PROFILE} image load ${SERVER_IMAGE_NAME}:${VERSION}
metrics:
@echo $(call node_ip):$(call node_port)
@curl -s $(call node_ip):$(call node_port)/metrics
deploy:
@helm --kube-context ${PROFILE} -n ${NAMESPACE} install --create-namespace ${RELEASE_NAME} charts/librarygames -f observability/librarygames_values.yaml --set=librarygames.image.tag=${VERSION}
uninstall:
@helm --kube-context ${PROFILE} -n ${NAMESPACE} delete ${RELEASE_NAME}
dependencies: dependencies-asdf dependencies-helm
dependencies-asdf:
@echo "Updating asdf plugins..."
@asdf plugin update --all >/dev/null 2>&1 || true
@echo "Adding new asdf plugins..."
@cut -d" " -f1 ./.tool-versions | xargs -I % asdf plugin-add % >/dev/null 2>&1 || true
@echo "Installing asdf tools..."
@cat ./.tool-versions | xargs -I{} bash -c 'asdf install {}'
@echo "Updating local environment to use proper tool versions..."
@cat ./.tool-versions | xargs -I{} bash -c 'asdf local {}'
@asdf reshim
@echo "Done!"
dependencies-helm:
@helm repo add bitnami https://charts.bitnami.com/bitnami
@helm repo add elastic https://helm.elastic.co
@helm repo add fluent https://fluent.github.io/helm-charts
@helm repo add grafana https://grafana.github.io/helm-charts
@helm repo add prometheus https://prometheus-community.github.io/helm-charts
@helm repo add sonarqube https://SonarSource.github.io/helm-chart-sonarqube
@cd charts/librarygames; \
helm dependencies update; \
helm dependencies build; \
hooks:
@pre-commit install --hook-type pre-commit
@pre-commit install-hooks
pre-commit:
@pre-commit run -a
dive:
@dive ${IMAGE_NAME}:${VERSION} --ci