Quick links : Home - Part 1 - Part 2 - Part 3 - Part 4 - Part 5
Part 5 - Codebase - Dependencies - Config - Backing services - Build, release, run - Processes - Port binding - Concurrency - Disposability - Dev/prod parity - Logs - Admin processes
I - Codebase
One codebase tracked in revision control, many deploys
First we need to decide what is a Node-RED application code base?
The Node-RED application is defined by a flow file and an optional credentials file. However, the flow may require some additional nodes to be installed to the runtime and the flow also runs within a Node.js application, which is the Node-RED runtime. This runtime can be customised and configured, so to fully capture a Node-RED application code base you need to capture the :
- application flow and credential file
- the package.json file, which captures all required Node.js and Node-RED node packages needed by the flow
- the Node-RED runtime source files
For this workshop a starter git project has been provided, containing a Node-RED runtime, customised to be managed by a cloud.
Node-RED has the projects feature, which is turned off by default. It allows Node-RED to work with a revision control system to manage the Node-RED flow and associated content. This can be considered the application source?
In this section you will fork a git repo, which is a starter template for a new project.
- Open a browser an navigate to the git starter project repo
- Make sure you are logged into your GitHub account then press the Fork button so you have your own copy of the repo

- Open the git settings

- (OPTIONAL) If you have 2-factor authentication enabled on your GitHub account, then you need to use a Personal Access Token when using the git command line tools. To create a Personal Access Token, select Developer settings then Personal access tokens then Generate new token. Give the token a use, select all scopes except
admin:enterpriseandadmin:gpg.keyscope then Generate token
- On your system edit file .node-red/settings.js in your home directory. At the bottom of the file change the projects setting to
enabled : true
- Start Node-RED running locally on your system. If it is already running stop it by entering Ctrl-c in the command window where it is running. Use command
node-redto start Node-RED - Open a browser to access your local Node-RED runtime on http://localhost:1880 and you should see a Projects wizard, as you've just enabled the project feature in the Node-RED editor.

- Select the Clone Repository.
- Enter your git credentials (use the Personal Access Token as the password if you have one set on your GitHub account - your GitHub account password will not work if a personal access token is defined)
- give the Node-RED project a name
- copy the Git repo URL from your git repo GitHub page:

- press the Clone project button when all the details have been completed - leave the Credentials encryption key field blank

- Drag an inject and debug node onto the sheet and connect them to create a basic flow then deploy the changes

- Switch to the project history section in the side panel, where you can see the flows.json file has uncommitted local changes. Move your mouse over the entry and press the + button to stage the change

- The flows.json file is now ready to be committed. Press the commit button then enter a commit message basic flow to commit the flow change

- Switch to the Commit History section of the project panel. Here you can see the last commit and also that the local git branch is 1 commit ahead of the remote master. Click the up arrow to open the Manage remote branch panel

- Press the Push button to send the commit to the remote branch

You can also pull changes from the repo, so if a team is working on the same Node-RED application they can push changes and the other team members can pull the changes.
Note: There is an issue when running on Windows 10 - the git push is not passing the git credentials correctly. If this is the case you can issue a git push command from a console window with the current directory the active git project directory : user home dir\.node-red\projects\repo name
Part 5 - Codebase - Dependencies - Config - Backing services - Build, release, run - Processes - Port binding - Concurrency - Disposability - Dev/prod parity - Logs - Admin processes
Quick links : Home - Part 1 - Part 2 - Part 3 - Part 4 - Part 5