diff --git a/README.md b/README.md index b757c77a..25fc1436 100644 --- a/README.md +++ b/README.md @@ -17,24 +17,33 @@ See: `faas-cli template store list` to see which templates are both: recommended | Name | Language | Version | Linux base | Watchdog | Link |:-----|:---------|:--------|:-----------|:---------|:---- | dockerfile | Dockerfile | N/A | Alpine Linux | classic | [Dockerfile template](https://github.com/openfaas/templates/tree/master/template/dockerfile) -| go | Go | 1.23 | Alpine Linux | classic | [Legacy Go template (deprecated)](https://github.com/openfaas/templates/tree/master/template/go) | node18 | NodeJS | 18 | Alpine Linux | of-watchdog | [NodeJS template (deprecated)](https://github.com/openfaas/templates/tree/master/template/node18) | node20 | NodeJS | 20 | Alpine Linux | of-watchdog | [NodeJS template](https://github.com/openfaas/templates/tree/master/template/node20) -| bun-express | Bun | 1.0 | Alpine Linux | of-watchdog | [NodeJS template](https://github.com/openfaas/templates/tree/master/template/bun-express) -| node | NodeJS | 20 | Alpine Linux | classic | [Legacy NodeJS template (deprecated)](https://github.com/openfaas/templates/tree/master/template/node) -| python3 | Python | 3 | Alpine Linux | classic | [Legacy Python 3 template](https://github.com/openfaas/templates/tree/master/template/python3) -| python3-debian | Python | 3 | Debian Linux | classic | [Legacy Python 3 Debian template](https://github.com/openfaas/templates/tree/master/template/python3-debian) -| python27 | Python | 2.7.18 | Alpine Linux | classic | [Python 2.7 template (deprecated)](https://github.com/openfaas/templates/tree/master/template/python27) | java11-vert-x | Java and [Vert.x](https://vertx.io/) | 11 | Debian GNU/Linux | of-watchdog | [Java LTS template](https://github.com/openfaas/templates/tree/master/template/java11-vert-x) | java11 | Java | 11 | Debian GNU/Linux | of-watchdog | [Deprecated Java template](https://github.com/openfaas/templates/tree/master/template/java11) | java17 | Java | 11 | Debian GNU/Linux | of-watchdog | [Java LTS template](https://github.com/openfaas/templates/tree/master/template/java17) -| ruby | Ruby | 3.3 | Alpine Linux | classic| [Ruby template](https://github.com/openfaas/templates/tree/master/template/ruby) | php7 | PHP | 7.4 | Alpine Linux | classic | [PHP 7 template](https://github.com/openfaas/templates/tree/master/template/php7) | php8 | PHP | 8.2 | Alpine Linux | classic | [PHP 8 template](https://github.com/openfaas/templates/tree/master/template/php8) -| csharp | C# | N/A | Debian GNU/Linux 9 | classic | [Legacy C# template (deprecated)](https://github.com/openfaas/templates/tree/master/template/csharp) For more information on the templates check out the [docs](https://docs.openfaas.com/cli/templates/). +### Moved Classic Templates + +A number of long deprecated templates have been moved out of this repository into a new repository to indicate their End Of Life (EOL) status. + +In most cases, alternatives have already been provided and are listed int the Function Store, or the [Languages section of the OpenFaaS documentation](https://docs.openfaas.com/languages/overview/). + +Moved templates: + +* go +* python3 +* python3-debian +* python27 +* ruby +* csharp +* bun-express +* node + ### Classic vs of-watchdog templates The current version of OpenFaaS templates use the original `watchdog` which `forks` processes - a bit like CGI. The newer watchdog [of-watchdog](https://github.com/openfaas/of-watchdog) is more similar to fastCGI/HTTP and should be used for any benchmarking or performance testing along with one of the newer templates. Contact the project for more information. diff --git a/template/bun/Dockerfile b/template/bun/Dockerfile deleted file mode 100644 index 4d7ea117..00000000 --- a/template/bun/Dockerfile +++ /dev/null @@ -1,59 +0,0 @@ -FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.10.7 AS watchdog -FROM --platform=${TARGETPLATFORM:-linux/amd64} oven/bun:1.0-alpine AS ship - -ARG TARGETPLATFORM -ARG BUILDPLATFORM - -COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog -RUN chmod +x /usr/bin/fwatchdog - -RUN addgroup -S app && adduser app -S -G app - -WORKDIR /root/ - -RUN mkdir -p /home/app - -# Wrapper/boot-strapper -WORKDIR /home/app -COPY package.json ./ -COPY jsconfig.json ./ -COPY bun.lockb ./ - -# This ordering means the npm installation is cached for the outer function handler. -RUN bun install --production - -# Copy outer function handler -COPY index.js ./ - -# COPY function node packages and install, adding this as a separate -# entry allows caching of npm install runtime dependencies -WORKDIR /home/app/function -COPY function/*.json ./ -RUN bun install --production || : - -# Copy in additional function files and folders -COPY --chown=app:app function/ . - -WORKDIR /home/app/ - -# chmod for tmp is for a buildkit issue (@alexellis) -RUN chmod +rx -R ./function \ - && chown app:app -R /home/app \ - && chmod 777 /tmp - -USER app - -ENV cgi_headers="true" -ENV fprocess="bun run index.js" -ENV mode="http" -ENV upstream_url="http://127.0.0.1:3000" - -ENV exec_timeout="10s" -ENV write_timeout="15s" -ENV read_timeout="15s" - -ENV prefix_logs="false" - -HEALTHCHECK --interval=3s CMD [ -e /tmp/.lock ] || exit 1 - -CMD ["fwatchdog"] diff --git a/template/bun/README.md b/template/bun/README.md deleted file mode 100644 index ac8afed6..00000000 --- a/template/bun/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# bun - -To install dependencies: - -```bash -bun install -``` - -To run: - -```bash -bun run index.js -``` - -This project was created using `bun init` in bun v1.0.3. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime. diff --git a/template/bun/bun.lockb b/template/bun/bun.lockb deleted file mode 100755 index 84e85afc..00000000 Binary files a/template/bun/bun.lockb and /dev/null differ diff --git a/template/bun/function/README.md b/template/bun/function/README.md deleted file mode 100644 index 88a7c04b..00000000 --- a/template/bun/function/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# openfaas-function - -To install dependencies: - -```bash -bun install -``` - -To run: - -```bash -bun run handler.js -``` - -This project was created using `bun init` in bun v1.0.3. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime. diff --git a/template/bun/function/bun.lockb b/template/bun/function/bun.lockb deleted file mode 100755 index 90670671..00000000 Binary files a/template/bun/function/bun.lockb and /dev/null differ diff --git a/template/bun/function/handler.js b/template/bun/function/handler.js deleted file mode 100644 index 18f543d4..00000000 --- a/template/bun/function/handler.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict' - -module.exports = async (event, context) => { - const result = { - 'body': JSON.stringify(event.body), - 'content-type': event.headers["content-type"] - } - - return context - .status(200) - .succeed(result) -} diff --git a/template/bun/function/jsconfig.json b/template/bun/function/jsconfig.json deleted file mode 100644 index 7556e1d4..00000000 --- a/template/bun/function/jsconfig.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "compilerOptions": { - "lib": ["ESNext"], - "module": "esnext", - "target": "esnext", - "moduleResolution": "bundler", - "moduleDetection": "force", - "allowImportingTsExtensions": true, - "noEmit": true, - "composite": true, - "strict": true, - "downlevelIteration": true, - "skipLibCheck": true, - "jsx": "react-jsx", - "allowSyntheticDefaultImports": true, - "forceConsistentCasingInFileNames": true, - "allowJs": true, - "types": [ - "bun-types" // add Bun global - ] - } -} diff --git a/template/bun/function/package.json b/template/bun/function/package.json deleted file mode 100644 index 8fa34153..00000000 --- a/template/bun/function/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "openfaas-function", - "version": "1.0.0", - "description": "OpenFaaS Function", - "main": "handler.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 0" - }, - "keywords": [], - "author": "OpenFaaS Ltd", - "license": "MIT", - "devDependencies": { - "bun-types": "latest" - }, - "peerDependencies": { - "typescript": "^5.0.0" - } -} \ No newline at end of file diff --git a/template/bun/index.js b/template/bun/index.js deleted file mode 100644 index 8c47b59b..00000000 --- a/template/bun/index.js +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright (c) Alex Ellis 2021. All rights reserved. -// Copyright (c) OpenFaaS Author(s) 2021. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -"use strict" - -import express from "express"; -const app = express() -const handler = require('./function/handler'); -const bodyParser = require('body-parser') - -const defaultMaxSize = '100kb' // body-parser default - -app.disable('x-powered-by'); - -const rawLimit = process.env.MAX_RAW_SIZE || defaultMaxSize -const jsonLimit = process.env.MAX_JSON_SIZE || defaultMaxSize - -app.use(function addDefaultContentType(req, res, next) { - // When no content-type is given, the body element is set to - // nil, and has been a source of contention for new users. - - if(!req.headers['content-type']) { - req.headers['content-type'] = "text/plain" - } - next() -}) - -if (process.env.RAW_BODY === 'true') { - app.use(bodyParser.raw({ type: '*/*' , limit: rawLimit })) -} else { - app.use(bodyParser.text({ type : "text/*" })); - app.use(bodyParser.json({ limit: jsonLimit})); - app.use(bodyParser.urlencoded({ extended: true })); -} - -const isArray = (a) => { - return (!!a) && (a.constructor === Array); -}; - -const isObject = (a) => { - return (!!a) && (a.constructor === Object); -}; - -class FunctionEvent { - constructor(req) { - this.body = req.body; - this.headers = req.headers; - this.method = req.method; - this.query = req.query; - this.path = req.path; - } -} - -class FunctionContext { - constructor(cb) { - this.statusCode = 200; - this.cb = cb; - this.headerValues = {}; - this.cbCalled = 0; - } - - status(statusCode) { - if(!statusCode) { - return this.statusCode; - } - - this.statusCode = statusCode; - return this; - } - - headers(value) { - if(!value) { - return this.headerValues; - } - - this.headerValues = value; - return this; - } - - succeed(value) { - let err; - this.cbCalled++; - this.cb(err, value); - } - - fail(value) { - let message; - if(this.status() == "200") { - this.status(500) - } - - this.cbCalled++; - this.cb(value, message); - } -} - -const middleware = async (req, res) => { - const cb = (err, functionResult) => { - if (err) { - console.error(err); - - return res.status(fnContext.status()) - .send(err.toString ? err.toString() : err); - } - - if(isArray(functionResult) || isObject(functionResult)) { - res.set(fnContext.headers()) - .status(fnContext.status()).send(JSON.stringify(functionResult)); - } else { - res.set(fnContext.headers()) - .status(fnContext.status()) - .send(functionResult); - } - }; - - const fnEvent = new FunctionEvent(req); - const fnContext = new FunctionContext(cb); - - Promise.resolve(handler(fnEvent, fnContext, cb)) - .then(res => { - if(!fnContext.cbCalled) { - fnContext.succeed(res); - } - }) - .catch(e => { - cb(e); - }); -}; - -app.post('/*', middleware); -app.get('/*', middleware); -app.patch('/*', middleware); -app.put('/*', middleware); -app.delete('/*', middleware); -app.options('/*', middleware); - -const port = process.env.http_port || 3000; - -app.listen(port, () => { - console.log(`bun-express listening on port: ${port}`) -}); - - diff --git a/template/bun/jsconfig.json b/template/bun/jsconfig.json deleted file mode 100644 index 7556e1d4..00000000 --- a/template/bun/jsconfig.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "compilerOptions": { - "lib": ["ESNext"], - "module": "esnext", - "target": "esnext", - "moduleResolution": "bundler", - "moduleDetection": "force", - "allowImportingTsExtensions": true, - "noEmit": true, - "composite": true, - "strict": true, - "downlevelIteration": true, - "skipLibCheck": true, - "jsx": "react-jsx", - "allowSyntheticDefaultImports": true, - "forceConsistentCasingInFileNames": true, - "allowJs": true, - "types": [ - "bun-types" // add Bun global - ] - } -} diff --git a/template/bun/package.json b/template/bun/package.json deleted file mode 100644 index 1a1117c5..00000000 --- a/template/bun/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "bun", - "module": "index.js", - "type": "module", - "devDependencies": { - "bun-types": "latest" - }, - "peerDependencies": { - "typescript": "^5.0.0" - }, - "scripts": { - "run": "bun run index.js" - }, - "dependencies": { - "express": "^4.18.2" - } -} \ No newline at end of file diff --git a/template/bun/template.yml b/template/bun/template.yml deleted file mode 100644 index 7b9374be..00000000 --- a/template/bun/template.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: bun-express -welcome_message: | - This template uses the Bun framework and Express.js to - build functions. To install packages run: bun install. diff --git a/template/csharp/.dockerignore b/template/csharp/.dockerignore deleted file mode 100644 index 1746e326..00000000 --- a/template/csharp/.dockerignore +++ /dev/null @@ -1,2 +0,0 @@ -bin -obj diff --git a/template/csharp/.gitignore b/template/csharp/.gitignore deleted file mode 100644 index c6e49efc..00000000 --- a/template/csharp/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -obj/ -bin/ diff --git a/template/csharp/Dockerfile b/template/csharp/Dockerfile deleted file mode 100644 index efbd46b9..00000000 --- a/template/csharp/Dockerfile +++ /dev/null @@ -1,42 +0,0 @@ -FROM ghcr.io/openfaas/classic-watchdog:0.3.1 AS watchdog - -FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS builder - -# Supress collection of data. -ENV DOTNET_CLI_TELEMETRY_OPTOUT 1 - -# Optimize for Docker builder caching by adding projects first. - -RUN mkdir -p /home/app/src/function -WORKDIR /home/app/src/function -COPY ./function/Function.csproj . - -WORKDIR /home/app/src/ -COPY ./root.csproj . -RUN dotnet restore ./root.csproj - -COPY . . - -RUN dotnet publish -c release -o published - -FROM mcr.microsoft.com/dotnet/core/runtime:3.1 - -COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog -RUN chmod +x /usr/bin/fwatchdog - -# Create a non-root user -RUN addgroup --system app \ - && adduser --system --ingroup app app - -WORKDIR /home/app/ -COPY --from=builder /home/app/src/published . -RUN chown app:app -R /home/app - -USER app - -ENV fprocess="dotnet ./root.dll" -EXPOSE 8080 - -HEALTHCHECK --interval=3s CMD [ -e /tmp/.lock ] || exit 1 - -CMD ["fwatchdog"] diff --git a/template/csharp/Program.cs b/template/csharp/Program.cs deleted file mode 100644 index a3e35491..00000000 --- a/template/csharp/Program.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) Alex Ellis 2017. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.Text; -using Function; - -namespace root -{ - class Program - { - static void Main(string[] args) - { - string buffer = Console.In.ReadToEnd(); - FunctionHandler f = new FunctionHandler(); - - string responseValue = f.Handle(buffer); - - if(responseValue != null) { - Console.Write(responseValue); - } - } - } -} diff --git a/template/csharp/function/.gitignore b/template/csharp/function/.gitignore deleted file mode 100644 index c74559e2..00000000 --- a/template/csharp/function/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -bin/ -obj/ -.nuget/ -.dotnet/ -.templateengine/ diff --git a/template/csharp/function/Function.csproj b/template/csharp/function/Function.csproj deleted file mode 100644 index 726d10a3..00000000 --- a/template/csharp/function/Function.csproj +++ /dev/null @@ -1,9 +0,0 @@ - - - - netstandard2.0 - - - false - - diff --git a/template/csharp/function/FunctionHandler.cs b/template/csharp/function/FunctionHandler.cs deleted file mode 100644 index 52b47f03..00000000 --- a/template/csharp/function/FunctionHandler.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Text; - -namespace Function -{ - public class FunctionHandler - { - public string Handle(string input) { - return $"Hi there - your input was: {input}\n"; - } - } -} diff --git a/template/csharp/root.csproj b/template/csharp/root.csproj deleted file mode 100644 index 90994556..00000000 --- a/template/csharp/root.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - false - - - - - - - Exe - netcoreapp3.1 - - - false - - diff --git a/template/csharp/template.yml b/template/csharp/template.yml deleted file mode 100644 index 8d64b2ce..00000000 --- a/template/csharp/template.yml +++ /dev/null @@ -1,7 +0,0 @@ -language: csharp -fprocess: dotnet ./root.dll -welcome_message: | - This template is deprecated and will be removed in a future - release. - - Use dotnet8-csharp instead. diff --git a/template/go/Dockerfile b/template/go/Dockerfile deleted file mode 100644 index fad7c13b..00000000 --- a/template/go/Dockerfile +++ /dev/null @@ -1,58 +0,0 @@ -FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/classic-watchdog:0.3.1 AS watchdog -FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.23-alpine3.20 AS build - -ARG TARGETPLATFORM -ARG BUILDPLATFORM -ARG TARGETOS -ARG TARGETARCH - -# Required to enable Go modules -RUN apk add --no-cache git - -# Allows you to add additional packages via build-arg -ARG ADDITIONAL_PACKAGE -ARG CGO_ENABLED=0 -ARG GO111MODULE="off" -ARG GOPROXY="" -ARG GOFLAGS="" - -COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog -RUN chmod +x /usr/bin/fwatchdog - -ENV CGO_ENABLED=0 - -WORKDIR /go/src/handler -COPY . . - -# Run a gofmt and exclude all vendored code. -RUN test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./function/vendor/*"))" || { echo "Run \"gofmt -s -w\" on your Golang code"; exit 1; } - -WORKDIR /go/src/handler/function -RUN mkdir -p /go/src/handler/function/static - -RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=${CGO_ENABLED} go test ./... -cover - -WORKDIR /go/src/handler - -RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=${CGO_ENABLED} \ - go build --ldflags "-s -w" -o handler . - -FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.21.2 AS ship - -RUN apk --no-cache add ca-certificates \ - && addgroup -S app && adduser -S -g app app - -WORKDIR /home/app - -COPY --from=build --chown=app /usr/bin/fwatchdog . -COPY --from=build --chown=app /go/src/handler/handler . -COPY --from=build --chown=app /go/src/handler/function/static static - -USER app - -ENV fprocess="./handler" -EXPOSE 8080 - -HEALTHCHECK --interval=3s CMD [ -e /tmp/.lock ] || exit 1 - -CMD ["./fwatchdog"] diff --git a/template/go/function/go.mod b/template/go/function/go.mod deleted file mode 100644 index 3e759ef8..00000000 --- a/template/go/function/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module handler/function - -go 1.23 diff --git a/template/go/function/handler.go b/template/go/function/handler.go deleted file mode 100644 index 0c3f15fb..00000000 --- a/template/go/function/handler.go +++ /dev/null @@ -1,10 +0,0 @@ -package function - -import ( - "fmt" -) - -// Handle a serverless request -func Handle(req []byte) string { - return fmt.Sprintf("Hello, Go. You said: %s", string(req)) -} diff --git a/template/go/go.mod b/template/go/go.mod deleted file mode 100644 index 5076a434..00000000 --- a/template/go/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module handler - -go 1.23 diff --git a/template/go/go.work b/template/go/go.work deleted file mode 100644 index e609a15b..00000000 --- a/template/go/go.work +++ /dev/null @@ -1,6 +0,0 @@ -go 1.23 - -use ( - . - ./function -) diff --git a/template/go/main.go b/template/go/main.go deleted file mode 100644 index 7c376214..00000000 --- a/template/go/main.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) Alex Ellis 2017. All rights reserved. -// Copyright (c) OpenFaaS Author(s) 2018. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -package main - -import ( - "fmt" - "io/ioutil" - "log" - "os" - - "handler/function" -) - -func main() { - input, err := ioutil.ReadAll(os.Stdin) - if err != nil { - log.Fatalf("Unable to read standard input: %s", err.Error()) - } - - fmt.Println(function.Handle(input)) -} diff --git a/template/go/template.yml b/template/go/template.yml deleted file mode 100644 index 7d29bab5..00000000 --- a/template/go/template.yml +++ /dev/null @@ -1,25 +0,0 @@ -language: go -fprocess: ./handler -build_options: - - name: dev - packages: - - make - - automake - - gcc - - g++ - - subversion - - python3-dev - - musl-dev - - libffi-dev - - git - - name: mysql - packages: - - mysql-client - - mysql-dev -welcome_message: | - Warning: this classic Go template has been DEPRECATED and - is being maintained for backwards compatibility reasons only. - - Use the golang-middleware template instead, learn more at: - - See more: https://docs.openfaas.com/cli/templates diff --git a/template/node/.dockerignore b/template/node/.dockerignore deleted file mode 100644 index e84c3fba..00000000 --- a/template/node/.dockerignore +++ /dev/null @@ -1 +0,0 @@ -*/node_modules diff --git a/template/node/Dockerfile b/template/node/Dockerfile deleted file mode 100644 index 05505d04..00000000 --- a/template/node/Dockerfile +++ /dev/null @@ -1,53 +0,0 @@ -FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/classic-watchdog:0.3.1 AS watchdog -FROM --platform=${TARGETPLATFORM:-linux/amd64} node:20-alpine AS ship - -ARG TARGETPLATFORM -ARG BUILDPLATFORM - -COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog -RUN chmod +x /usr/bin/fwatchdog - -RUN addgroup -S app && adduser app -S -G app - -WORKDIR /root/ - -# Turn down the verbosity to default level. -ENV NPM_CONFIG_LOGLEVEL warn - -RUN mkdir -p /home/app - -# Wrapper/boot-strapper -WORKDIR /home/app -COPY package.json ./ - -# This ordering means the npm installation is cached for the outer function handler. -RUN npm i --production - -# Copy outer function handler -COPY index.js ./ - -# COPY function node packages and install, adding this as a separate -# entry allows caching of npm install runtime dependencies -WORKDIR /home/app/function -COPY function/*.json ./ -RUN npm i --production || : - -# Copy in additional function files and folders -COPY --chown=app:app function/ . - -WORKDIR /home/app/ - -# chmod for tmp is for a buildkit issue (@alexellis) -RUN chmod +rx -R ./function \ - && chown app:app -R /home/app \ - && chmod 777 /tmp - -USER app - -ENV cgi_headers="true" -ENV fprocess="node index.js" -EXPOSE 8080 - -HEALTHCHECK --interval=3s CMD [ -e /tmp/.lock ] || exit 1 - -CMD ["fwatchdog"] diff --git a/template/node/function/handler.js b/template/node/function/handler.js deleted file mode 100644 index 6df7c5d4..00000000 --- a/template/node/function/handler.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict" - -module.exports = async (context, callback) => { - return {status: "done"} -} diff --git a/template/node/function/package.json b/template/node/function/package.json deleted file mode 100644 index 3d3a3e45..00000000 --- a/template/node/function/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "function", - "version": "1.0.0", - "description": "", - "main": "handler.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC" -} diff --git a/template/node/index.js b/template/node/index.js deleted file mode 100644 index e9189b5e..00000000 --- a/template/node/index.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) Alex Ellis 2017. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -"use strict" - -const getStdin = require('get-stdin'); - -const handler = require('./function/handler'); - -getStdin().then(val => { - const cb = (err, res) => { - if (err) { - return console.error(err); - } - if (!res) { - return; - } - if(Array.isArray(res) || isObject(res)) { - console.log(JSON.stringify(res)); - } else { - process.stdout.write(res); - } - } // cb ... - - const result = handler(val, cb); - if (result instanceof Promise) { - result - .then(data => cb(undefined, data)) - .catch(err => cb(err, undefined)) - ; - } -}).catch(e => { - console.error(e.stack); -}); - -const isObject = (a) => { - return (!!a) && (a.constructor === Object); -}; \ No newline at end of file diff --git a/template/node/package.json b/template/node/package.json deleted file mode 100644 index 20b327ac..00000000 --- a/template/node/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "node", - "version": "1.0.0", - "description": "", - "main": "faas_index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "get-stdin": "^5.0.1" - } -} diff --git a/template/node/template.yml b/template/node/template.yml deleted file mode 100644 index 905b073b..00000000 --- a/template/node/template.yml +++ /dev/null @@ -1,9 +0,0 @@ -language: node -fprocess: node index.js -welcome_message: | - Warning: this classic node template has been DEPRECATED and - is being maintained for backwards compatibility reasons only. - - Use the node20 template instead, learn more at: - - See more: https://docs.openfaas.com/cli/templates diff --git a/template/python27/Dockerfile b/template/python27/Dockerfile deleted file mode 100644 index c209b9ba..00000000 --- a/template/python27/Dockerfile +++ /dev/null @@ -1,55 +0,0 @@ -FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/classic-watchdog:0.3.1 AS watchdog -FROM --platform=${TARGETPLATFORM:-linux/amd64} python:2.7.18-alpine - -ARG TARGETPLATFORM -ARG BUILDPLATFORM - -# Allows you to add additional packages via build-arg -ARG ADDITIONAL_PACKAGE - -COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog -RUN chmod +x /usr/bin/fwatchdog -RUN apk --no-cache add ca-certificates ${ADDITIONAL_PACKAGE} - -# Add non root user -RUN addgroup -S app && adduser app -S -G app - -WORKDIR /home/app/ - -COPY index.py . -COPY requirements.txt . - -RUN chown -R app /home/app && \ - mkdir -p /home/app/python && chown -R app /home/app -USER app -ENV PATH=$PATH:/home/app/.local/bin:/home/app/python/bin/ -ENV PYTHONPATH=$PYTHONPATH:/home/app/python - -RUN pip install -r requirements.txt --target=/home/app/python - -RUN mkdir -p function -RUN touch ./function/__init__.py - -WORKDIR /home/app/function/ -COPY function/requirements.txt . - -RUN pip install -r requirements.txt --target=/home/app/python - -WORKDIR /home/app/ - -USER root - -COPY function function - -# Allow any user-id for OpenShift users. -RUN chown -R app:app ./ && \ - chmod -R 777 /home/app/python - -USER app - -ENV fprocess="python index.py" -EXPOSE 8080 - -HEALTHCHECK --interval=3s CMD [ -e /tmp/.lock ] || exit 1 - -CMD ["fwatchdog"] diff --git a/template/python27/function/handler.py b/template/python27/function/handler.py deleted file mode 100644 index a7098fa5..00000000 --- a/template/python27/function/handler.py +++ /dev/null @@ -1,7 +0,0 @@ -def handle(req): - """handle a request to the function - Args: - req (str): request body - """ - - return req diff --git a/template/python27/function/requirements.txt b/template/python27/function/requirements.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/template/python27/index.py b/template/python27/index.py deleted file mode 100644 index 5c0d24f4..00000000 --- a/template/python27/index.py +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright (c) Alex Ellis 2017. All rights reserved. -# Copyright (c) OpenFaaS Author(s) 2018. All rights reserved. -# Licensed under the MIT license. See LICENSE file in the project root for full license information. - -import sys -from function import handler - -def get_stdin(): - buf = "" - for line in sys.stdin: - buf = buf + line - return buf - -if __name__ == "__main__": - st = get_stdin() - ret = handler.handle(st) - if ret != None: - print(ret) diff --git a/template/python27/requirements.txt b/template/python27/requirements.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/template/python27/template.yml b/template/python27/template.yml deleted file mode 100644 index 55027337..00000000 --- a/template/python27/template.yml +++ /dev/null @@ -1,30 +0,0 @@ -language: python27 -fprocess: python index.py -build_options: - - name: dev - packages: - - make - - automake - - gcc - - g++ - - subversion - - python3-dev - - musl-dev - - libffi-dev - - git - - name: mysql - packages: - - mysql-client - - mysql-dev - - name: pillow - packages: - - jpeg-dev - - zlib-dev - - freetype-dev - - lcms2-dev - - openjpeg-dev - - tiff-dev - - tk-dev - - tcl-dev - - harfbuzz-dev - - fribidi-dev diff --git a/template/python3-debian/Dockerfile b/template/python3-debian/Dockerfile deleted file mode 100644 index d83355e2..00000000 --- a/template/python3-debian/Dockerfile +++ /dev/null @@ -1,58 +0,0 @@ -ARG PYTHON_VERSION=3 -FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/classic-watchdog:0.3.1 AS watchdog -FROM --platform=${TARGETPLATFORM:-linux/amd64} python:${PYTHON_VERSION} - -ARG TARGETPLATFORM -ARG BUILDPLATFORM - -# Allows you to add additional packages via build-arg -ARG ADDITIONAL_PACKAGE - -COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog -RUN chmod +x /usr/bin/fwatchdog -RUN apt-get update \ - && apt-get install -y ca-certificates ${ADDITIONAL_PACKAGE} \ - && rm -rf /var/lib/apt/lists/ - -# Add non root user -RUN groupadd app && useradd -r -g app app - -WORKDIR /home/app/ - -COPY index.py . -COPY requirements.txt . - -RUN chown -R app /home/app && \ - mkdir -p /home/app/python && chown -R app /home/app -USER app -ENV PATH=$PATH:/home/app/.local/bin:/home/app/python/bin/ -ENV PYTHONPATH=$PYTHONPATH:/home/app/python - -RUN pip install -r requirements.txt --target=/home/app/python - -RUN mkdir -p function -RUN touch ./function/__init__.py - -WORKDIR /home/app/function/ -COPY function/requirements.txt . - -RUN pip install -r requirements.txt --target=/home/app/python - -WORKDIR /home/app/ - -USER root - -COPY function function - -# Allow any user-id for OpenShift users. -RUN chown -R app:app ./ && \ - chmod -R 777 /home/app/python - -USER app - -ENV fprocess="python3 index.py" -EXPOSE 8080 - -HEALTHCHECK --interval=3s CMD [ -e /tmp/.lock ] || exit 1 - -CMD ["fwatchdog"] diff --git a/template/python3-debian/function/__init__.py b/template/python3-debian/function/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/template/python3-debian/function/handler.py b/template/python3-debian/function/handler.py deleted file mode 100644 index a7098fa5..00000000 --- a/template/python3-debian/function/handler.py +++ /dev/null @@ -1,7 +0,0 @@ -def handle(req): - """handle a request to the function - Args: - req (str): request body - """ - - return req diff --git a/template/python3-debian/function/requirements.txt b/template/python3-debian/function/requirements.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/template/python3-debian/index.py b/template/python3-debian/index.py deleted file mode 100644 index f49caaec..00000000 --- a/template/python3-debian/index.py +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright (c) Alex Ellis 2017. All rights reserved. -# Licensed under the MIT license. See LICENSE file in the project root for full license information. - -import sys -from function import handler - -def get_stdin(): - buf = "" - while(True): - line = sys.stdin.readline() - buf += line - if line=="": - break - return buf - -if(__name__ == "__main__"): - st = get_stdin() - ret = handler.handle(st) - if ret != None: - print(ret) diff --git a/template/python3-debian/requirements.txt b/template/python3-debian/requirements.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/template/python3-debian/template.yml b/template/python3-debian/template.yml deleted file mode 100644 index 461193ff..00000000 --- a/template/python3-debian/template.yml +++ /dev/null @@ -1,2 +0,0 @@ -language: python3-debian -fprocess: python3 index.py diff --git a/template/python3/Dockerfile b/template/python3/Dockerfile deleted file mode 100644 index 3c455585..00000000 --- a/template/python3/Dockerfile +++ /dev/null @@ -1,57 +0,0 @@ -ARG PYTHON_VERSION=3 -FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/classic-watchdog:0.3.1 AS watchdog -FROM --platform=${TARGETPLATFORM:-linux/amd64} python:${PYTHON_VERSION}-alpine - -ARG TARGETPLATFORM -ARG BUILDPLATFORM - -# Allows you to add additional packages via build-arg -ARG ADDITIONAL_PACKAGE - -COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog -RUN chmod +x /usr/bin/fwatchdog -RUN apk --no-cache add ca-certificates ${ADDITIONAL_PACKAGE} - - -# Add non root user -RUN addgroup -S app && adduser app -S -G app - -WORKDIR /home/app/ - -COPY index.py . -COPY requirements.txt . - -RUN chown -R app /home/app && \ - mkdir -p /home/app/python && chown -R app /home/app -USER app -ENV PATH=$PATH:/home/app/.local/bin:/home/app/python/bin/ -ENV PYTHONPATH=$PYTHONPATH:/home/app/python - -RUN pip install -r requirements.txt --target=/home/app/python - -RUN mkdir -p function -RUN touch ./function/__init__.py - -WORKDIR /home/app/function/ -COPY function/requirements.txt . - -RUN pip install -r requirements.txt --target=/home/app/python - -WORKDIR /home/app/ - -USER root - -COPY function function - -# Allow any user-id for OpenShift users. -RUN chown -R app:app ./ && \ - chmod -R 777 /home/app/python - -USER app - -ENV fprocess="python3 index.py" -EXPOSE 8080 - -HEALTHCHECK --interval=3s CMD [ -e /tmp/.lock ] || exit 1 - -CMD ["fwatchdog"] diff --git a/template/python3/function/__init__.py b/template/python3/function/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/template/python3/function/handler.py b/template/python3/function/handler.py deleted file mode 100644 index a7098fa5..00000000 --- a/template/python3/function/handler.py +++ /dev/null @@ -1,7 +0,0 @@ -def handle(req): - """handle a request to the function - Args: - req (str): request body - """ - - return req diff --git a/template/python3/function/requirements.txt b/template/python3/function/requirements.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/template/python3/index.py b/template/python3/index.py deleted file mode 100644 index 6e1a22f8..00000000 --- a/template/python3/index.py +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright (c) Alex Ellis 2017. All rights reserved. -# Copyright (c) OpenFaaS Author(s) 2018. All rights reserved. -# Licensed under the MIT license. See LICENSE file in the project root for full license information. - -import sys -from function import handler - -def get_stdin(): - buf = "" - while(True): - line = sys.stdin.readline() - buf += line - if line == "": - break - return buf - -if __name__ == "__main__": - st = get_stdin() - ret = handler.handle(st) - if ret != None: - print(ret) diff --git a/template/python3/requirements.txt b/template/python3/requirements.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/template/python3/template.yml b/template/python3/template.yml deleted file mode 100644 index 5933be96..00000000 --- a/template/python3/template.yml +++ /dev/null @@ -1,37 +0,0 @@ -language: python3 -fprocess: python3 index.py -build_options: - - name: dev - packages: - - make - - automake - - gcc - - g++ - - subversion - - python3-dev - - musl-dev - - libffi-dev - - git - - name: mysql - packages: - - mysql-client - - mysql-dev - - name: pillow - packages: - - jpeg-dev - - zlib-dev - - freetype-dev - - lcms2-dev - - openjpeg-dev - - tiff-dev - - tk-dev - - tcl-dev - - harfbuzz-dev - - fribidi-dev -welcome_message: | - You have created a Python3 function using the Classic Watchdog. - - To include third-party dependencies create a requirements.txt file. - - For high-throughput applications, we recommend using the python3-flask - or python3-http templates. diff --git a/template/ruby/Dockerfile b/template/ruby/Dockerfile deleted file mode 100644 index 1e52db1b..00000000 --- a/template/ruby/Dockerfile +++ /dev/null @@ -1,42 +0,0 @@ -FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/classic-watchdog:0.3.1 AS watchdog -FROM --platform=${TARGETPLATFORM:-linux/amd64} ruby:3.3.6-alpine - -ARG TARGETPLATFORM -ARG BUILDPLATFORM - -COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog -RUN chmod +x /usr/bin/fwatchdog - -ARG ADDITIONAL_PACKAGE - -# Alternatively use ADD https:// (which will not be cached by Docker builder) -RUN apk --no-cache add ${ADDITIONAL_PACKAGE} - -WORKDIR /home/app - -COPY Gemfile . -COPY index.rb . -COPY function function - -RUN bundle install \ - && mkdir -p /home/app/function - -WORKDIR /home/app/function - -RUN bundle install - -RUN addgroup -S app \ - && adduser app -S -G app - -RUN chown app:app -R /home/app - -USER app - -WORKDIR /home/app - -ENV fprocess="ruby index.rb" -EXPOSE 8080 - -HEALTHCHECK --interval=2s CMD [ -e /tmp/.lock ] || exit 1 - -CMD ["fwatchdog"] diff --git a/template/ruby/Gemfile b/template/ruby/Gemfile deleted file mode 100644 index 20b4d4ae..00000000 --- a/template/ruby/Gemfile +++ /dev/null @@ -1 +0,0 @@ -source 'https://rubygems.org' diff --git a/template/ruby/function/Gemfile b/template/ruby/function/Gemfile deleted file mode 100644 index c9721cb6..00000000 --- a/template/ruby/function/Gemfile +++ /dev/null @@ -1,2 +0,0 @@ -source 'https://rubygems.org' - diff --git a/template/ruby/function/handler.rb b/template/ruby/function/handler.rb deleted file mode 100644 index 1c5f146a..00000000 --- a/template/ruby/function/handler.rb +++ /dev/null @@ -1,5 +0,0 @@ -class Handler - def run(req) - return "Hello world from the Ruby template" - end -end diff --git a/template/ruby/index.rb b/template/ruby/index.rb deleted file mode 100644 index 9016c462..00000000 --- a/template/ruby/index.rb +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright (c) Alex Ellis 2017. All rights reserved. -# Copyright (c) OpenFaaS Author(s) 2018. All rights reserved. -# Licensed under the MIT license. See LICENSE file in the project root for full license information. - -require_relative 'function/handler' - -req = ARGF.read - -handler = Handler.new -res = handler.run req - -puts res diff --git a/template/ruby/template.yml b/template/ruby/template.yml deleted file mode 100644 index ab1e5ac3..00000000 --- a/template/ruby/template.yml +++ /dev/null @@ -1,24 +0,0 @@ -language: ruby -fprocess: ruby index.rb -build_options: - - name: dev - packages: - - make - - automake - - gcc - - g++ - - subversion - - python3-dev - - musl-dev - - libffi-dev - - libssh - - libssh-dev -welcome_message: | - - Warning: - This template is deprecated, use the ruby-http template instead. - - You have created a Ruby function using the Classic Watchdog. - - To include third-party dependencies create a Gemfile. You can also - include developer-dependencies using the "dev" build_option.