-
Notifications
You must be signed in to change notification settings - Fork 387
Quick Custom Image
Dave Conway-Jones edited this page Oct 17, 2019
·
1 revision
If you just want to add some nodes or maybe make a docker container out of and existing project then you can use the Docker layering to add to the existing base images.
For example a Dockerfile
like this
FROM nodered/node-red
# copy node-red project files into place
COPY flows.json /data/flows.json
COPY flows_cred.json /data/flows_cred.json
COPY settings.js /data/settings.js
# copy package.json to the WORKDIR so npm builds for node-red
COPY package.json .
RUN npm install --unsafe-perm --no-update-notifier --no-audit --only=production
CMD ["npm", "start"]
will copy in your package.json, settings.js, flows and flows_creds files and install all the relevant modules. If you don't need flows or settings then just comment or delete them from the example above.
Note: the package.json
file must contain both the base node-red project as a dependency, AND a run script section like this
{
"name": "node-red-project",
"description": "A Node-RED Project",
"version": "0.0.1",
"dependencies": {
"node-red": "1.0.2",
"node-red-contrib-web-worldmap": "*",
"node-red-dashboard": "*"
},
"scripts": {
"start": "node $NODE_OPTIONS node_modules/node-red/red.js $FLOWS"
}
}
A quick way to run and test this Dockerfile is the command line
docker run --rm -p 1880:1880 -it --name mytest $(docker build -q .)
Which will create the image - run it on port 1880, then delete the container when you close it.