mirror of https://github.com/node-red/node-red.git
Updated Design: Runnable Project (markdown)
parent
45c7e25251
commit
3d2eb847f1
|
@ -16,14 +16,15 @@ It should be possible to deploy a project without using the editor. For example:
|
|||
We can't quite do this today. Here are the missing pieces:
|
||||
|
||||
1. the project's `package.json` needs to list `node-red` as a dependency. On balance, I think this is the right approach, rather than treat node-red as an assumed prerequisite. I don't think we should do this be default; maybe add a checkbox in the project settings' dependencies page to include `node-red`.
|
||||
> DCJ: Yes - agree it should be a dependency. Currently not hard to add manually, but could be even easier.
|
||||
> DCJ: Yes - agree it should be a dependency. Currently not hard to add manually, but could be even easier. It would be a prerequisite dependency for inside a Docker container.
|
||||
2. it must be possible to point node-red at a project on start-up, without using the editor to do so. Currently we overload the flowFile argument to set the active project - but that only works if the project is 'known'. It would be better to point at a `projectDir` wherever it may exist.
|
||||
> DCJ: Are we pointing Node-RED or npm start ? Which are we calling to run it ? If npm start then don't we already have to be in the correct project directory ? (or use npm start --prefix projdir)
|
||||
> DCJ: Are we pointing Node-RED or npm start ? Which are we calling to run it ? If npm start then don't we already have to be in the correct project directory ? (or use npm start --prefix projectDir)
|
||||
> DCJ: Having played with it a while - I think `npm start` from within the relevant directory is the way to go to start with.
|
||||
3. it must be possible to provide the credentialSecret for the project without it being part of any of the version controlled files. Options for this include:
|
||||
- env var - `NODE_RED_CREDENTIAL_SECRET`
|
||||
- [DCJ] easy to add to settings.js - `credentialSecret: process.env.NODE_RED_CREDENTIAL_SECRET` and would suit Docker style deploy.
|
||||
- command-line flag - `--credentialSecret="..."`
|
||||
- [DCJ] added as option to runnable-project dev branch
|
||||
- [DCJ] added as new command line option to runnable-project dev branch
|
||||
|
||||
4. Must handle running in a read-only environment. If the package is installed globally (in order to insert a command link into /usr/bin) then the flow file and settings.js will be in root space - which ought not to be writable by the user. Currently even starting Node-RED with -u option pointing somewhere protected will fail. Options include
|
||||
- just handling the error.
|
||||
|
@ -31,10 +32,10 @@ We can't quite do this today. Here are the missing pieces:
|
|||
- setting disableEditor to `true` also.
|
||||
|
||||
The package would provide an npm start script that runs node-red with the appropriate command-line args.
|
||||
It could also provide a `bin` section that could allow starting via command line if installed globally.
|
||||
|
||||
> DCJ: If you run the steps above then node-red and other modules will be installed *below* the CWD in node_modules... all good. If however we want to take our project dir and npm pack it... on re-installing it the project itself will also be in the node_modules dir thus making npm start (or pathing back to node-red) trickier.
|
||||
Another possibility would be to add a bin section to package.json - but that requires a command to be run (and doesn't take parameters) so in order to do that we would also need to create that script/.js file or porvide a template.
|
||||
|
||||
It could also provide a `bin` section that could allow starting via command line if installed globally - but that requires a command to be run (that doesn't take parameters) so in order to do that we would also need to create that script/.js file or provide a template.
|
||||
|
||||
> DCJ: Actually by pre-req node-red it automatically adds the node-red command to the node_modules/.bin so the package.json start script can just call node-red and all is good.
|
||||
|
||||
|
@ -56,7 +57,7 @@ We should also have an example Dockerfile that can be used to build and run a pr
|
|||
|
||||
> DCJ: Here is an example *Dockerfile.template* that works with various flavours of Docker - note that the flow file is set using the start command in package.json, and it needs node red as a dependency)
|
||||
|
||||
"scripts": {"start": "node node_modules/node-red/red.js flow.json"},
|
||||
"scripts": {"start": "node-red -u . flow.json"},
|
||||
|
||||
```
|
||||
# Expects -e NODE_RED_CREDENTIAL_SECRET="my_secret_key" to be part of the docker run command at start time
|
||||
|
@ -85,7 +86,9 @@ RUN JOBS=MAX npm install --production --unsafe-perm --no-optional && npm cache c
|
|||
|
||||
COPY . ./
|
||||
|
||||
# required for Resin.io
|
||||
ENV INITSYSTEM on
|
||||
# useful for pigpiod node to be able to talk to daemon on host.
|
||||
ENV HOST_IP=172.17.0.1
|
||||
ENV NODE_PATH=/usr/src/app/node_modules
|
||||
|
||||
|
@ -96,7 +99,8 @@ CMD ["npm", "start"]
|
|||
|
||||
A really minimal Dockerfile to build an image (but not run) could be as simple as
|
||||
|
||||
```FROM node:8-onbuild
|
||||
```
|
||||
FROM node:8-onbuild
|
||||
VOLUME /root/.node-red
|
||||
EXPOSE 1880
|
||||
```
|
Loading…
Reference in New Issue