-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTaskfile.yml
More file actions
511 lines (467 loc) · 16.1 KB
/
Copy pathTaskfile.yml
File metadata and controls
511 lines (467 loc) · 16.1 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
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
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
version: '3'
dotenv:
- .env
vars:
BASETAG: 2.0.0-incubating
TAG:
sh: |
if test -n "${TAG:-}"; then
echo "$TAG"
else
git describe --tags --abbrev=0 2>/dev/null || git rev-parse --short HEAD
fi
GHUSER:
sh: echo "${GITHUB_USER:-apache}"
BUN:
sh: |
if command -v bun >/dev/null 2>&1; then
command -v bun
exit 0
fi
os="$(uname -s | tr A-Z a-z)"
arch="$(uname -m)"
case "$arch" in
x86_64) arch=amd64 ;;
aarch64|arm64) arch=arm64 ;;
esac
if test -x "$HOME/.ops/${os}-${arch}/bin/bun"; then
echo "$HOME/.ops/${os}-${arch}/bin/bun"
else
echo bun
fi
OPSROOT_JSON:
sh: echo "$HOME/.ops/0.1.0/olaris/opsroot.json"
KIND_NODE: nuvolaris-control-plane
KUBE_NAMESPACE: nuvolaris
DOCKER_REGISTRY: docker.io/apache
LOCAL_DOCKER_REGISTRY:
sh: echo "${LOCAL_DOCKER_REGISTRY:-localhost:5000/apache}"
LOCAL_REGISTRY_CONTAINER:
sh: echo "${LOCAL_REGISTRY_CONTAINER:-openserverless-registry}"
BUILDX_BUILDER: openserverless-buildx
DIST_DOCKER_REGISTRY: ""
DIST_DOCKER_REGISTRY_ARG:
sh: |
if test -n "{{.DIST_DOCKER_REGISTRY}}"; then
echo "-PdockerRegistry={{.DIST_DOCKER_REGISTRY}}"
fi
CONTROLLER_IMAGE: openserverless-wsk-controller
INVOKER_IMAGE: openserverless-wsk-invoker
SCHEDULER_IMAGE: openserverless-wsk-scheduler
STANDALONE_IMAGE: openserverless-wsk-standalone
COMMON_IMAGE: openserverless-wsk-scala
ACT: "nothing"
S: ""
tasks:
default:
- task --list-all
setup:
silent: true
ensure-openwhisk:
silent: true
cmds:
- |
if ! test -d openwhisk/common/scala; then
echo "ERROR: openwhisk directory is missing or incomplete."
echo "This branch vendors openwhisk as a regular directory, not as a submodule."
echo "Refresh the build checkout and make sure the build-local branch includes openwhisk/common/scala."
exit 1
fi
image-tag:
- git tag -d $(git tag)
- git tag -f {{.BASETAG}}.$(date +%y%m%d%H%M){{.S}}
- task show
show:
silent: true
cmds:
- echo "tag:" {{.TAG}}
- echo "scala:" {{.COMMON_IMAGE}}:{{.TAG}}
- echo "controller:" ${MY_CONTROLLER_IMAGE:-{{.CONTROLLER_IMAGE}}}:{{.TAG}}
- echo "invoker:" ${MY_INVOKER_IMAGE:-{{.INVOKER_IMAGE}}}:{{.TAG}}
- echo "scheduler:" ${MY_SCHEDULER_IMAGE:-{{.INVOKER_IMAGE}}}:{{.TAG}}
- echo "standalone:" ${MY_STANDALONE_IMAGE:-{{.STANDALONE_IMAGE}}}:{{.TAG}}
compile:controller:
dir: openwhisk
cmds:
- ./gradlew :core:controller:distTar
status:
- test -f core/controller/build/distributions/controller.tar
compile:invoker:
dir: openwhisk
cmds:
- ./gradlew :core:invoker:distTar
status:
- test -f core/invoker/build/distributions/invoker.tar
compile:scheduler:
dir: openwhisk
cmds:
- ./gradlew :core:scheduler:distTar
status:
- test -f core/scheduler/build/distributions/scheduler.tar
compile:standalone:
dir: openwhisk
cmds:
- ./gradlew :core:standalone:build
- mkdir -p ../standalone/lib
- cp bin/openwhisk-standalone.jar ../standalone/lib/
status:
- test -f ../standalone/lib/openwhisk-standalone.jar
native:standalone-libs:
deps:
- compile:standalone
dir: openwhisk
cmds:
- ./gradlew core:standalone:copyRuntimeLibs
native:standalone-build:
deps:
- native:standalone-libs
dir: openwhisk/core/standalone
cmds:
- native-image
--initialize-at-run-time=io.netty,akka.protobufv3.internal.UnsafeUtil
--no-fallback --report-unsupported-elements-at-runtime
--trace-object-instantiation=ch.qos.logback.classic.Logger
--enable-url-protocols=http,https
-march=native
-cp build/classes/scala/main:build/resources/main:build/dependency-libs/*
-H:ConfigurationFileDirectories=$PWD/../../../standalone/graal-config
-o $PWD/../../../standalone/dist/{{.EXEC_NAME}}
org.apache.openwhisk.standalone.StandaloneOpenWhisk
vars:
EXEC_NAME: "${NATIVE_IMAGE_NAME:-openwhisk-standalone}"
native:standalone-run:
dir: standalone/dist
cmds:
- ./openwhisk-standalone -Xmx2g -Dwhisk.standalone.host.name="0.0.0.0" -Dwhisk.standalone.host.internal="$(hostname -f)" -Dkamon.auto-start=no --no-browser
env:
KAMON_ENABLED: false
native:standalone-config:
deps:
- compile:standalone
dir: openwhisk/core/standalone
cmds:
- java -agentlib:native-image-agent=config-output-dir=../../../standalone/graal-config
-cp build/classes/scala/main:build/resources/main:build/dependency-libs/*
-Dwhisk.standalone.host.name="0.0.0.0"
-Dwhisk.standalone.host.internal="$(hostname -f)"
org.apache.openwhisk.standalone.StandaloneOpenWhisk
clean:
ignore_error: true
cmds:
- rm standalone/lib/openwhisk-standalone.jar
- rm openwhisk/core/invoker/build/distributions/invoker.tar
- rm openwhisk/core/controller/build/distributions/controller.tar
- rm openwhisk/core/scheduler/build/distributions/scheduler.tar
- docker buildx rm {{.BUILDX_BUILDER}}
compile:
- task: compile:controller
- task: compile:invoker
- task: compile:scheduler
- task: compile:standalone
docker-setup:
- docker run --rm --privileged tonistiigi/binfmt --install all
- docker buildx inspect {{.BUILDX_BUILDER}} >/dev/null 2>&1 || docker buildx create --name {{.BUILDX_BUILDER}} --driver docker-container --driver-opt network=host
- docker buildx use {{.BUILDX_BUILDER}}
- docker buildx inspect --bootstrap
docker-local-registry:
silent: true
cmds:
- |
if docker container inspect {{.LOCAL_REGISTRY_CONTAINER}} >/dev/null 2>&1; then
docker start {{.LOCAL_REGISTRY_CONTAINER}} >/dev/null
else
docker run -d --restart=always -p 5000:5000 --name {{.LOCAL_REGISTRY_CONTAINER}} registry:2 >/dev/null
fi
docker-login: >
echo $GITHUB_TOKEN | docker login ghcr.io -u $GITHUB_USER --password-stdin
# this requires ACT IMG and DIR parameters to be passed
docker-build:
silent: true
cmds:
- |-
echo "***" {{.ACT}} for {{.IMG}} in {{.DIR}}
case "{{.ACT}}" in
(build)
docker build {{.DIR}} -t {{.IMG}} --build-arg BASE={{.BASE}}
;;
(buildx)
docker buildx build --platform linux/amd64,linux/arm64 --build-arg BASE={{.BASE}} -t {{.IMG}} {{.DIR}}
;;
(buildx-local)
docker buildx build --platform linux/amd64,linux/arm64 --build-arg BASE={{.BASE}} -t {{.IMG}} {{.DIR}} --push
;;
(buildx-push)
docker buildx build --platform linux/amd64,linux/arm64 --build-arg BASE={{.BASE}} -t {{.IMG}} {{.DIR}} --push
;;
(*) echo ACT must be "build|buildx|buildx-local|buildx-push"
esac
# this requires ACT IMG OPENWHISK_JAR and DIR parameters to be passed
docker-build-standalone:
silent: true
cmds:
- |-
echo "***" {{.ACT}} for {{.IMG}} in {{.DIR}}
case "{{.ACT}}" in
(build)
docker build {{.DIR}} -t {{.IMG}} --build-arg BASE={{.BASE}} --build-arg OPENWHISK_JAR={{.OPENWHISK_JAR}}
;;
(buildx)
docker buildx build --platform linux/amd64,linux/arm64 --build-arg BASE={{.BASE}} --build-arg OPENWHISK_JAR={{.OPENWHISK_JAR}} -t {{.IMG}} {{.DIR}}
;;
(buildx-local)
docker buildx build --platform linux/amd64,linux/arm64 --build-arg BASE={{.BASE}} --build-arg OPENWHISK_JAR={{.OPENWHISK_JAR}} -t {{.IMG}} {{.DIR}} --push
;;
(buildx-push)
docker buildx build --platform linux/amd64,linux/arm64 --build-arg BASE={{.BASE}} --build-arg OPENWHISK_JAR={{.OPENWHISK_JAR}} -t {{.IMG}} {{.DIR}} --push
;;
(*) echo ACT must be "build|buildx|buildx-local|buildx-push"
esac
build:scala:
cmds:
- task: docker-build
vars:
DIR: openwhisk/common/scala
IMG: "{{.DOCKER_REGISTRY}}/{{.COMMON_IMAGE}}:{{.TAG}}"
ACT: '{{.ACT}}'
build:controller:
deps:
- compile:controller
cmds:
- task: docker-build
vars:
DIR: openwhisk/core/controller
IMG: "{{.DOCKER_REGISTRY}}/${MY_CONTROLLER_IMAGE:-{{.CONTROLLER_IMAGE}}}:{{.TAG}}"
ACT: '{{.ACT}}'
BASE: "{{.DOCKER_REGISTRY}}/{{.COMMON_IMAGE}}:{{.TAG}}"
build:invoker:
deps:
- compile:invoker
cmds:
- task: docker-build
vars:
DIR: openwhisk/core/invoker
IMG: "{{.DOCKER_REGISTRY}}/${MY_INVOKER_IMAGE:-{{.INVOKER_IMAGE}}}:{{.TAG}}"
ACT: '{{.ACT}}'
BASE: "{{.DOCKER_REGISTRY}}/{{.COMMON_IMAGE}}:{{.TAG}}"
build:scheduler:
deps:
- compile:scheduler
cmds:
- task: docker-build
vars:
DIR: openwhisk/core/scheduler
IMG: "{{.DOCKER_REGISTRY}}/${MY_SCHEDULER_IMAGE:-{{.SCHEDULER_IMAGE}}}:{{.TAG}}"
ACT: '{{.ACT}}'
BASE: "{{.DOCKER_REGISTRY}}/{{.COMMON_IMAGE}}:{{.TAG}}"
build:standalone:
deps:
- compile:standalone
cmds:
- task: docker-build-standalone
vars:
DIR: openwhisk/core/standalone
IMG: "{{.DOCKER_REGISTRY}}/${MY_STANDALONE_IMAGE:-{{.STANDALONE_IMAGE}}}:{{.TAG}}"
ACT: '{{.ACT}}'
BASE: "{{.DOCKER_REGISTRY}}/{{.COMMON_IMAGE}}:{{.TAG}}"
OPENWHISK_JAR: "build/libs/openwhisk-standalone-1.0.0-SNAPSHOT.jar"
build-all:
cmds:
- |
if test "${OPENWHISK_BUILDCONTAINER:-}" = "1"; then
task build-all:local
else
printf '%s\n' 'mkdir -p /tmp/openserverless-docker-config && printf "{}\n" >/tmp/openserverless-docker-config/config.json && OPENWHISK_BUILDCONTAINER=1 DOCKER_CONFIG=/tmp/openserverless-docker-config TAG="{{.TAG}}" task build-all:local' | ops ide devcontainer
fi
build-all:local:
cmds:
- task: ensure-openwhisk
- task: build:scala
vars:
ACT: "build"
- task: build:controller
vars:
ACT: "build"
- task: build:invoker
vars:
ACT: "build"
- task: build:scheduler
vars:
ACT: "build"
- task: build:standalone
vars:
ACT: "build"
buildx-all:
desc: build multi-arch OpenWhisk images into a local registry without pushing to DockerHub
cmds:
- |
if test "${OPENWHISK_BUILDCONTAINER:-}" = "1"; then
task buildx-all:local
else
if docker ps | grep vsc-build
then docker rm -f $(docker ps | awk '/vsc-build/{print $1}')
fi
printf '%s\n' 'mkdir -p /tmp/openserverless-docker-config && printf "{}\n" >/tmp/openserverless-docker-config/config.json && OPENWHISK_BUILDCONTAINER=1 DOCKER_CONFIG=/tmp/openserverless-docker-config TAG="{{.TAG}}" task buildx-all:local' | ops ide devcontainer
fi
buildx-all:local:
cmds:
- task: docker-setup
- task: docker-local-registry
- task: ensure-openwhisk
- task: build:scala
vars:
ACT: "buildx-local"
DOCKER_REGISTRY: "{{.LOCAL_DOCKER_REGISTRY}}"
- task: build:controller
vars:
ACT: "buildx-local"
DOCKER_REGISTRY: "{{.LOCAL_DOCKER_REGISTRY}}"
- task: build:invoker
vars:
ACT: "buildx-local"
DOCKER_REGISTRY: "{{.LOCAL_DOCKER_REGISTRY}}"
- task: build:scheduler
vars:
ACT: "buildx-local"
DOCKER_REGISTRY: "{{.LOCAL_DOCKER_REGISTRY}}"
- task: build:standalone
vars:
ACT: "buildx-local"
DOCKER_REGISTRY: "{{.LOCAL_DOCKER_REGISTRY}}"
build:
desc: build local OpenWhisk images, update OPS root, load kind, and roll out controller
cmds:
- task: deploy-kind-local
deploy-kind-local:
desc: build local OpenWhisk images, update OPS root, load kind, and roll out controller
deps:
- build-all
cmds:
- task: kind:deploy
opsroot:update:
desc: update installed OPS root with local OpenWhisk image tags
silent: true
cmds:
- "{{.BUN}} scripts/kind-local.ts update-opsroot"
env:
TAG: "{{.TAG}}"
DOCKER_REGISTRY: "{{.DOCKER_REGISTRY}}"
CONTROLLER_IMAGE: "{{.CONTROLLER_IMAGE}}"
INVOKER_IMAGE: "{{.INVOKER_IMAGE}}"
STANDALONE_IMAGE: "{{.STANDALONE_IMAGE}}"
OPSROOT_JSON: "{{.OPSROOT_JSON}}"
kind:load:
desc: load local OpenWhisk images into the kind node
silent: true
cmds:
- "{{.BUN}} scripts/kind-local.ts load-kind"
env:
TAG: "{{.TAG}}"
DOCKER_REGISTRY: "{{.DOCKER_REGISTRY}}"
CONTROLLER_IMAGE: "{{.CONTROLLER_IMAGE}}"
INVOKER_IMAGE: "{{.INVOKER_IMAGE}}"
STANDALONE_IMAGE: "{{.STANDALONE_IMAGE}}"
KIND_NODE: "{{.KIND_NODE}}"
kind:rollout:
desc: update local kind OpenWhisk workloads to the local images
silent: true
cmds:
- "{{.BUN}} scripts/kind-local.ts rollout"
env:
TAG: "{{.TAG}}"
DOCKER_REGISTRY: "{{.DOCKER_REGISTRY}}"
CONTROLLER_IMAGE: "{{.CONTROLLER_IMAGE}}"
INVOKER_IMAGE: "{{.INVOKER_IMAGE}}"
STANDALONE_IMAGE: "{{.STANDALONE_IMAGE}}"
KUBE_NAMESPACE: "{{.KUBE_NAMESPACE}}"
kind:status:
desc: show local image, kind image, and pod image status
silent: true
cmds:
- "{{.BUN}} scripts/kind-local.ts status"
env:
TAG: "{{.TAG}}"
DOCKER_REGISTRY: "{{.DOCKER_REGISTRY}}"
CONTROLLER_IMAGE: "{{.CONTROLLER_IMAGE}}"
INVOKER_IMAGE: "{{.INVOKER_IMAGE}}"
STANDALONE_IMAGE: "{{.STANDALONE_IMAGE}}"
KIND_NODE: "{{.KIND_NODE}}"
KUBE_NAMESPACE: "{{.KUBE_NAMESPACE}}"
kind:deploy:
desc: update OPS root, load local images into kind, and roll out OpenWhisk
silent: true
cmds:
- "{{.BUN}} scripts/kind-local.ts deploy-kind"
env:
TAG: "{{.TAG}}"
DOCKER_REGISTRY: "{{.DOCKER_REGISTRY}}"
CONTROLLER_IMAGE: "{{.CONTROLLER_IMAGE}}"
INVOKER_IMAGE: "{{.INVOKER_IMAGE}}"
STANDALONE_IMAGE: "{{.STANDALONE_IMAGE}}"
OPSROOT_JSON: "{{.OPSROOT_JSON}}"
KIND_NODE: "{{.KIND_NODE}}"
KUBE_NAMESPACE: "{{.KUBE_NAMESPACE}}"
buildx-and-push:
- task: docker-setup
- task: build:scala
vars:
ACT: "buildx-push"
- task: build:controller
vars:
ACT: "buildx-push"
- task: build:invoker
vars:
ACT: "buildx-push"
- task: build:scheduler
vars:
ACT: "buildx-push"
- task: build:standalone
vars:
ACT: "buildx-push"
distdocker:
cmds:
- |
if test "${OPENWHISK_BUILDCONTAINER:-}" = "1"; then
task distdocker:local
else
printf '%s\n' 'mkdir -p /tmp/openserverless-docker-config && printf "{}\n" >/tmp/openserverless-docker-config/config.json && OPENWHISK_BUILDCONTAINER=1 DOCKER_CONFIG=/tmp/openserverless-docker-config TAG="{{.TAG}}" task distdocker:local' | ops ide devcontainer
fi
distdocker:local:
deps:
- ensure-openwhisk
dir: openwhisk
cmds:
- ./gradlew distDocker -PdockerMultiArchBuild=true {{.DIST_DOCKER_REGISTRY_ARG}} -PdockerImagePrefix=openwhisk2 -PdockerImageTag={{.TAG}}
run:standalone-docker:
cmds:
- >
docker run -ti
-p 3232:3232 -p 3233:3233
-v /var/run/docker.sock:/var/run/docker.sock
{{.DOCKER_REGISTRY}}/openwhisk2/standalone:{{.TAG}}
interactive: true
run:standalone:
deps:
- native:standalone-libs
dir: openwhisk/core/standalone
cmds:
- java -cp build/classes/scala/main:build/resources/main:build/dependency-libs/*
-Dwhisk.standalone.host.name="0.0.0.0"
-Dwhisk.standalone.host.internal="$(hostname -f)"
org.apache.openwhisk.standalone.StandaloneOpenWhisk --no-browser