This repository has been archived by the owner on Jul 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathmakefile
209 lines (151 loc) · 4.92 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
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
SHELL := /bin/bash
# ==============================================================================
# Building containers
all: api ui
api:
docker build \
-f zarf/docker/dockerfile.travel-api \
-t travel-api-amd64:1.0 \
--build-arg VCS_REF=`git rev-parse HEAD` \
--build-arg BUILD_DATE=`date -u +”%Y-%m-%dT%H:%M:%SZ”` \
.
ui:
docker build \
-f zarf/docker/dockerfile.travel-ui \
-t travel-ui-amd64:1.0 \
--build-arg VCS_REF=`git rev-parse HEAD` \
--build-arg BUILD_DATE=`date -u +”%Y-%m-%dT%H:%M:%SZ”` \
.
# ==============================================================================
# Running from within docker compose
run: up seed browse
up:
docker-compose -f zarf/compose/compose.yaml -f zarf/compose/compose-config.yaml up --detach --remove-orphans
down:
docker-compose -f zarf/compose/compose.yaml down --remove-orphans
browse:
python -m webbrowser "http://localhost"
logs:
docker-compose -f zarf/compose/compose.yaml logs -f
dbonly:
docker-compose -f zarf/compose/compose-dbonly.yaml -f zarf/compose/compose-dbonly-config.yaml up --detach --remove-orphans
# ==============================================================================
# Running Dgraph in Cloud
kind-cloud-up:
kind create cluster --image kindest/node:v1.21.1 --name dgraph-travel-cluster --config zarf/k8s/cloud/kind-config.yaml
kind-cloud-services:
kustomize build zarf/k8s/cloud | kubectl apply -f -
# ==============================================================================
# Running from within k8s
kind-up:
kind create cluster \
--image kindest/node:v1.23.0@sha256:49824ab1727c04e56a21a5d8372a402fcd32ea51ac96a2706a12af38934f81ac \
--name dgraph-travel-cluster \
--config zarf/k8s/kind/kind-config.yaml
kind-down:
kind delete cluster --name dgraph-travel-cluster
kind-load:
kind load docker-image travel-api-amd64:1.0 --name dgraph-travel-cluster
kind load docker-image travel-ui-amd64:1.0 --name dgraph-travel-cluster
kind-apply:
kustomize build zarf/k8s/kind | kubectl apply -f -
kind-api: api
kind load docker-image travel-api-amd64:1.0 --name dgraph-travel-cluster
kubectl rollout restart deployment travel-pod
kind-ui: ui
kind load docker-image travel-ui-amd64:1.0 --name dgraph-travel-cluster
kubectl rollout restart deployment travel-pod
kind-logs:
kubectl logs -l app=travel --all-containers true -f --tail 100
kind-status:
kubectl get nodes -o wide
kubectl get svc -o wide
kubectl get pods -o wide --watch
kind-status-full:
kubectl describe nodes
kubectl describe svc
kubectl describe pod -l app=travel
kind-events:
kubectl get ev --sort-by metadata.creationTimestamp
kind-events-warn:
kubectl get ev --field-selector type=Warning --sort-by metadata.creationTimestamp
kind-delete:
kustomize build . | kubectl delete -f -
kind-schema:
go run app/travel-admin/main.go --custom-functions-upload-feed-url=http://localhost:3000/v1/feed/upload schema
kind-seed: kind-schema
go run app/travel-admin/main.go seed
# ==============================================================================
# Running Local
local-run: local-up seed browse
local-up:
go run app/travel-api/main.go &> api.log &
cd app/travel-ui; \
go run main.go &> ../../ui.log &
API := $(shell lsof -i tcp:4000 | cut -c9-13 | grep "[0-9]")
UI := $(shell lsof -i tcp:4080 | cut -c9-13 | grep "[0-9]")
ps:
lsof -i tcp:4000; \
lsof -i tcp:4080
local-down:
kill -15 $(API); \
kill -15 $(UI); \
rm *.log
api-logs:
tail -F api.log
ui-logs:
tail -F ui.log
# ==============================================================================
# Administration
schema:
go run app/travel-admin/main.go schema
seed: schema
go run app/travel-admin/main.go seed
dropall:
curl -H "Content-Type: application/graphql" http://0.0.0.0:8080/alter -XPOST -d $ \
'{ \
"drop_all": true \
}'
dropdata:
curl -H "Content-Type: application/graphql" http://0.0.0.0:8080/alter -XPOST -d $ \
'{ \
"drop_op": "DATA" \
}'
token:
go run app/travel-admin/main.go gentoken [email protected] zarf/keys/54bb2165-71e1-41a6-af3e-7da4a0e1e2c1.pem RS256
# ==============================================================================
# Running tests within the local computer
test:
go test ./... -count=1
staticcheck ./...
# ==============================================================================
# Modules support
deps-reset:
git checkout -- go.mod
go mod tidy
go mod vendor
tidy:
go mod tidy
go mod vendor
deps-upgrade:
go get -u -t -d -v ./...
go mod tidy
go mod vendor
deps-cleancache:
go clean -modcache
# ==============================================================================
# Docker support
FILES := $(shell docker ps -aq)
down-local:
docker stop $(FILES)
docker rm $(FILES)
clean:
docker system prune -f
logs-local:
docker logs -f $(FILES)
# ==============================================================================
# Git support
install-hooks:
cp -r .githooks/pre-commit .git/hooks/pre-commit
remove-hooks:
rm .git/hooks/pre-commit