diff --git a/hello-world-node/README.md b/hello-world-node/README.md new file mode 100644 index 0000000..0ab1c62 --- /dev/null +++ b/hello-world-node/README.md @@ -0,0 +1,40 @@ +# Sample Function Node + +> When having poor network connectivity to GitHub/Googleapis: +> +> Change ```gcr.io/buildpacks/builder``` to ```openfunction/buildpacks-builder:v1``` + +## Run Locally with Buildpacks & Docker: +``` +pack build --builder=gcr.io/buildpacks/builder hello-world-node +``` + +## Run on OpenFunction: + +1. [Install OpenFunction](https://github.com/OpenFunction/OpenFunction#quickstart) +2. [Run a function](https://github.com/OpenFunction/OpenFunction#sample-run-a-function) + +Definition of a ```Function``` for ```node``` is shown below: + +```yaml +apiVersion: core.openfunction.io/v1alpha1 +kind: Function +metadata: + name: node-sample +spec: + funcName: "helloWorld" + funcType: "http" + funcVersion: "v1.0.0" + builder: "gcr.io/buildpacks/builder:v1" + source: + url: "https://github.com/OpenFunction/function-samples.git" + sourceSubPath: "hello-world-node" + image: "/sample-node-func:latest" + registry: + url: "https://index.docker.io/v1/" + account: + name: "basic-user-pass" + key: "username" + runtime: "Knative" + port: 8080 +``` \ No newline at end of file diff --git a/hello-world-node/index.js b/hello-world-node/index.js new file mode 100644 index 0000000..26ef1ae --- /dev/null +++ b/hello-world-node/index.js @@ -0,0 +1,3 @@ +exports.helloWorld = (req, res) => { + res.send('hello, world'); +}; diff --git a/hello-world-python/README.md b/hello-world-python/README.md new file mode 100644 index 0000000..b323947 --- /dev/null +++ b/hello-world-python/README.md @@ -0,0 +1,40 @@ +# Sample Function Python + +> When having poor network connectivity to GitHub/Googleapis: +> +> Change ```gcr.io/buildpacks/builder``` to ```openfunction/buildpacks-builder:v1``` + +## Run Locally with Buildpacks & Docker: +``` +pack build --builder=gcr.io/buildpacks/builder hello-world-python +``` + +## Run on OpenFunction: + +1. [Install OpenFunction](https://github.com/OpenFunction/OpenFunction#quickstart) +2. [Run a function](https://github.com/OpenFunction/OpenFunction#sample-run-a-function) + +Definition of a ```Function``` for ```python``` is shown below: + +```yaml +apiVersion: core.openfunction.io/v1alpha1 +kind: Function +metadata: + name: python-sample +spec: + funcName: "hello_world" + funcType: "http" + funcVersion: "v1.0.0" + builder: "gcr.io/buildpacks/builder:v1" + source: + url: "https://github.com/OpenFunction/function-samples.git" + sourceSubPath: "hello-world-python" + image: "/sample-python-func:latest" + registry: + url: "https://index.docker.io/v1/" + account: + name: "basic-user-pass" + key: "username" + runtime: "Knative" + port: 8080 +``` \ No newline at end of file diff --git a/hello-world-python/main.py b/hello-world-python/main.py new file mode 100644 index 0000000..249f1b8 --- /dev/null +++ b/hello-world-python/main.py @@ -0,0 +1,2 @@ +def hello_world(request): + return "hello, world" diff --git a/hello-world-python/requirements.txt b/hello-world-python/requirements.txt new file mode 100644 index 0000000..bc9616b --- /dev/null +++ b/hello-world-python/requirements.txt @@ -0,0 +1 @@ +functions-framework==1.4.3 \ No newline at end of file