Hi,
I am developing node-red flows for an application. How to create a deployable file similar to WAR or .exe file. Also how to deploy the same?
Do you want NR itself in the package? You need to decide between that and having a default NR installation at each destination. Personally, I'd probably recommend a complete package since you can then be certain of the versions and configuration.
To do a complete package, you will need a local NR installation. Create a folder, in it do npm init
then npm install node-red --save
. Then create a sub-folder for the userDir. That's the folder that you will use to install nodes for use in your flows (though you can also use the parent folder but then a user can't manage that from the Node-RED admin ui - can also be an advantage in some cases). You will need to set up a command to start Node-RED with the correct userDir, that's in the docs. You will also need to change the default flows.json filename because the standard includes the device name which you won't want. Finally, you will have to decide how you want NR to actually run. npm again gives you a simple option for starting manually but you will need a script of some kind if you want it to always be running - either to create and configure a systemd startup script (for Linux/Mac) or the scheduler on Windows. Alternatively, you could install PM2 along side Node-RED and pre-configure so that once started, it will continue to run.
Everything is predicated on npm
so you will want to look at how to use that to its full. It allows you to create a package that can then be installed easily on other devices.
I think you are looking for something like 'Electron' -- one of our contributors has a template project showing how to do this:
Electron lets you create an executable client from a Node.JS application. So that would do the trick if you want your end users to run the Node-RED "application" as a thick client. But that isn't necessary as long as Node.js is installed on the client computer. You can still distribute a complete node.js package that includes node-red (and PM2 if desired) with any required nodes and the flows quite easily.
Thanks, will try the same.
The reason I am looking for an executable or deployable file is
-
I want to deploy the solution on end user machine.
-
I want the end-user to only able to view the node dashboard and not the node workflow page.
-
I do not want end user to access workflow page so that he is not able to touch the code or the nodes
How can this be achieved?
Regards
Prashant
You will need to add a user login to the admin side. Look into the settings.js file. This will prevent users from making deploying any changes but they will still be able to see the flows. AFAIK, there is not yet a way to completely prevent the admin UI. This is due in future releases.
My version is slightly more up to date
Nice idea, I like that, I’ll be intrigued to hear how you get on, and what you decide to do.
You can use the disableEditor
property your settings file to disable the editor - https://github.com/node-red/node-red/blob/a8ec032553cc4fa51803b84fff411507c1b4dfa7/settings.js#L156
The HTTP Admin routes will still be available - but they can be disabled by setting httpAdminRoot
to false
.
What about using docker to do the distribution ? - Give no access to the commandline of the virtual machine and export/map a single virtual directory for data etc, use the other ideas re controlling admin UI access and only give the single port for user dashboard - then have the node autoupdate from a central repository if you want to change any of the nodes etc
Craig
we have the same requirement to deploy or update entire user package.
i like the container idea, it would be the best solution, the electron one looks more complex and less flexible.
however we run our NR on raspi and we exeperienced some problems on full gpio/i2c access from NR container. anyone had the same problem or suggestions how to fix?
we already have influx db and other packaged on container in any case.
how do achieve the container auto update from central repo?
m
If you were going to do this for a reasonable number of systems/sites you would use one of the container orchestration packages dependant on what your bent is -
Craig
yep, got it
i’ll try it out this way.
i think that could also be better to use a container with a complete NR local installation.
just wonder how all dependencies are managed in a local installation
we see this as a way to both initially deploy a solution and maintain to user, but also as a way to recover from a system crash, or for HA solutions.
using docker allows for a better hot swap solution using for example a dual HA raspi system.
m
You may want to look at resin.io. they use containers for maintaining a fleet of devices and have a complete management back end for it..
Yes i know that solution, thats what is needed,
we would however rather like to have an all-in house solution,
we already have all the relevant networking, supervision/monitoring features, mainly looking for an easy and safe NR deployement/CC solution
If it's all in-house solution you want then you'll have to build it yourself ....
The default deploy item in Node-RED is the flow file. It's up to you if you decide to deploy just that to an already existing and managed runtime (maybe inside a container), or the complete runtime container, or wrapped as an electron app, or anything in between.
I agree, and i think the candidate solution is between electron and a container or a mix ..
the need is being able to keep under control the complete app, which is not only NR itself, so also networking and related monitoring, data bases, low level functions and perhaps specific drivers..
also disaster recovery feature must be considered, which on remote and unmanned sites is not easy to grant.
likely the container approach is the best, just need to be verified some specific points about NR and orchestration features.
we are looking at a docker swarm type of solution, also because the iot approach lead to have a quite number of devices alive also for a single site...so this could be an advantage
Given the extra requirements you've now outlined, I'd agree that a container solution would be best. You might want to look at kubernetes for the container orchestration part. It seems to be the most popular of the container orchestration tools & is well supported by cloud (Azure & AWS, etc) as well as on-premise solutions.
You will want to look at a DevOps toolchain for managing changes to the containers themselves and, if you need any local data stores, you may need to look at creating a data container as well as a master.
Agree, that the way im moving, in evaluating kubernetes. should start some tests this week ill give some feedback if of interest.
the main issuse now, apart general architecture design, is to confirm feasibility of NR in a cotainer, and also find smart ways to easy update (not just flows) but the entire environment. there are many dependencies around it to be taken into account, such as openzwave, mraa, boot config, drivers and their compatibility with kernel versions, ui images etc, where solutions such as ansible or simply rsync scripts could help.
Hi,
Does anyone knows steps for node-red with docker.
-
Install node-red on docker
-
Deploy node-red application on docker
Regards,
Prashant