Use 'Projects' on Mac / Docker with git to transfer to Prod without 'Projects' on RPi

Hi, I develop my flows on Docker for Mac - then push changes to Github.
To then bring the latest code onto my production RPi, I open Node-Red Admin, then do - open editor - Project History Tab > Commit History > Refresh Commit History > Pull

I would like to write a script to do this. Something like

git clone http://github/myfiles/ThePrjName.git /opt/myfiles/libraryName/data/Projects/master --depth 1 (/opt/myfiles/ is where I have my projects)

and then I assume some Node-RED command line function to refresh the flows? Whilst I am at it, I will set the edit in settings.js to disableEditor: true - this will give me more security & automate a CD/CI flow. Any guidance on this?

Anybody done something like this?

Ansible? https://docs.ansible.com/ansible/latest/index.html
In the playbook, use Node-REDā€™s http admin API wherever you can.

1 Like

If you update the project files you should restart Node-RED to reload the project.

However, I'd suggest a slightly different approach. You don't need to enable the projects feature on your production raspberry pi if you don't plan to expose the editor.

You can manually git clone the repository somewhere and then run node-red using the command line args to point to your project directory (--userDir) as well as the name of the flow file to use.

This general model of using projects for your development environment but not in your production environment is outlined in this blog post - https://knolleary.net/2018/06/01/creating-a-node-red-deployment-pipeline-to-ibm-cloud/ (although in that instance I also setup an automatic deployment mechanism so whenever I push changes to the git repo they get deployed to an IBM Cloud instance. You don't need to do all that, but the basic principle is there).

3 Likes

Thank you all, I will go play with these ideas.

Okay, I am doing something wrong.

  1. I create the host folder for the docker instance. \homedir\homedig2core\data\
  2. I Clone my repo here: \homedir\homedig2core\data\cloned
  3. I copy the following files from location 2) to 1):
  - flow.json
  - flow_cred.json
  - package.json

I start the Node-RED container: docker run -p 1880:1880 -v /opt/iotplay/homedig2core/data:/data --detach --name homedig2core nodered/node-red:latest

It opens an empty Node-RED editor. What am I missing?

By default docker uses a file called flows.json.... like yours but with an extra s :slight_smile:

Ohh my.... let me go check

That worked... these flows came from a project, now running them in ā€˜Productionā€™ using just git clone to RPi host, but flows have been with me for many years, might come from there. Were working under Projects on Docker on Mac, have not trsttd if rename to flows.json will also work on Projects. Will report hack.

Thank you.

One more issue - if I use Projects on Mac, and git clone to get the Project to Production - where do I enter my Credentials?

I now have this message on Node-RED:

Credentials could not be decrypted
The flow credential file is encrypted, but the project's encryption key is missing or invalid.
The flow credential file will be reset on the next deployment. Any existing flow credentials will be cleared.

I see my .config.json - at the bottom has the below section, I do not know where it got the credentialSecret, but it's clearly not working:

 "_credentialSecret": "hashed-version-of-something-blablablabla....",
 "users": {
  "MyEditorUser": {
   "editor": {
    "view": {
     "view-show-grid": true,
     "view-snap-grid": true,
     "view-grid-size": 20,
     "view-node-status": true,
     "view-node-show-label": true,
     "view-show-tips": false
    }
   },
   "menu-menu-item-palette": false
  }
 }

Which hashed value is stored here? I checked, it is not the hashed password I added to the settings.js file for the setting adminAuth for the MyEditorUser, neither is it the Project's flow_cred.json hash.

Or should I edit the .config.json file - and make "hashed-version-of-something-blablablabla...." the same as what lives in Projects (on the Mac & in GitHub) under flow_cred.json ?

When projects are not enabled, Node-RED will use the credentialSecret value in your settings.js file.

If it doesn't find a value in the settings file, it generates it own one and stores it in the runtime config file (.config.json) as _credentialSecret.

hmmm, my credentialSecret that I use in Projects was set in settings.js ...

I think its also related to my previous flow.json vs flows.json problem, busy checking.

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