From cebabbf7eacba5818c3d86a3916da244f3c17d6e Mon Sep 17 00:00:00 2001 From: Qi Zheng Date: Wed, 11 Dec 2019 05:25:39 +0000 Subject: [PATCH] Add helper_script for python3-clearlinux template Give a chance to function developers to add extra initial/helper operation when using the template python3-clearlinux. Signed-off-by: Qi Zheng --- FaaS/OpenFaaS/template/README.md | 5 +++++ FaaS/OpenFaaS/template/python3-clearlinux/Dockerfile | 4 ++++ .../template/python3-clearlinux/function/helper_script.sh | 1 + 3 files changed, 10 insertions(+) create mode 100644 FaaS/OpenFaaS/template/python3-clearlinux/function/helper_script.sh diff --git a/FaaS/OpenFaaS/template/README.md b/FaaS/OpenFaaS/template/README.md index 656b950..14685de 100644 --- a/FaaS/OpenFaaS/template/README.md +++ b/FaaS/OpenFaaS/template/README.md @@ -72,6 +72,7 @@ Steps could refer to ├── hello-openfaas │   ├── bundles.txt │   ├── handler.py + │   ├── helper_script.sh │   ├── __init__.py │   └── requirements.txt ├── hello-openfaas.yml @@ -89,6 +90,10 @@ Steps could refer to `echo "openblas" >> hello-openfaas/bundles.txt` `echo "wget" >> hello-openfaas/bundles.txt` + + * Put any initial/helper operation in the "help_script.sh" + + 4. `faas-cli up -f hello-openfaas.yml` Then you can invoke your python function by OpenFaas UI or faas-cli. diff --git a/FaaS/OpenFaaS/template/python3-clearlinux/Dockerfile b/FaaS/OpenFaaS/template/python3-clearlinux/Dockerfile index a40be1e..58dabcc 100644 --- a/FaaS/OpenFaaS/template/python3-clearlinux/Dockerfile +++ b/FaaS/OpenFaaS/template/python3-clearlinux/Dockerfile @@ -35,6 +35,10 @@ RUN for bundle in $(cat bundles.txt); do \ swupd bundle-add $bundle $swupd_args; \ done +# give a chance to run help script +COPY function/helper_script.sh . +RUN chmod +x helper_script.sh && ./helper_script.sh + WORKDIR /root/ COPY function function diff --git a/FaaS/OpenFaaS/template/python3-clearlinux/function/helper_script.sh b/FaaS/OpenFaaS/template/python3-clearlinux/function/helper_script.sh new file mode 100644 index 0000000..a9bf588 --- /dev/null +++ b/FaaS/OpenFaaS/template/python3-clearlinux/function/helper_script.sh @@ -0,0 +1 @@ +#!/bin/bash