45 |
46 |
47 | WebApp with Vert.x and Java
48 |
49 |
50 | Hosted with ❤️ on OpenFaaS
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/template/python-waitress/template/java11-vert-x/function/src/test/java/HandlerTest.java:
--------------------------------------------------------------------------------
1 | import org.junit.Test;
2 | import static org.junit.Assert.*;
3 |
4 | import com.openfaas.function.Handler;
5 |
6 | public class HandlerTest {
7 | @Test public void handlerIsNotNull() {
8 | Handler handler = new Handler();
9 | assertTrue("Expected handler not to be null", handler != null);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/template/python-waitress/template/java11-vert-x/settings.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * This file was generated by the Gradle 'init' task.
3 | *
4 | * The settings file is used to specify which projects to include in your build.
5 | *
6 | * Detailed information about configuring a multi-project build in Gradle can be found
7 | * in the user guide at https://docs.gradle.org/4.8.1/userguide/multi_project_builds.html
8 | */
9 |
10 | rootProject.name = 'java8-vert-x'
11 |
12 | include 'function', 'entrypoint'
13 |
--------------------------------------------------------------------------------
/template/python-waitress/template/java11-vert-x/template.yml:
--------------------------------------------------------------------------------
1 | language: java8-vert-x
2 |
--------------------------------------------------------------------------------
/template/python-waitress/template/java11/README.md:
--------------------------------------------------------------------------------
1 | ## Template: java11
2 |
3 | The Java11 template uses gradle as a build system.
4 |
5 | Gradle version: 5.5.1
6 |
7 | ### Structure
8 |
9 | There are three projects which make up a single gradle build:
10 |
11 | - model - (Library) classes for parsing request/response
12 | - function - (Library) your function code as a developer, you will only ever see this folder
13 | - entrypoint - (App) HTTP server for re-using the JVM between requests
14 |
15 | ### Handler
16 |
17 | The handler is written in the `./src/main/Handler.java` folder
18 |
19 | Tests are supported with junit via files in `./src/test`
20 |
21 | ### External dependencies
22 |
23 | External dependencies can be specified in ./build.gradle in the normal way using jcenter, a local JAR or some other remote repository.
24 |
25 |
--------------------------------------------------------------------------------
/template/python-waitress/template/java11/build.gradle:
--------------------------------------------------------------------------------
1 | allprojects {
2 | repositories {
3 | jcenter()
4 | }
5 | }
6 |
7 | subprojects {
8 | version = '1.0'
9 | }
10 |
11 | repositories {
12 | jcenter()
13 |
14 | flatDir {
15 | dirs 'libs'
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/template/python-waitress/template/java11/function/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/container-registry/container-vending-machine/ca9c86373d1d97e75cedf4bf3e185661019fb640/template/python-waitress/template/java11/function/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/template/python-waitress/template/java11/function/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/template/python-waitress/template/java11/function/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'function'
2 |
--------------------------------------------------------------------------------
/template/python-waitress/template/java11/function/src/main/java/com/openfaas/function/Handler.java:
--------------------------------------------------------------------------------
1 | package com.openfaas.function;
2 |
3 | import com.openfaas.model.IHandler;
4 | import com.openfaas.model.IResponse;
5 | import com.openfaas.model.IRequest;
6 | import com.openfaas.model.Response;
7 |
8 | public class Handler extends com.openfaas.model.AbstractHandler {
9 |
10 | public IResponse Handle(IRequest req) {
11 | Response res = new Response();
12 | res.setBody("Hello, world!");
13 |
14 | return res;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/template/python-waitress/template/java11/function/src/test/java/HandlerTest.java:
--------------------------------------------------------------------------------
1 | import org.junit.Test;
2 | import static org.junit.Assert.*;
3 |
4 | import com.openfaas.function.Handler;
5 | import com.openfaas.model.IHandler;
6 |
7 | public class HandlerTest {
8 | @Test public void handlerIsNotNull() {
9 | IHandler handler = new Handler();
10 | assertTrue("Expected handler not to be null", handler != null);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/template/python-waitress/template/java11/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/container-registry/container-vending-machine/ca9c86373d1d97e75cedf4bf3e185661019fb640/template/python-waitress/template/java11/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/template/python-waitress/template/java11/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/template/python-waitress/template/java11/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'java11'
2 |
3 | include 'model', 'function', 'entrypoint'
4 |
--------------------------------------------------------------------------------
/template/python-waitress/template/java11/template.yml:
--------------------------------------------------------------------------------
1 | language: java11
2 | welcome_message: |
3 | You have created a function using the java11 template which uses an LTS
4 | version of the OpenJDK.
5 |
--------------------------------------------------------------------------------
/template/python-waitress/template/node/.dockerignore:
--------------------------------------------------------------------------------
1 | */node_modules
2 |
--------------------------------------------------------------------------------
/template/python-waitress/template/node/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/classic-watchdog:0.1.4 as watchdog
2 | FROM --platform=${TARGETPLATFORM:-linux/amd64} node:12-alpine as ship
3 |
4 | ARG TARGETPLATFORM
5 | ARG BUILDPLATFORM
6 |
7 | COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog
8 | RUN chmod +x /usr/bin/fwatchdog
9 |
10 | RUN addgroup -S app && adduser app -S -G app
11 |
12 | WORKDIR /root/
13 |
14 | # Turn down the verbosity to default level.
15 | ENV NPM_CONFIG_LOGLEVEL warn
16 |
17 | RUN mkdir -p /home/app
18 |
19 | # Wrapper/boot-strapper
20 | WORKDIR /home/app
21 | COPY package.json ./
22 |
23 | # This ordering means the npm installation is cached for the outer function handler.
24 | RUN npm i --production
25 |
26 | # Copy outer function handler
27 | COPY index.js ./
28 |
29 | # COPY function node packages and install, adding this as a separate
30 | # entry allows caching of npm install runtime dependencies
31 | WORKDIR /home/app/function
32 | COPY function/*.json ./
33 | RUN npm i --production || :
34 |
35 | # Copy in additional function files and folders
36 | COPY --chown=app:app function/ .
37 |
38 | WORKDIR /home/app/
39 |
40 | # chmod for tmp is for a buildkit issue (@alexellis)
41 | RUN chmod +rx -R ./function \
42 | && chown app:app -R /home/app \
43 | && chmod 777 /tmp
44 |
45 | USER app
46 |
47 | ENV cgi_headers="true"
48 | ENV fprocess="node index.js"
49 | EXPOSE 8080
50 |
51 | HEALTHCHECK --interval=3s CMD [ -e /tmp/.lock ] || exit 1
52 |
53 | CMD ["fwatchdog"]
54 |
--------------------------------------------------------------------------------
/template/python-waitress/template/node/function/handler.js:
--------------------------------------------------------------------------------
1 | "use strict"
2 |
3 | module.exports = async (context, callback) => {
4 | return {status: "done"}
5 | }
6 |
--------------------------------------------------------------------------------
/template/python-waitress/template/node/function/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "function",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "handler.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "keywords": [],
10 | "author": "",
11 | "license": "ISC"
12 | }
13 |
--------------------------------------------------------------------------------
/template/python-waitress/template/node/index.js:
--------------------------------------------------------------------------------
1 | // Copyright (c) Alex Ellis 2017. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | "use strict"
5 |
6 | const getStdin = require('get-stdin');
7 |
8 | const handler = require('./function/handler');
9 |
10 | getStdin().then(val => {
11 | const cb = (err, res) => {
12 | if (err) {
13 | return console.error(err);
14 | }
15 | if (!res) {
16 | return;
17 | }
18 | if(Array.isArray(res) || isObject(res)) {
19 | console.log(JSON.stringify(res));
20 | } else {
21 | process.stdout.write(res);
22 | }
23 | } // cb ...
24 |
25 | const result = handler(val, cb);
26 | if (result instanceof Promise) {
27 | result
28 | .then(data => cb(undefined, data))
29 | .catch(err => cb(err, undefined))
30 | ;
31 | }
32 | }).catch(e => {
33 | console.error(e.stack);
34 | });
35 |
36 | const isObject = (a) => {
37 | return (!!a) && (a.constructor === Object);
38 | };
--------------------------------------------------------------------------------
/template/python-waitress/template/node/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "NodejsBase",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "faas_index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "keywords": [],
10 | "author": "",
11 | "license": "ISC",
12 | "dependencies": {
13 | "get-stdin": "^5.0.1"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/template/python-waitress/template/node/template.yml:
--------------------------------------------------------------------------------
1 | language: node
2 | fprocess: node index.js
3 | welcome_message: |
4 | You have created a new function which uses Node.js 12.13.0 and the OpenFaaS
5 | Classic Watchdog.
6 |
7 | npm i --save can be used to add third-party packages like request or cheerio
8 | npm documentation: https://docs.npmjs.com/
9 |
10 | For high-throughput services, we recommend you use the node12 template which
11 | uses a different version of the OpenFaaS watchdog.
12 |
--------------------------------------------------------------------------------
/template/python-waitress/template/node12/.dockerignore:
--------------------------------------------------------------------------------
1 | */node_modules
2 |
--------------------------------------------------------------------------------
/template/python-waitress/template/node12/function/handler.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | module.exports = async (event, context) => {
4 | const result = {
5 | 'status': 'Received input: ' + JSON.stringify(event.body)
6 | }
7 |
8 | return context
9 | .status(200)
10 | .succeed(result)
11 | }
12 |
13 |
--------------------------------------------------------------------------------
/template/python-waitress/template/node12/function/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "openfaas-function",
3 | "version": "1.0.0",
4 | "description": "OpenFaaS Function",
5 | "main": "handler.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 0"
8 | },
9 | "keywords": [],
10 | "author": "OpenFaaS Ltd",
11 | "license": "MIT"
12 | }
13 |
--------------------------------------------------------------------------------
/template/python-waitress/template/node12/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "openfaas-node12",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no tests specified\" && exit 0"
8 | },
9 | "keywords": [],
10 | "author": "OpenFaaS Ltd",
11 | "license": "MIT",
12 | "dependencies": {
13 | "body-parser": "^1.18.2",
14 | "express": "^4.16.2"
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/template/python-waitress/template/node12/template.yml:
--------------------------------------------------------------------------------
1 | language: node12
2 | fprocess: node index.js
3 | welcome_message: |
4 | You have created a new function which uses Node.js 12 (TLS) and the OpenFaaS
5 | of-watchdog which gives greater control over HTTP responses.
6 |
7 | npm i --save can be used to add third-party packages like request or cheerio
8 | npm documentation: https://docs.npmjs.com/
9 |
10 | Unit tests are run at build time via "npm run", edit package.json to specify
11 | how you want to execute them.
12 |
13 |
--------------------------------------------------------------------------------
/template/python-waitress/template/php7/function/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "openfaas/function-php7.2",
3 | "description": "Template for function in PHP 7.2",
4 | "type": "project",
5 | "license": "proprietary",
6 | "config": {
7 | "classmap-authoritative": true
8 | },
9 | "autoload": {
10 | "psr-4": {
11 | "App\\": "src/"
12 | }
13 | },
14 | "require": {
15 | "php": "^7.2"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/template/python-waitress/template/php7/function/php-extension.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | echo "Installing PHP extensions"
4 |
5 | # Add your extensions in here, an example is below
6 | # docker-php-ext-install mysqli
7 | #
8 | # See the template documentation for instructions on installing extensions;
9 | # - https://github.com/openfaas/templates/tree/master/template/php7
10 | #
11 | # You can also install any apk packages here
12 |
--------------------------------------------------------------------------------
/template/python-waitress/template/php7/function/src/Handler.php:
--------------------------------------------------------------------------------
1 | handle($stdin);
10 | echo $response;
11 |
--------------------------------------------------------------------------------
/template/python-waitress/template/php7/php-extension.sh-example:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | echo "Installing PHP extensions"
4 | docker-php-ext-install pdo_mysql
5 |
6 | # Install Phalcon
7 | PHALCON_VERSION=3.4.0
8 | PHALCON_EXT_PATH=php7/64bits
9 |
10 | set -xe && \
11 | # Compile Phalcon
12 | curl -LO https://github.com/phalcon/cphalcon/archive/v${PHALCON_VERSION}.tar.gz && \
13 | tar xzf ${PWD}/v${PHALCON_VERSION}.tar.gz && \
14 | docker-php-ext-install -j $(getconf _NPROCESSORS_ONLN) ${PWD}/cphalcon-${PHALCON_VERSION}/build/${PHALCON_EXT_PATH} && \
15 | # Remove all temp files
16 | rm -r \
17 | ${PWD}/v${PHALCON_VERSION}.tar.gz \
18 | ${PWD}/cphalcon-${PHALCON_VERSION}
--------------------------------------------------------------------------------
/template/python-waitress/template/php7/template.yml:
--------------------------------------------------------------------------------
1 | language: php7
2 | fprocess: php index.php
3 | welcome_message: |
4 | You have created a new function which uses PHP 7.2.
5 | Dependencies and extensions can be added using the composer.json
6 | and php-extension.sh files.
7 | See https://github.com/openfaas/templates/blob/master/template/php7.
8 |
--------------------------------------------------------------------------------
/template/python-waitress/template/python/function/handler.py:
--------------------------------------------------------------------------------
1 | def handle(req):
2 | """handle a request to the function
3 | Args:
4 | req (str): request body
5 | """
6 |
7 | return req
8 |
--------------------------------------------------------------------------------
/template/python-waitress/template/python/function/requirements.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/container-registry/container-vending-machine/ca9c86373d1d97e75cedf4bf3e185661019fb640/template/python-waitress/template/python/function/requirements.txt
--------------------------------------------------------------------------------
/template/python-waitress/template/python/index.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) Alex Ellis 2017. All rights reserved.
2 | # Copyright (c) OpenFaaS Author(s) 2018. All rights reserved.
3 | # Licensed under the MIT license. See LICENSE file in the project root for full license information.
4 |
5 | import sys
6 | from function import handler
7 |
8 | def get_stdin():
9 | buf = ""
10 | for line in sys.stdin:
11 | buf = buf + line
12 | return buf
13 |
14 | if __name__ == "__main__":
15 | st = get_stdin()
16 | ret = handler.handle(st)
17 | if ret != None:
18 | print(ret)
19 |
--------------------------------------------------------------------------------
/template/python-waitress/template/python/requirements.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/container-registry/container-vending-machine/ca9c86373d1d97e75cedf4bf3e185661019fb640/template/python-waitress/template/python/requirements.txt
--------------------------------------------------------------------------------
/template/python-waitress/template/python/template.yml:
--------------------------------------------------------------------------------
1 | language: python
2 | fprocess: python index.py
3 | build_options:
4 | - name: dev
5 | packages:
6 | - make
7 | - automake
8 | - gcc
9 | - g++
10 | - subversion
11 | - python3-dev
12 | - musl-dev
13 | - libffi-dev
14 | - git
15 | - name: mysql
16 | packages:
17 | - mysql-client
18 | - mysql-dev
19 | - name: pillow
20 | packages:
21 | - jpeg-dev
22 | - zlib-dev
23 | - freetype-dev
24 | - lcms2-dev
25 | - openjpeg-dev
26 | - tiff-dev
27 | - tk-dev
28 | - tcl-dev
29 | - harfbuzz-dev
30 | - fribidi-dev
31 |
--------------------------------------------------------------------------------
/template/python-waitress/template/python3-debian/function/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/container-registry/container-vending-machine/ca9c86373d1d97e75cedf4bf3e185661019fb640/template/python-waitress/template/python3-debian/function/__init__.py
--------------------------------------------------------------------------------
/template/python-waitress/template/python3-debian/function/handler.py:
--------------------------------------------------------------------------------
1 | def handle(req):
2 | """handle a request to the function
3 | Args:
4 | req (str): request body
5 | """
6 |
7 | return req
8 |
--------------------------------------------------------------------------------
/template/python-waitress/template/python3-debian/function/requirements.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/container-registry/container-vending-machine/ca9c86373d1d97e75cedf4bf3e185661019fb640/template/python-waitress/template/python3-debian/function/requirements.txt
--------------------------------------------------------------------------------
/template/python-waitress/template/python3-debian/index.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) Alex Ellis 2017. All rights reserved.
2 | # Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | import sys
5 | from function import handler
6 |
7 | def get_stdin():
8 | buf = ""
9 | while(True):
10 | line = sys.stdin.readline()
11 | buf += line
12 | if line=="":
13 | break
14 | return buf
15 |
16 | if(__name__ == "__main__"):
17 | st = get_stdin()
18 | ret = handler.handle(st)
19 | if ret != None:
20 | print(ret)
21 |
--------------------------------------------------------------------------------
/template/python-waitress/template/python3-debian/requirements.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/container-registry/container-vending-machine/ca9c86373d1d97e75cedf4bf3e185661019fb640/template/python-waitress/template/python3-debian/requirements.txt
--------------------------------------------------------------------------------
/template/python-waitress/template/python3-debian/template.yml:
--------------------------------------------------------------------------------
1 | language: python3-debian
2 | fprocess: python3 index.py
3 |
--------------------------------------------------------------------------------
/template/python-waitress/template/python3/function/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/container-registry/container-vending-machine/ca9c86373d1d97e75cedf4bf3e185661019fb640/template/python-waitress/template/python3/function/__init__.py
--------------------------------------------------------------------------------
/template/python-waitress/template/python3/function/handler.py:
--------------------------------------------------------------------------------
1 | def handle(req):
2 | """handle a request to the function
3 | Args:
4 | req (str): request body
5 | """
6 |
7 | return req
8 |
--------------------------------------------------------------------------------
/template/python-waitress/template/python3/function/requirements.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/container-registry/container-vending-machine/ca9c86373d1d97e75cedf4bf3e185661019fb640/template/python-waitress/template/python3/function/requirements.txt
--------------------------------------------------------------------------------
/template/python-waitress/template/python3/index.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) Alex Ellis 2017. All rights reserved.
2 | # Copyright (c) OpenFaaS Author(s) 2018. All rights reserved.
3 | # Licensed under the MIT license. See LICENSE file in the project root for full license information.
4 |
5 | import sys
6 | from function import handler
7 |
8 | def get_stdin():
9 | buf = ""
10 | while(True):
11 | line = sys.stdin.readline()
12 | buf += line
13 | if line == "":
14 | break
15 | return buf
16 |
17 | if __name__ == "__main__":
18 | st = get_stdin()
19 | ret = handler.handle(st)
20 | if ret != None:
21 | print(ret)
22 |
--------------------------------------------------------------------------------
/template/python-waitress/template/python3/requirements.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/container-registry/container-vending-machine/ca9c86373d1d97e75cedf4bf3e185661019fb640/template/python-waitress/template/python3/requirements.txt
--------------------------------------------------------------------------------
/template/python-waitress/template/python3/template.yml:
--------------------------------------------------------------------------------
1 | language: python3
2 | fprocess: python3 index.py
3 | build_options:
4 | - name: dev
5 | packages:
6 | - make
7 | - automake
8 | - gcc
9 | - g++
10 | - subversion
11 | - python3-dev
12 | - musl-dev
13 | - libffi-dev
14 | - git
15 | - name: mysql
16 | packages:
17 | - mysql-client
18 | - mysql-dev
19 | - name: pillow
20 | packages:
21 | - jpeg-dev
22 | - zlib-dev
23 | - freetype-dev
24 | - lcms2-dev
25 | - openjpeg-dev
26 | - tiff-dev
27 | - tk-dev
28 | - tcl-dev
29 | - harfbuzz-dev
30 | - fribidi-dev
31 | welcome_message: |
32 | You have created a Python3 function using the Classic Watchdog.
33 |
34 | To include third-party dependencies create a requirements.txt file.
35 |
36 | For high-throughput applications, we recommend using the python3-flask
37 | or python3-http templates.
38 |
--------------------------------------------------------------------------------
/template/python-waitress/template/ruby/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/classic-watchdog:0.1.4 as watchdog
2 | FROM --platform=${TARGETPLATFORM:-linux/amd64} ruby:alpine
3 |
4 | ARG TARGETPLATFORM
5 | ARG BUILDPLATFORM
6 |
7 | COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog
8 | RUN chmod +x /usr/bin/fwatchdog
9 |
10 | ARG ADDITIONAL_PACKAGE
11 |
12 | # Alternatively use ADD https:// (which will not be cached by Docker builder)
13 | RUN apk --no-cache add ${ADDITIONAL_PACKAGE}
14 |
15 | WORKDIR /home/app
16 |
17 | COPY Gemfile .
18 | COPY index.rb .
19 | COPY function function
20 |
21 | RUN bundle install \
22 | && mkdir -p /home/app/function
23 |
24 | WORKDIR /home/app/function
25 |
26 | RUN bundle install
27 |
28 | RUN addgroup -S app \
29 | && adduser app -S -G app
30 |
31 | RUN chown app:app -R /home/app
32 |
33 | USER app
34 |
35 | WORKDIR /home/app
36 |
37 | ENV fprocess="ruby index.rb"
38 | EXPOSE 8080
39 |
40 | HEALTHCHECK --interval=2s CMD [ -e /tmp/.lock ] || exit 1
41 |
42 | CMD ["fwatchdog"]
43 |
--------------------------------------------------------------------------------
/template/python-waitress/template/ruby/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 |
--------------------------------------------------------------------------------
/template/python-waitress/template/ruby/function/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 |
3 |
--------------------------------------------------------------------------------
/template/python-waitress/template/ruby/function/handler.rb:
--------------------------------------------------------------------------------
1 | class Handler
2 | def run(req)
3 | return "Hello world from the Ruby template"
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/template/python-waitress/template/ruby/index.rb:
--------------------------------------------------------------------------------
1 | # Copyright (c) Alex Ellis 2017. All rights reserved.
2 | # Copyright (c) OpenFaaS Author(s) 2018. All rights reserved.
3 | # Licensed under the MIT license. See LICENSE file in the project root for full license information.
4 |
5 | require_relative 'function/handler'
6 |
7 | req = ARGF.read
8 |
9 | handler = Handler.new
10 | res = handler.run req
11 |
12 | puts res
13 |
--------------------------------------------------------------------------------
/template/python-waitress/template/ruby/template.yml:
--------------------------------------------------------------------------------
1 | language: ruby
2 | fprocess: ruby index.rb
3 | build_options:
4 | - name: dev
5 | packages:
6 | - make
7 | - automake
8 | - gcc
9 | - g++
10 | - subversion
11 | - python3-dev
12 | - musl-dev
13 | - libffi-dev
14 | - libssh
15 | - libssh-dev
16 | welcome_message: |
17 | You have created a Ruby function using the Classic Watchdog.
18 |
19 | To include third-party dependencies create a Gemfile. You can also
20 | include developer-dependencies using the "dev" build_option.
21 |
22 | For high-throughput applications, we recommend using the ruby-http
23 | template.
24 |
--------------------------------------------------------------------------------
/template/python-waitress/venv/bin/activate.csh:
--------------------------------------------------------------------------------
1 | # This file must be used with "source bin/activate.csh" *from csh*.
2 | # You cannot run it directly.
3 | # Created by Davide Di Blasi