From c7db0faab4d3938d217333a89e9a5669e164f497 Mon Sep 17 00:00:00 2001 From: aafrey Date: Mon, 10 Apr 2017 17:17:35 -0400 Subject: [PATCH] Adding CoffeeScript base example Adding CoffeeScript base --- sample-functions/BaseFunctions/README.md | 1 + .../BaseFunctions/coffee/Dockerfile | 19 +++++++++++++++++++ .../BaseFunctions/coffee/build.sh | 5 +++++ .../BaseFunctions/coffee/handler.coffee | 7 +++++++ .../BaseFunctions/coffee/package.json | 16 ++++++++++++++++ 5 files changed, 48 insertions(+) create mode 100644 sample-functions/BaseFunctions/coffee/Dockerfile create mode 100644 sample-functions/BaseFunctions/coffee/build.sh create mode 100644 sample-functions/BaseFunctions/coffee/handler.coffee create mode 100644 sample-functions/BaseFunctions/coffee/package.json diff --git a/sample-functions/BaseFunctions/README.md b/sample-functions/BaseFunctions/README.md index c3763c12..8171899a 100644 --- a/sample-functions/BaseFunctions/README.md +++ b/sample-functions/BaseFunctions/README.md @@ -7,6 +7,7 @@ Each one will read the request from the watchdog then print it back resulting in | Language | Docker image | Notes | |------------------------|-----------------------------------------|----------------------------------------| | Node.js | functions/base:node-6.9.1-alpine | Node.js built on Alpine Linux | +| Coffeescript | functions/base:node-6.9.1-alpine | Coffeescript/Nodejs built on Alpine Linux | | Golang | functions/base:golang-1.7.5-alpine | Golang compiled on Alpine Linux | | Python | functions/base:python-2.7-alpine | Python 2.7 built on Alpine Linux | | Java | functions/base:openjdk-8u121-jdk-alpine | OpenJDK built on Alpine Linux | diff --git a/sample-functions/BaseFunctions/coffee/Dockerfile b/sample-functions/BaseFunctions/coffee/Dockerfile new file mode 100644 index 00000000..321ba26d --- /dev/null +++ b/sample-functions/BaseFunctions/coffee/Dockerfile @@ -0,0 +1,19 @@ +FROM node:6.9.1-alpine + +ADD https://github.com/alexellis/faas/releases/download/0.5.1-alpha/fwatchdog /usr/bin +RUN chmod +x /usr/bin/fwatchdog + +WORKDIR /root/ + +COPY package.json . + +RUN npm install -g coffee-script && \ + npm i + +COPY handler.coffee . + +ENV fprocess="coffee handler.coffee" + +HEALTHCHECK --interval=1s CMD [ -e /tmp/.lock ] || exit 1 + +CMD ["fwatchdog"] diff --git a/sample-functions/BaseFunctions/coffee/build.sh b/sample-functions/BaseFunctions/coffee/build.sh new file mode 100644 index 00000000..8f1edcbf --- /dev/null +++ b/sample-functions/BaseFunctions/coffee/build.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +echo "Building functions/base:coffeescript-1.12-alpine" +docker build -t functions/base:coffeescript-1.12-alpine . + diff --git a/sample-functions/BaseFunctions/coffee/handler.coffee b/sample-functions/BaseFunctions/coffee/handler.coffee new file mode 100644 index 00000000..d2576273 --- /dev/null +++ b/sample-functions/BaseFunctions/coffee/handler.coffee @@ -0,0 +1,7 @@ +getStdin = require 'get-stdin' + +handler = (req) -> console.log req + +getStdin() +.then (val) -> handler val +.catch (e) -> console.error e.stack diff --git a/sample-functions/BaseFunctions/coffee/package.json b/sample-functions/BaseFunctions/coffee/package.json new file mode 100644 index 00000000..52ea9bf4 --- /dev/null +++ b/sample-functions/BaseFunctions/coffee/package.json @@ -0,0 +1,16 @@ +{ + "name": "NodejsBase", + "version": "1.0.0", + "description": "", + "main": "faas_index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "coffeescript": "^1.12.4", + "get-stdin": "^5.0.1" + } +}