Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker container for noflo-nodejs #107

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM hypriot/rpi-node:latest

# https://docs.flowhub.io/getting-started-node/

# Prepare a Node.js project
RUN mkdir noflo-example && \
cd noflo-example && \
npm init --yes

# Install NoFlo itself
RUN npm install noflo --save

# Install a few components (there are many more)
RUN npm install noflo-filesystem --save && \
npm install noflo-core --save && \
npm install noflo-amqp --save && \
npm install noflo-packets --save && \
npm install noflo-mqtt --save

# Install the runtime
RUN npm install noflo-nodejs --save

COPY init-and-run.sh .
RUN chmod ug+x init-and-run.sh

CMD ./init-and-run.sh


EXPOSE 3569
80 changes: 80 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# docker-noflo-runtime-js
This is the source to build a docker container for [noflo-nodejs](https://github.com/noflo/noflo-nodejs).
There shall be an additional version for X86 in addition to the current ARM (Raspberry Pi) version.

## Very short: How do I use it?
Install docker engine on a Raspberry Pi and then run

docker run -d -e "SEJNUB_FLOWHUB_USERID=<user-id>" -e "SEJNUB_NOFLO_RUNTIME_HOST=<host>" -e "SEJNUB_NOFLO_RUNTIME_SECRET=<secret>" -e "SEJNUB_NOFLO_RUNTIME_LABEL=<label>" --name nojs -p 3569:3569 sejnub/noflo-runtime-js:rpi-latest

and now the longer version:


## Status and rights
Seems to be working.
Totally free to use by everyone.


## Tags
* **``rpi-latest``** Latest version for Raspberry Pi


## Clean up before build
docker rm $(docker ps -a -f status=exited -q)
docker rmi $(docker images -f dangling=true -q)
docker volume rm $(docker volume ls -f dangling=true -q)


## Build

cd ~; rm -rf docker-noflo-runtime-js; git clone https://github.com/sejnub/docker-noflo-runtime-js.git
cd ~/docker-noflo-runtime-js; docker build --no-cache=false -t sejnub/noflo-runtime-js:rpi-latest .


## Push images to https://hub.docker.com

If you are not sejnub you have to retag the images to your username at dockerhub and use those new tags. The following commands use the authors tags.

Log into dockerhub and push the images with

docker login
docker push sejnub/noflo-runtime-js:rpi-latest


## Create env-file (optional)
You have to create an env-file `/usr/local/etc/sejnub-credentials.env` with the following content

# noflo-runtime-js
SEJNUB_FLOWHUB_USERID=<your-user-id-that-you-got-from-flowhub>
SEJNUB_NOFLO_RUNTIME_HOST=<ip-or-hostname-which-can-be-used-to-access-the-runtime>
SEJNUB_NOFLO_RUNTIME_SECRET=<freely-choosable-secret-string>
SEJNUB_NOFLO_RUNTIME_LABEL=<freely-choosable-label>


## Run interactively

Depending on if you created the env-file you run one of the following commands

docker rm -f nojs; docker run -it -e "SEJNUB_FLOWHUB_USERID=<user-id>" -e "SEJNUB_NOFLO_RUNTIME_HOST=<host>" -e "SEJNUB_NOFLO_RUNTIME_SECRET=<secret>" -e "SEJNUB_NOFLO_RUNTIME_LABEL=<label>" --name nojs -p 3569:3569 sejnub/noflo-runtime-js:rpi-latest /bin/bash
docker rm -f nojs; docker run -it --env-file /usr/local/etc/sejnub-credentials.env --name nojs -p 3569:3569 sejnub/noflo-runtime-js:rpi-latest /bin/bash


## Run for production

Depending on if you created the env-file you run one of the following commands

docker rm -f nojs; docker run -d -e "SEJNUB_FLOWHUB_USERID=<user-id>" -e "SEJNUB_NOFLO_RUNTIME_HOST=<host>" -e "SEJNUB_NOFLO_RUNTIME_SECRET=<secret>" -e "SEJNUB_NOFLO_RUNTIME_LABEL=<label>" --name nojs -p 3569:3569 sejnub/noflo-runtime-js:rpi-latest
docker rm -f nojs; docker run -d --env-file /usr/local/etc/sejnub-credentials.env --name nojs -p 3569:3569 sejnub/noflo-runtime-js:rpi-latest

or you can also use a mix like e.g.

docker rm -f nojs; docker run -d --env-file /usr/local/etc/sejnub-credentials.env -e "SEJNUB_NOFLO_RUNTIME_LABEL=<label>" --name nojs -p 3569:3569 sejnub/noflo-runtime-js:rpi-latest



The specified port on the host $SEJNUB_NOFLO_RUNTIME_HOST must be accesible from the browser.


## Links
https://docs.flowhub.io/getting-started-node/

41 changes: 41 additions & 0 deletions docker/init-and-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Configure local runtime
# Usage: node_modules/.bin/noflo-nodejs-init [options]
#
# Options:
# --user Unique Identifier for the runtime owner. [default: "fe5e8086-0299-4b9a-8166-ea62e75e694a"]
# --host Hostname or IP for the runtime. Use "autodetect" or "autodetect(<iface>)" for dynamic detection. [default: "home.bunjes.net"]
# --port Port for the runtime. [number] [default: 3569]
# --label Human-readable label for the runtime. [default: "Raspi Runtime 2"]
# --secret Secret string to be used for the connection. [default: ",i0xJfVE"]
# --id Unique Identifier for the runtime instance. [default: "7fc432e9-a77a-45fe-a2c4-adf8ad777d49"]
# --permissions Permissions [default: "protocol:component,protocol:runtime,protocol:graph,protocol:network,component:getsource,component:setsource"]
# --0.7.2 V [boolean]
# -h, --help Show help [boolean]


# Start the runtime
# Usage: node_modules/.bin/noflo-nodejs [options]
#
# Options:
# --graph Path to a graph file to start
# --capture-output Catch writes to stdout and send to the FBP protocol client [boolean] [default: false]
# --catch-exceptions Catch exceptions and report to the FBP protocol client [boolean] [default: true]
# --debug Start the runtime in debug mode [boolean] [default: false]
# --verbose Log in verbose format [boolean] [default: false]
# --cache Enable component cache [boolean] [default: false]
# --batch Exit when the graph finished [default: false]
# --trace Record flowtrace. If batch is enabled, will [default: false]
# --ide Url where the noflo-ui runs.
# --uuid Runtime UUID
# --host Hostname or IP for the runtime. Use "autodetect" or "autodetect(<iface>)" for dynamic detection. [default: "autodetect"]
# --port Port for the runtime. [number] [default: 3569]
# --secret Secret string to be used for the connection.
# --permissions Permissions [default: "protocol:component,protocol:runtime,protocol:graph,protocol:network,component:getsource,component:setsource"]
# --register Register the runtime with Flowhub [boolean] [default: true]
# --0.7.2 V [boolean]
# -h, --help Show help [boolean]

node node_modules/.bin/noflo-nodejs-init --user $SEJNUB_FLOWHUB_USERID --host $SEJNUB_NOFLO_RUNTIME_HOST --secret $SEJNUB_NOFLO_RUNTIME_SECRET --port 3569 --label $SEJNUB_NOFLO_RUNTIME_LABEL

node node_modules/.bin/noflo-nodejs --host $SEJNUB_NOFLO_RUNTIME_HOST --secret $SEJNUB_NOFLO_RUNTIME_SECRET --capture-output=true