mirror of
https://github.com/openfaas/faas.git
synced 2025-06-18 12:06:37 +00:00
Light-weight examples for HelloWorld - for on reading an input/request.
This commit is contained in:
18
sample-functions/BaseFunctions/node/Dockerfile
Normal file
18
sample-functions/BaseFunctions/node/Dockerfile
Normal file
@ -0,0 +1,18 @@
|
||||
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 i
|
||||
COPY handler.js .
|
||||
|
||||
ENV fprocess="node handler.js"
|
||||
|
||||
HEALTHCHECK --interval=1s CMD [ -e /tmp/.lock ] || exit 1
|
||||
|
||||
CMD ["fwatchdog"]
|
||||
|
5
sample-functions/BaseFunctions/node/build.sh
Executable file
5
sample-functions/BaseFunctions/node/build.sh
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo "Building functions/node:6.9.1-alpine"
|
||||
docker build -t functions/node:6.9.1-alpine .
|
||||
|
15
sample-functions/BaseFunctions/node/handler.js
Normal file
15
sample-functions/BaseFunctions/node/handler.js
Normal file
@ -0,0 +1,15 @@
|
||||
"use strict"
|
||||
|
||||
let getStdin = require('get-stdin');
|
||||
|
||||
let handler = require('./handler');
|
||||
|
||||
let handle = (req) => {
|
||||
console.log(req);
|
||||
};
|
||||
|
||||
getStdin().then(val => {
|
||||
handle(val);
|
||||
}).catch(e => {
|
||||
console.error(e.stack);
|
||||
});
|
15
sample-functions/BaseFunctions/node/package.json
Normal file
15
sample-functions/BaseFunctions/node/package.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"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": {
|
||||
"get-stdin": "^5.0.1"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user