Git integration with docker

I spent some time recently testing node red projects feature. And trying to get a proper git repo for node red itself as well as git submodules per project. While the projects are straight forward, I'm not sure what the best approach for the node red program is. Currently running it in docker, so have docker-compose.yml and Dockerfile in the main/root repo together with everything else that comes from the docker bind mount. It works recently well at the moment, but at some cost in terms of configurations and complexity.

For example when running node red (either in prod or locally), the things to click on in the browser affects a multiple files:

  • .config.projects.json
  • .config.runtime.json
  • .config.users.json

Additionally, each user may want to select themes and other settings individually, which affects:

  • settings.js

Finally, I got .env file for docker variables and .env.json to be imported in settings.js (since node red doesn't support .env files directly).

So a total of 6 files that must be configured per machine it runs on. My gut reaction was to add all of these to gitignore, then supply example versions for blueprints and even prod versions ready to use. These are later applied in entrypoint.sh depending on some arg to use prod or dev environment.

In the end I'm quite happy with the result, but it takes trial and error to see what files need special handling and this takes time. Having built-in git support for projects and the code itself (flows.json) is nice. But I think having version control and backup of the node-red runtime is important too, as it can contain a lot of details which should be handled in the same way as the code.

I'm still not sure about the exact distinction between package.json in the node red root folder and each individual project folder's package.json. Based on earlier discussion, it sounded like the project package.json has little to no effect and everything goes into main package.json anyway?

Anyone else tried to tame this beast and found some better/smoother solutions?

Noticed that .config.nodes.json keeps changing, even if not modifying any dependencies. Just starting node red on different machines will toggle values like "local": true/false and "user": true/false.

Anyone know why this happens? Is it important? Thinking about adding it to gitignore also. Is this auto-generated by node red if not existing?

You should perhaps do a little reading on how the node.js package manager, npm works. That will explain it.

Each installed package contributes the package to the root node_modules folder, but it will usually have dependencies and these may also be contributed - and that continues to the bottom of the package tree. This is a bit of a simplified explanation but it gives you a feel for what is going on.

Other aspects of Node-RED may also have their own package roots. For example, uibuilder creates its own separated from your node-red userDir root. and then each instance of a uibuilder node creates another root for managing front-end code. Each of these roots will have their own package.json file.

Node.js package management is very complex and comprehensive.