Search code examples
node.jsdockerpluginsnode-red

Node Red Plugin in Container: Node missing


I wrote a custom node for node red and everything is working fine. Now I need to put everything in a docker container. Node red is running and the dependency is installed, but the nodes do not show up on the interface. I do not get any error messages, even when I not include the files, what causes an error on the standalone version.

My package.json:

{
    "name": "boolean_nodes",
    "version": "1.0.0",
    "description": "Nodes for boolean operation.",
    "dependencies": {
        "node-red": "*",
        "node-red-contrib-home-assistant-websocket": "*",
        "mqtt": "*"
    },
    "scripts": {
        "start": "node-red"
    },
    "author": "",
    "license": "ISC",
    "node-red": {
        "nodes": {
            "BOOL-Switch": "./data/bool/switch/bool_switch.js",
            "BOOL-AND": "./data/bool/and/bool_and.js",
            "BOOL-OR": "./data/bool/or/bool_or.js",
            "ML-Interface": "mlinterface.js"
        }
    }
}

My dockerfile:

FROM nodered/node-red

# Copy package.json to the WORKDIR so npm builds all
# of your added nodes modules for Node-RED
COPY package.json .
RUN npm install --unsafe-perm --no-update-notifier --no-fund --only=production

# Copy _your_ Node-RED project files into place
COPY /data/bool/switch/bool_switch.js /data/bool/switch/bool_switch.js
COPY /data/bool/switch/bool_switch.html /data/bool/switch/bool_switch.html

COPY /data/bool/and/bool_and.js /data/bool/and/bool_and.js
COPY /data/bool/and/bool_and.html /data/bool/and/bool_and.html

COPY /data/bool/or/bool_or.js /data/bool/or/bool_or.js
COPY /data/bool/or/bool_or.html /data/bool/or/bool_or.html

If experimented with diffrent paths for the files but that does not cause any different behavior. How do I get may plugin in the container?


Solution

  • Normally you'd package your node as an npm module and then npm install it.

    In this instance, you can still load what we call 'local' nodes which aren't packaged properly. By default Node-RED will look under the nodes directory of node-red user directory.

    In the docker image, /data is used as the user directory.

    So you should be copying your files somewhere under /data/nodes/