How to add custom nodes while running node-red inside docker? (without creating a npm package)

For locally running node-red
I do

cd ~/.node-red
npm install ~/dev/node-red-contrib-example-lower-case

Same things I want to achieve but inside docker node-red

Hi @sabir

You still need to create the skeleton of the NPM package along with its package.json file etc etc.

Here is the step 1 can take (there are a few ways)

  1. run npm pack in the root directory that your node is - this will create the file that is usually uploaded to NPM (but we wont do that)

  2. Install the file to Node RED using the UI - there is an option to upload.

image

A caveat you might need to be wary of, is during development, to increase the version number for each upload.

As mentioned, there are a few ways - but as I don't use docker (many who do of course), I'm not sure of the other ways

I think you can do the same for Docker in that the Docker data folder holds your userDir folder and so you need to do the install there.

Obviously, you need to restart Node-RED after each change to your source-code though, not sure how you do that with the docker version.

Normally for dev, I run Node-RED locally using PM2 and use PM2's watch facilities to watch for file changes in nodes being developed (and settings.js, etc) so that it restarts node-red for me.

1 Like

Thanks for response
This is what works for me

Dockerfile

FROM nodered/node-red:latest
COPY settings.js /data/
USER root
RUN mkdir /data/nodes
COPY ./custom-node /data/nodes
RUN chown -R node-red:node-red /data/nodes
USER node-red
RUN cd /data/nodes && npm install
USER node-red
RUN npm install --no-fund --no-update-notifier --save node-red-contrib-storage-mongodb

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.