Skip to content

Instantly share code, notes, and snippets.

@dceejay
Last active November 24, 2020 15:39
Show Gist options
  • Save dceejay/9435867 to your computer and use it in GitHub Desktop.
Save dceejay/9435867 to your computer and use it in GitHub Desktop.
Dockerfile for Node-RED
# Dockerfile for Node-RED - pulls latest master code from git
# Use the node.js v4 LTS engine
FROM node:4-slim
MAINTAINER ceejay
RUN mkdir -p /root/.node-red
WORKDIR /root/.node-red
# download latest stable node-red
RUN npm install -g --unsafe-perm node-red
RUN npm install -g --save node-red/node-red-dashboard node-red-contrib-web-worldmap node-red-node-random
# use external storage for the user directory
VOLUME /root/.node-red
# expose port
EXPOSE 1880
# Set the default command to execute
# when creating a new container
CMD ["node-red-pi","-v","--max-old-space-size=512","flow.json"]
# docker build --rm=true --tag=node-red .
# docker run -it -p 1880:1880 --name mynodered node-red
# docker run -it -p 1880:1880 -v ~/data:/root/.node-red --name mynodered node-red

Install docker as per latest instructions at

https://docs.docker.com/installation/

e.g. for Ubuntu 14.04

sudo apt-get update
sudo apt-get install linux-image-generic-lts-trusty wget
wget -qO- https://get.docker.com/ | sh

add yourself to docker group for when you get fed up with all the sudo below...

sudo usermod -aG docker $USER
sudo service docker restart

install Node-RED from the gist above

sudo docker build -rm -t davecj/node-red http://gist.github.com/raw/9435867/Dockerfile
or
sudo docker build -rm -t davecj/node-red git://gist.github.com/9435867.git

(or copy / paste the Dockerfile and build)

sudo docker build -rm -t davecj/node-red - < Dockerfile

Note: there will be errors during the npm install - but they should be warnings about gyp failing to build icu and serialport - but they will fail back to pre-compiled versions ok. So all should be ok.

run (as daemon)

sudo docker run -d -p 1880:1880 --name mynodered davecj/node-red

start a command line inside the container

sudo docker run -it --rm -p 1880:1880 --name mynodered davecj/node-red /bin/bash

show running containers

sudo docker ps -a

show all images (so you can tidy up)

sudo docker images
@siddhant-bharti
Copy link

How can we pass the creds/ environment variable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment