Reputation: 1974
I'd like to automatically deploy a Node-RED instance using docker-compose.
The goal is to deploy:
/data/flows.json
)/data/settings.js
)I can't figure out how to deploy palettes on first start, essentially it would be enough to run cd /data; npm install
on first start.
Here is my docker-compose.yml
file:
version: '2'
services:
nodered:
image: nodered/node-red
user: root:root # necessary, otherwise we get 'access denied'
environment:
TZ: Europe/Amsterdam
ports:
- "1880:1880"
volumes:
- ./data:/data
Upvotes: 2
Views: 3930
Reputation: 1974
After some research I'd like to propose a simple answer to my question.
Pros:
Cons:
Modified docker-compose.yml:
version: '2'
services:
nodered:
image: nodered/node-red
user: root:root # necessary, otherwise we get 'access denied'
entrypoint: /data/entrypoint.sh
environment:
TZ: Europe/Amsterdam
ports:
- "1880:1880"
volumes:
- ./data:/data
/data/entrypoint.sh file:
#!/bin/sh
DIR=`pwd`
cd /data
npm install
cd "$DIR"
npm start -- --userDir /data
For the sake of simplicity npm install
is run during each startup since I figured out that it takes close to nothing (time) and it's very useful if I need to modify package.json on-the-fly. It's very easy to make it run only once by touch
-ing a file and then testing for the presence of the file.
Upvotes: 1
Reputation: 59686
You create your own Docker container that extends the nodered/node-red
container and include your own package.json
that has the extra nodes you want to include in the dependencies
section.
Make sure you add your dependencies to the existing package.json
file that is included in the base image.
More detailed instuctions can be found in the node-red-docker project on github here
Upvotes: 1