-
Notifications
You must be signed in to change notification settings - Fork 1
/
taskfile.yaml
356 lines (300 loc) · 11.8 KB
/
taskfile.yaml
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
# yaml-language-server: $schema=https://taskfile.dev/schema.json
version: '3'
##############################################################################
# DOT ENV SUPPORT
##############################################################################
dotenv:
- .env
env:
BINARY_NAME: vth-gateway
GIT_REPO: https://github.com/azarc-io/verathread-gateway
tasks:
##############################################################################
# DEV - NATIVE
##############################################################################
dev:
desc: "runs both the backend and frontend in local dev mode"
deps:
- dev:be
- dev:fe
cmds:
- echo "finished"
dev:be:
desc: "builds the backend with hot reloading"
prefix: gateway
method: none
cmds:
- fswatch -config .fsw.task.yml
env:
CONFIG_DIR: cmd/app/config
BASE_CONTEXT: base
MONGO_HOST: localhost
dev:fe:
desc: "starts the front end in dev mode with hmr support"
dir: cmd/web
cmds:
- yarn dev
env:
NODE_ENV: development
##############################################################################
# DEV - DOCKER COMPOSE
##############################################################################
compose:
desc: "Starts up dependant services such as redis, nats and mongo"
cmds:
- docker compose -f docker-compose.yml up -d
compose:down:
desc: "Stops previously started containers using <compose>"
cmds:
- docker compose -f docker-compose.yml down
compose:dev:
desc: "Starts up dependant services such as redis, nats and mongo and runs all apps in development mode with hot reloading"
cmds:
- docker compose -f docker-compose.yml -f docker-compose-dev.yml up -d
compose:dev:down:
desc: "Stops previously started containers using <compose:dev>"
cmds:
- docker compose -f docker-compose.yml -f docker-compose-dev.yml down
compose:rebuild:
desc: "Rebuilds all docker containers in compose"
cmds:
- task: compose:rebuild:example:be
- task: compose:rebuild:gateway:be
- task: compose:rebuild:example:fe
- task: compose:rebuild:gateway:fe
- echo "rebuild completed"
compose:rebuild:example:be:
desc: "Rebuilds the example be docker image in compose"
cmds:
- docker compose -f docker-compose.yml -f docker-compose-dev.yml build example
compose:rebuild:example:fe:
desc: "Rebuilds the example fe docker image in compose"
cmds:
- docker compose -f docker-compose.yml -f docker-compose-dev.yml build example-fe
compose:rebuild:gateway:be:
desc: "Rebuilds the gateway be docker image in compose"
cmds:
- docker compose -f docker-compose.yml -f docker-compose-dev.yml build gateway
compose:rebuild:gateway:fe:
desc: "Rebuilds the gateway fe docker image in compose"
cmds:
- docker compose -f docker-compose.yml -f docker-compose-dev.yml build example-fe
compose:metalogix:
desc: "Starts up dependant services such as redis, nats and mongo and runs all apps in development mode with hot reloading"
cmds:
- docker compose -f docker-compose.yml -f docker-compose-metalogix.yml up -d
compose:metalogix:down:
desc: "Stops previously started containers using <compose:metalogix>"
cmds:
- docker compose -f docker-compose.yml -f docker-compose-metalogix.yml down
##############################################################################
# EXAMPLE
##############################################################################
example:
desc: "runs both the backend and frontend in local dev mode"
deps:
- example:be
- example:fe
cmds:
- echo "finished"
example:be:
desc: "builds the backend with hot reloading"
prefix: gateway-example
method: none
dir: example
cmds:
- fswatch -config .fsw.task.yml
env:
CONFIG_DIR: app/config
BASE_CONTEXT: base
example:fe:
desc: "starts the front end in dev mode with hmr support"
dir: example/web
cmds:
- yarn build:watch
env:
NODE_ENV: development
example:build:publish:
desc: "builds the example backend"
method: none
dir: example
cmds:
- GOOS=linux GOARCH=arm64 go build -gcflags="all=-N -l" -o bin/vth-gateway-example app/main.go && chmod 775 bin/vth-gateway-example
- docker buildx build --push --platform linux/arm64 -f docker/app/Dockerfile -t ghcr.io/azarc-io/verathread-gateway/gateway-be-example:${EX_VERSION}-linux-arm64 .
- GOOS=linux GOARCH=amd64 go build -gcflags="all=-N -l" -o bin/vth-gateway-example app/main.go && chmod 775 bin/vth-gateway-example
- docker buildx build --push --platform linux/amd64 -f docker/app/Dockerfile -t ghcr.io/azarc-io/verathread-gateway/gateway-be-example:${EX_VERSION}-linux-amd64 .
env:
EX_VERSION: v1.51.2
##############################################################################
# BUILD
##############################################################################
build:be:multi:
desc: "builds the backend for all platforms concurrently"
deps:
- task: build:be:amd
- task: build:be:arm
cmd: echo "finished building"
build:be:amd:
desc: "builds the backend"
cmds:
- CGO_ENABLED=0 GOOS={{.GOOS}} GOARCH={{.GOARCH}} go build -tags wg_composition_v8 -ldflags='-extldflags=-static -s -w' -o bin/{{.GOOS}}-{{.GOARCH}}/vth-gateway cmd/app/main.go
vars:
GOOS: '{{default "linux" .GOOS}}'
GOARCH: '{{default "amd64" .GOARCH}}'
build:be:arm:
desc: "builds the backend"
cmds:
- CGO_ENABLED=0 GOOS={{.GOOS}} GOARCH={{.GOARCH}} go build -ldflags='-extldflags=-static -s -w' -o bin/{{.GOOS}}-{{.GOARCH}}/vth-gateway cmd/app/main.go
vars:
GOOS: '{{default "linux" .GOOS}}'
GOARCH: '{{default "arm64" .GOARCH}}'
build:fe:
desc: "builds the frontend for production"
dir: cmd/web
cmds:
- echo "building for environment ${ENV_MODE}"
- yarn build --env-mode ${ENV_MODE}
env:
ENV_MODE: production
##############################################################################
# DOCKER
##############################################################################
docker:build:multi:
desc: "builds a docker image"
cmds:
- |
docker buildx build . -t $DOCKER_REGISTRY/$DOCKER_IMAGE:$DOCKER_VERSION \
--platform $PLATFORM \
--build-arg BINARY=bin/$PLATFORM_OS-$PLATFORM_ARCH/$BINARY_NAME \
--label="org.opencontainers.image.description=Verathread Gateway" \
--label="org.opencontainers.image.created={{now}}" \
--label="org.opencontainers.image.name=$DOCKER_IMAGE" \
--label="org.opencontainers.image.revision={{.GIT_COMMIT}}" \
--label="org.opencontainers.image.version=$DOCKER_VERSION" \
--label="org.opencontainers.image.source=$GIT_REPO" \
--annotation="index:org.opencontainers.image.description=Verathread Gateway Multi Platform Image" \
--cache-from type=gha \
--cache-to type=gha,mode=max \
--push \
-f $DOCKERFILE
env:
DOCKER_REGISTRY: "k3d-local-registry:5000"
DOCKER_IMAGE: "gateway-be"
DOCKER_VERSION: "dev"
PLATFORM: "linux/amd64,linux/arm64"
DOCKERFILE: "deployment/docker/app/Dockerfile.multi"
BUILDX_NO_DEFAULT_ATTESTATIONS: 1
vars:
GIT_COMMIT:
sh: git log -n 1 --format=%h
docker:re-tag:
desc: "re-tags a docker image"
cmds:
- docker buildx imagetools create -t $DOCKER_REGISTRY/$DOCKER_IMAGE:$TARGET_VERSION $DOCKER_REGISTRY/$DOCKER_IMAGE:$SOURCE_VERSION
env:
DOCKER_REGISTRY: "localhost:5000"
DOCKER_IMAGE: "gateway-be"
TARGET_VERSION: "dev"
SOURCE_VERSION: "dev"
##############################################################################
# LINT
##############################################################################
lint:be:
desc: "runs lint checks for the backend using golangci"
cmds:
- golangci-lint run
lint:be:fix:
desc: "lints go code using golangci and attempts to apply fixes"
cmds:
- golangci-lint run --fix
lint:fe:
desc: "runs lint checks for the frontend"
dir: cmd/web
cmds:
- yarn lint
##############################################################################
# TEST
##############################################################################
test:fe:
desc: "runs tests for the frontend"
dir: cmd/web
cmds:
- echo "not implemented yet"
##############################################################################
# CI
##############################################################################
ci:fe:install:
desc: "installs dependencies for ci"
dir: cmd/web
cmds:
- yarn install --prefer-offline --frozen-lockfile --non-interactive
##############################################################################
# SETUP
##############################################################################
setup:
desc: "run this if you are starting with a fresh checkout, see documentation for configuration instructions"
cmds:
- curl -fsSL https://raw.githubusercontent.com/tilt-dev/tilt/master/scripts/install.sh | bash
- task: setup:tilt:template
- task: setup:env:template
- go install github.com/codeskyblue/fswatch@latest
setup:container:
desc: "run this if you are starting with a fresh checkout, see documentation for configuration instructions"
cmds:
- go install github.com/codeskyblue/fswatch@latest
setup:tilt:template:
desc: "copies the tilt config template to the root of the project, will not overwrite if existing"
internal: true
cmds:
- cp deployment/template/_tilt_config.json tilt_config.json
status:
- test -f ./tilt_config.json
setup:env:template:
desc: "copies the .env template to the root of the project, will not overwrite if existing"
internal: true
cmds:
- cp deployment/template/env .env
status:
- test -f ./.env
##############################################################################
# DOCS
##############################################################################
docs:install:deps:
desc: "installs python dependencies for mkdocs - requires python 3+"
dir: docs
cmds:
- |
pip install \
mkdocs pymdown-extensions mkdocs-material \
mkdocs-extra-sass-plugin mkdocs-minify-plugin mkdocs-redirects livereload mkdocs-glightbox \
mkdocs-mermaid2-plugin mkdocs-drawio-file
docs:serve:
desc: "builds and serves documentation"
dir: docs
cmds:
- mkdocs serve
docs:build:
desc: "builds documentation and outputs to docs/site"
dir: docs
cmds:
- mkdocs build
##############################################################################
# TESTING
##############################################################################
test:
desc: "runs e2e tests using gotestsum"
cmds:
- gotestsum --junitfile-testcase-classname=short --jsonfile bin/toolkit_e2e.json --junitfile bin/toolkit_e2e.xml --junitfile-testsuite-name=short --format testname -- -timeout 15m -p 2 -count=1 ./internal/...
test:ci:unit:
desc: "runs e2e tests using gotestsum"
cmds:
- mkdir -p bin
- gotestsum -- -coverprofile=bin/unit.cover.out ./internal/...
##############################################################################
# CI
##############################################################################
ci:install:charts:
desc: "Installs dependency charts"
cmds:
- helm upgrade --install nats --create-namespace ./deployment/charts/nats --namespace $NAMESPACE --wait --set=local=false
- helm upgrade --install keydb --create-namespace ./deployment/charts/keydb --namespace $NAMESPACE --wait --set=local=false