| # 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: "" |
| REPO_PATH: apache |
| BASEIMG: registry.hub.docker.com/{{.REPO_PATH}} |
| COMMON_VER: common1.17.1 |
| COMMON: "{{.BASEIMG}}/openserverless-runtime-common:{{.COMMON_VER}}" |
| EXPERIMENTAL_COMMON_VER: common1.18.2 |
| EXPERIMENTAL_COMMON: "{{.BASEIMG}}/openserverless-runtime-common:{{.EXPERIMENTAL_COMMON_VER}}" |
| TAG: |
| sh: git describe --tags --abbrev=0 2>/dev/null || echo latest |
| J: "{}" |
| RUNTIMES: "go,nodejs,php,python,java" |
| EXPERIMENTAL_RUNTIMES: "python" |
| COMMIT_ID: |
| sh: git rev-parse --short HEAD |
| |
| 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 {{.RT}}.$(date +%y%m%d%H%M) |
| else git tag -f $(date +%y%m%d%H%M) |
| fi |
| - env PAGER= git tag |
| |
| common-tag: |
| silent: true |
| cmds: |
| - git tag -d $(git tag) |
| - git tag -f common-$(date +%y%m%d%H%M) |
| |
| - env PAGER= git tag |
| |
| compile: go build -o proxy |
| |
| test: |
| dir: openwhisk |
| cmds: |
| - go test -v |
| |
| docker-login: |
| ignore_error: true |
| cmds: |
| - echo ${MY_DOCKER_HUB_TOKEN:-$DOCKER_HUB_TOKEN} | docker login -u ${MY_DOCKER_HUB_USER:-$DOCKER_HUB_USER} --password-stdin registry.hub.docker.com |
| - > |
| {{.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_DOCKER_HUB_REGISTRY:-$DOCKER_HUB_REGISTRY}") |
| RUNTIME="{{.BASEIMG}}/openserverless-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}}/openserverless-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}}/openserverless-runtime-{{.RT}}:{{.VER}}-{{.TAG}}" |
| |
| debug-experimental: |
| desc: debug a runtime |
| requires: { vars: [RT, VER] } |
| dir: "runtime/experimental/{{.RT}}/{{.VER}}" |
| cmds: |
| - > |
| BASEIMG="${MY_DOCKER_HUB_REGISTRY:-$DOCKER_HUB_REGISTRY}" ; |
| {{.DRY}} docker run -p 8080:8080 -ti |
| --entrypoint=/bin/bash -v $PWD:/mnt |
| -e OW_COMPILER=/mnt/bin/compile |
| "${BASEIMG}/openserverless-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}}' |
| |
| |
| render-runtime: |
| requires: { vars: [RT, VER] } |
| dir: "runtime/{{.RT}}/{{.VER}}" |
| cmds: |
| - | |
| BASEIMG=$(echo "${MY_DOCKER_HUB_REGISTRY:-$DOCKER_HUB_REGISTRY}") |
| RUNTIME="{{.BASEIMG}}/openserverless-runtime-{{.RT}}:{{.VER}}-{{.TAG}}" |
| ENVVER=$(echo "{{.VER}}" | tr '.' '_' | tr '[:upper:][:lower:]' '[:lower:][:upper:]') |
| ENVRT=$(echo "{{.RT}}" | tr '[a-zA-Z]' '[A-Za-z]') |
| if test -n "{{.PUSH}}" |
| then |
| {{.DRY}} echo "OPS_RUNTIME_TAG_${ENVRT}_${ENVVER}={{.VER}}-{{.TAG}}" >> {{.BASE_DIR}}/runtimes.env |
| else {{.DRY}} echo "OPS_RUNTIME_TAG_${ENVRT}_${ENVVER}={{.VER}}-{{.TAG}}" |
| fi |
| echo "Rendered $RUNTIME" |
| |
| render-lang: |
| desc: render images for one runtime |
| requires: {vars: [RT,BASE_DIR] } |
| vars: |
| DIRS: |
| sh: ls -d runtime/{{.RT}}/v* || echo "" |
| cmds: |
| - for: { var: DIRS } |
| task: render-runtime |
| vars: |
| VER: "{{base .ITEM}}" |
| BASE_DIR: "{{.BASE_DIR}}" |
| |
| render: |
| silent: true |
| requires: { vars: [TAG,RUNTIMES] } |
| vars: |
| RT_REGEX: |
| sh: echo "{{.RUNTIMES}}" | tr ',' '|' |
| SPECIFIC_RT: |
| sh: echo "{{.TAG}}" | grep -E -o '({{.RT_REGEX}})' || echo '' |
| BASE_DIR: |
| sh: pwd |
| cmds: |
| - | |
| rm -f runtimes.env |
| echo "OPS_RUNTIME_PREFIX={{.REPO_PATH}}" >> runtimes.env |
| echo "==> RENDERING RUNTIMES {{.RUNTIMES}}" |
| for ITEM in `echo {{.RUNTIMES}} | tr ',' ' '`; do |
| echo "==> RENDERINGG $ITEM:{{.TAG}}" |
| task render-lang RT=$ITEM PUSH="{{.PUSH}}" DRY={{.DRY}} BASE_DIR="{{.BASE_DIR}}" |
| done |
| |
| generate-runtimes: |
| silent: true |
| dotenv: |
| - runtimes.env |
| cmds: |
| - cat runtimes.json.tpl | envsubst > runtimes.json |
| |
| render-runtimes: |
| silent: true |
| desc: generate a runtimes.json file with all the runtime corresponding to the current TAG |
| cmds: |
| - | |
| task render PUSH=y |
| task generate-runtimes |
| |
| build-experimental-runtime: |
| requires: { vars: [RT, VER] } |
| dir: "runtime/experimental/{{.RT}}/{{.VER}}" |
| cmds: |
| - | |
| BASEIMG=$(echo "${MY_DOCKER_HUB_REGISTRY:-$DOCKER_HUB_REGISTRY}") |
| RUNTIME="$BASEIMG/openserverless-runtime-{{.RT}}:{{.VER}}-{{.TAG}}" |
| PLATFORMS=$(cat platforms.txt) |
| if test -n "{{.PUSH}}" |
| then |
| {{.DRY}} docker buildx build -t "$RUNTIME" --build-arg COMMON="{{.EXPERIMENTAL_COMMON}}" --platform "$PLATFORMS" . --push |
| else {{.DRY}} docker buildx build -t "$RUNTIME" --build-arg COMMON="{{.EXPERIMENTAL_COMMON}}" . --load |
| fi |
| echo "Built $RUNTIME on platforms $PLATFORMS" |
| |
| build-experimental-lang: |
| desc: build images for experimental runtimes |
| requires: {vars: [RT] } |
| vars: |
| DIRS: |
| sh: ls -d runtime/experimental/{{.RT}}/v* || echo "" |
| cmds: |
| - for: { var: DIRS } |
| task: build-experimental-runtime |
| vars: |
| VER: "{{base .ITEM}}" |
| |
| build-experimental-runtimes: |
| silent: true |
| requires: { vars: [TAG,EXPERIMENTAL_RUNTIMES] } |
| vars: |
| RT_REGEX: |
| sh: echo "{{.EXPERIMENTAL_RUNTIMES}}" | tr ',' '|' |
| SPECIFIC_RT: |
| sh: echo "{{.TAG}}" | grep -E -o '({{.RT_REGEX}})' || echo '' |
| cmds: |
| - | |
| if [ -z "{{.SPECIFIC_RT}}" ]; |
| then |
| echo "==> BUILDING RUNTIMES {{.EXPERIMENTAL_RUNTIMES}}" |
| for ITEM in `echo {{.EXPERIMENTAL_RUNTIMES}} | tr ',' ' '`; do |
| echo "==> BUILDING $ITEM:{{.TAG}}" |
| task build-experimental-lang RT=$ITEM PUSH="{{.PUSH}}" DRY={{.DRY}} |
| done |
| else echo "Build {{.SPECIFIC_RT}}" |
| task build-experimental-lang RT={{.SPECIFIC_RT}} PUSH="{{.PUSH}}" DRY={{.DRY}} |
| fi |