[Docker] Node-red docker!


Recommended Posts

This is how I got my version of Node-Red running on docker on Unraid..

 

What is Node-Red? Please have a look at http://Nodered.org and http://www.techrepublic.com/article/node-red/

(spoiler, it is an amazing application to enable the Internet of Things. I use it to monitor sensors around my house and to send alerts to my phones using PushBullet).

 

First of all, create a Dockerfile containing:

# Dockerfile for Node-RED - pulls latest master code from git
#FROM ubuntu:12.04
FROM phusion/baseimage:0.9.11

# based on the original by @cpswan
MAINTAINER ceejay
# some changes by Spants

# add universe repository to /etc/apt/sources.list
# we need it later as rlwrap is required by node.js
#RUN sed -i s/main/'main universe'/ /etc/apt/sources.list

# make sure everything is up to date - update and upgrade
RUN apt-get update -y
# RUN apt-get upgrade -y

# install dependencies
#RUN apt-get install python-software-properties python g++ make software-properties-common wget curl unzip git -y
RUN apt-get install python-software-properties wget curl unzip git -y

# add node.js repo
RUN add-apt-repository ppa:chris-lea/node.js -y

# another update so added repo can be used
RUN apt-get update

# install node.js
RUN apt-get install nodejs -y --force-yes

# download latest node-red
RUN cd /opt && git clone https://github.com/node-red/node-red.git

# remove some nodes
RUN cd /opt/node-red/nodes/core && rm -rf hardware deprecated
RUN cd /opt/node-red/nodes/core/io && rm -f 25-serial*

# install node-red node_modules
RUN cd /opt/node-red && npm install --production && npm install eyes js2xmlparser pushbullet fs.notify

# add extra nodes project so we have the lot just in case.
RUN cd /opt/node-red/nodes && git clone https://github.com/node-red/node-red-nodes.git

# expose port
EXPOSE 1880

# Set the default command to execute
# when creating a new container
CMD /usr/bin/node /opt/node-red/red.js -v /config/flow.json

 

I changed the base image to match my use, added the /config and also added pushbullet

Save this file to a directory on your unraid system

 

Build the image/container:

 

From this directory:

docker build --tag="nodered” .

  (dont forget the trailing . !)

 

and then: (/mnt/disk9/appdata/nodered is my data directory for node-red)

docker run -d --name nodered -p 1880:1880 -v /etc/localtime:/etc/localtime:ro -v /mnt/disk9/appdata/nodered:/config:rw nodered

 

Then check if it is running with http://192.168.1.22:1880 (change the IP to suit!)

 

I don't know how to make a template, sorry.

 

** Just one gotcha, you will get an error if you change a flow and deploy. If you delete the flow from the disk then deploy it will work ok. I don't know why yet. **

Tony

 

** edit added --force-yes to nodejs install line **

Link to comment

This is how I got my version of Node-Red running on docker on Unraid..

 

What is Node-Red? Please have a look at http://Nodered.org and http://www.techrepublic.com/article/node-red/

(spoiler, it is an amazing application to enable the Internet of Things. I use it to monitor sensors around my house and to send alerts to my phones using PushBullet).

 

First of all, create a Dockerfile containing:

# Dockerfile for Node-RED - pulls latest master code from git
#FROM ubuntu:12.04
FROM phusion/baseimage:0.9.11

# based on the original by @cpswan
MAINTAINER ceejay
# some changes by Spants

# add universe repository to /etc/apt/sources.list
# we need it later as rlwrap is required by node.js
#RUN sed -i s/main/'main universe'/ /etc/apt/sources.list

# make sure everything is up to date - update and upgrade
RUN apt-get update -y
# RUN apt-get upgrade -y

# install dependencies
#RUN apt-get install python-software-properties python g++ make software-properties-common wget curl unzip git -y
RUN apt-get install python-software-properties wget curl unzip git -y

# add node.js repo
RUN add-apt-repository ppa:chris-lea/node.js -y

# another update so added repo can be used
RUN apt-get update

# install node.js
RUN apt-get install nodejs -y

# download latest node-red
RUN cd /opt && git clone https://github.com/node-red/node-red.git

# remove some nodes
RUN cd /opt/node-red/nodes/core && rm -rf hardware deprecated
RUN cd /opt/node-red/nodes/core/io && rm -f 25-serial*

# install node-red node_modules
RUN cd /opt/node-red && npm install --production && npm install eyes js2xmlparser pushbullet fs.notify

# add extra nodes project so we have the lot just in case.
RUN cd /opt/node-red/nodes && git clone https://github.com/node-red/node-red-nodes.git

# expose port
EXPOSE 1880

# Set the default command to execute
# when creating a new container
CMD /usr/bin/node /opt/node-red/red.js -v /config/flow.json

 

I changed the base image to match my use, added the /config and also added pushbullet

Save this file to a directory on your unraid system

 

Build the image/container:

 

From this directory:

docker build --tag="nodered” .

  (dont forget the trailing . !)

 

and then: (/mnt/disk9/appdata/nodered is my data directory for node-red)

docker run -d --name nodered -p 1880:1880 -v /etc/localtime:/etc/localtime:ro -v /mnt/disk9/appdata/nodered:/config:rw nodered

 

Then check if it is running with http://192.168.1.22:1880 (change the IP to suit!)

 

I don't know how to make a template, sorry.

 

** Just one gotcha, you will get an error if you change a flow and deploy. If you delete the flow from the disk then deploy it will work ok. I don't know why yet. **

Tony

 

AWESOME!  I gotta try this!!

Link to comment
  • 3 years later...

I wonder if there's a way to make the feedparser node have a "state" of sorts? Because every time the docker image is updated, the feedparser flow is executed and it sends old posts again to my email. Is there a way to prevent the feedparser node from sending duplicates?

As of now, I'm back to using IFTTT to get RSS feed updates.

 

Link to comment
5 hours ago, ICDeadPpl said:

I wonder if there's a way to make the feedparser node have a "state" of sorts? Because every time the docker image is updated, the feedparser flow is executed and it sends old posts again to my email. Is there a way to prevent the feedparser node from sending duplicates?

As of now, I'm back to using IFTTT to get RSS feed updates.

 

The best way is to find the author of the node on flows.Nodered.org and raise an issue on github/slack/Google groups

 

Tony

Link to comment
  • 10 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.