forked from apache/openwhisk-runtime-go
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Taskfile.yml
164 lines (143 loc) · 4.82 KB
/
Taskfile.yml
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
# 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:
DRY: ""
PUSH: ""
BASETAG: 3.1.0-mastrogpt
BASEIMG: ghcr.io/nuvolaris
COMMON_VER: common1.17.1
COMMON: "{{.BASEIMG}}/runtime-common:{{.COMMON_VER}}"
TAG:
sh: git describe --tags --abbrev=0 2>/dev/null || echo latest
J: "{}"
RUNTIMES: "golang,nodejs,php,python"
tasks:
default:
- task --list-all
setup:
# check we are running in ubuntu
- grep '^ID=' /etc/os-release | grep -i ubuntu
- if ! which python3 | grep python3 ; then echo "python3 not found" ; exit 1; fi
- sudo apt-get -y install python3-pip python3-virtualenv
- python3 -m pip install ipython watchdog requests cram
image-tag:
silent: true
cmds:
- git tag -d $(git tag)
- |
if test -n "{{.RT}}"
then git tag -f {{.BASETAG}}-{{.RT}}.$(date +%y%m%d%H%M)
else git tag -f {{.BASETAG}}.$(date +%y%m%d%H%M)
fi
- env PAGER= git tag
compile: go build -o proxy
test:
dir: openwhisk
cmds:
- go test -v
docker-login:
ignore_error: true
cmds:
- echo ${MY_GITHUB_TOKEN:-$GITHUB_TOKEN} | docker login -u ${MY_GITHUB_USER:-$GITHUB_USER} --password-stdin ghcr.io
- >
{{.DRY}} docker run -it --rm --privileged tonistiigi/binfmt --install all
- >
{{.DRY}} docker buildx create --name mybuilder --bootstrap --use
clean-images:
- docker images -a | grep ghcr.io/nuvolaris | awk '{print $3}' | xargs docker rmi -f
- yes | docker buildx prune
build-common:
dir: "runtime/common/{{.COMMON_VER}}"
cmds:
- |
if test -n "{{.PUSH}}"
then {{.DRY}} docker buildx build -t "{{.COMMON}}" --platform linux/amd64,linux/arm64 . --push
else {{.DRY}} docker buildx build -t "{{.COMMON}}" . --load
fi
build-runtime:
requires: { vars: [RT, VER] }
dir: "runtime/{{.RT}}/{{.VER}}"
cmds:
- |
BASEIMG=$(echo "${MY_GITHUB_REGISTRY:-$GITHUB_REGISTRY}")
RUNTIME="{{.BASEIMG}}/runtime-{{.RT}}-{{.VER}}:{{.TAG}}"
if test -n "{{.PUSH}}"
then {{.DRY}} docker buildx build -t "$RUNTIME" --build-arg COMMON="{{.COMMON}}" --platform linux/amd64,linux/arm64 . --push
else {{.DRY}} docker buildx build -t "$RUNTIME" --build-arg COMMON="{{.COMMON}}" . --load
fi
echo "Built $RUNTIME"
build-lang:
desc: build images for one runtime
requires: {vars: [RT] }
vars:
DIRS:
sh: ls -d runtime/{{.RT}}/v* || echo ""
cmds:
- for: { var: DIRS }
task: build-runtime
vars:
VER: "{{base .ITEM}}"
build:
silent: true
requires: { vars: [TAG,RUNTIMES] }
vars:
RT_REGEX:
sh: echo "{{.RUNTIMES}}" | tr ',' '|'
SPECIFIC_RT:
sh: echo "{{.TAG}}" | grep -E -o '({{.RT_REGEX}})' || echo ''
cmds:
- |
if [ -z "{{.SPECIFIC_RT}}" ];
then
echo "==> BUILDING RUNTIMES {{.RUNTIMES}}"
for ITEM in `echo {{.RUNTIMES}} | tr ',' ' '`; do
echo "==> BUILDING $ITEM:{{.TAG}}"
task build-lang RT=$ITEM PUSH="{{.PUSH}}" DRY={{.DRY}}
done
else echo "Build {{.SPECIFIC_RT}}"
task build-lang RT={{.SPECIFIC_RT}} PUSH="{{.PUSH}}" DRY={{.DRY}}
fi
build-and-push:
- task build PUSH=y DRY={{.DRY}}
run:
desc: run a runtime
requires: { vars: [RT, VER] }
dir: "runtime/{{.RT}}/{{.VER}}"
cmds:
- >
{{.DRY}} docker run -p 8080:8080 -ti "{{.BASEIMG}}/runtime-{{.RT}}-{{.VER}}:{{.TAG}}"
debug:
desc: debug a runtime
requires: { vars: [RT, VER] }
dir: "runtime/{{.RT}}/{{.VER}}"
cmds:
- >
{{.DRY}} docker run -p 8080:8080 -ti
--entrypoint=/bin/bash -v $PWD:/mnt
-e OW_COMPILER=/mnt/bin/compile
"{{.BASEIMG}}/runtime-{{.RT}}-{{.VER}}:{{.TAG}}"
init:
desc: intialize a runtime with a test
requires: { vars: [RT, VER, T] }
cmds:
- python3 packages/invoke.py init packages/{{.RT}}/{{.T}}.zip
invoke:
desc: invoke a runtime listening in port 8080, optionally with J=<json>
cmds:
- python3 packages/invoke.py run '{{.J}}'