Skip to content

Commit

Permalink
openfaas: Support OpenFaaS Cloud
Browse files Browse the repository at this point in the history
Only client is used as function (using node runtime):

Usage:

```
echo '{ "hostname": "ifconfig.io", "port": 80 , "path":"/all.json" }' \
  | curl -H "Content-Type: application/json" -X POST -d @- \
  https://rzr.o6s.io/iotjs-express

```

Relate-to: github.com/openfaas/openfaas-cloud/pull/523
Change-Id: I49ca87f508a52e922414f86cbce2e40487fb023a
Signed-off-by: Philippe Coval <p.coval@samsung.com>
  • Loading branch information
rzr committed Oct 23, 2019
1 parent d69a1e2 commit 977f9ae
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 0 deletions.
28 changes: 28 additions & 0 deletions extra/tools/openfaas/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/echo docker build . -f
# -*- coding: utf-8 -*-
# SPDX-License-Identifier: MIT
#{
# Copyright 2019-present Samsung Electronics France SAS, and other contributors
#
# This Source Code Form is subject to the terms of the MIT Licence
# If a copy of the MIT was not distributed with this file
# You can obtain one at:
# https://spdx.org/licenses/MIT.html
#}

FROM rzrfreefr/iotjs-express:latest
LABEL maintainer "Philippe Coval (p.coval@samsung.com)"

ENV project iotjs-express-openfaas
COPY . /usr/local/opt/${project}/src/${project}/
WORKDIR /usr/local/opt/${project}/src/${project}/

ADD https://github.com/openfaas/faas/releases/download/0.6.9/fwatchdog /usr/bin
RUN chmod +x /usr/bin/fwatchdog

ENV read_timeout="60"
ENV write_timeout="60"
ENV fprocess="xargs iotjs --help"

HEALTHCHECK --interval=5s CMD [ -e /tmp/.lock ] || exit 1
CMD [ "fwatchdog" ]
17 changes: 17 additions & 0 deletions extra/tools/openfaas/handler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* -*- mode: js; js-indent-level:2; -*-
* SPDX-License-Identifier: MIT
*
* Copyright 2019-present Samsung Electronics France SAS, and other contributors
*
* This Source Code Form is subject to the terms of the MIT Licence
* If a copy of the MIT was not distributed with this file
* You can obtain one at:
* https://spdx.org/licenses/MIT.html
*
*/
"use strict"
var ClientRequest = require('iotjs-express/example/client');

module.exports = (context, callback) => {
ClientRequest(JSON.parse(context || {}), callback);
}
13 changes: 13 additions & 0 deletions extra/tools/openfaas/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions extra/tools/openfaas/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "function",
"version": "1.0.0",
"description": "",
"main": "handler.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "Philippe Coval <p.coval@samsung.com> (https://www.npmjs.com/~rzr)",
"license": "MIT",
"dependencies": {
"iotjs-express": "0.0.12"
}
}
9 changes: 9 additions & 0 deletions stack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: 1.0
provider:
name: openfaas
gateway: http://127.0.0.1:8080
functions:
iotjs-express:
lang: node
handler: ./extra/tools/openfaas
image: rzrfreefr/faas-iotjs-express

0 comments on commit 977f9ae

Please sign in to comment.