Unable to Create custom docker image of custom node-red core code

Hi,
I forked node-red/node-red repository and made some custom changes to its UI and functionality. Now I want to create a docker image of this edited node-red source code. I found this link regarding the customer docker image creation. But it mentions that it picks node-red code from npm registry.
How do I make custom docker image of a local node-red source code ?

the node-red version is a dependency in the package.json there - so edit that to point that at your local version instead.

I tried doing that. Image gets built But when I run the image using docker run -it -p 1880:1880 --name <name> <image> that didn't work. It said Module Not Found error.

What exactly did you put in the package.json file?

This is the package.json file for docker-custom

{
    "name": "node-red-docker",
    "version": "1.0.5",
    "description": "Low-code programming for event-driven applications",
    "homepage": "http://nodered.org",
    "license": "Apache-2.0",
    "main": "node_modules/node-red/red/red.js",
    "scripts": {
        "start": "node $NODE_OPTIONS node_modules/node-red/red.js $FLOWS"
    },
    "contributors": [],
    "dependencies": {
        "node-red": "file:../node-red"
    },
    "engines": {
        "node": ">=10"
    }
}

Hi @shrey.garg

I've edited your post to make the JSON a bit more readable.

I don't have a quick answer here - this isn't something I've thought about or done before.

The node-red git repository contains 7 separate npm modules that make up Node-RED. You can't simply point to the root of the git repository because that is not the same thing as the node-red module published to npm.

There may be an easier way to do it, but I would try something along the lines of:

  1. run grunt release to build the npm module tgz files. These get written to .dist/modules/.
  2. modify your package.json file to point to these tgz files:
    "dependencies": {
        "@node-red/util": "file:../node-red/.dist/modules/node-red-util-x.y.z.tgz",
        "@node-red/runtime": "file:../node-red/.dist/modules/node-red-runtime-x.y.z.tgz",
        "@node-red/registry": "file:../node-red/.dist/modules/node-red-registry-x.y.z.tgz",
        "@node-red/nodes": "file:../node-red/.dist/modules/node-red-nodes-x.y.z.tgz",
        "@node-red/editor-client": "file:../node-red/.dist/modules/node-red-editor-client-x.y.z.tgz",
        "@node-red/editor-api": "file:../node-red/.dist/modules/node-red-editor-api-x.y.z.tgz",
        "node-red": "file:../node-red/.dist/modules/node-red-x.y.z.tgz"
    },

You will need to change x.y.z for whatever version number you've given your custom modules. (Use the command node scripts/set-package-version.js x.y.z to update all of the module's package.json files with the version number of your choosing before running grunt release).

That should then install the modules from your customised version. But as I said... I haven't tried this, so not sure if there's anything else needed.

1 Like

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