diff --git a/Design:-Runnable-Project.md b/Design:-Runnable-Project.md index 46144ba..6c355d2 100644 --- a/Design:-Runnable-Project.md +++ b/Design:-Runnable-Project.md @@ -14,7 +14,9 @@ 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. 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 ? 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` - command-line flag - `--credentialSecret="..."` @@ -24,9 +26,44 @@ The package would provide an npm start script that runs node-red with the approp ### Runtime settings When deploying the project, there will also be a need to have the runtime settings provided. These are not normally part of a project generated by Node-RED. The question is whether we have some tooling support to generate, or we just document how to do it. For example, the user would manually add a `settings.js` file to their project repo. +> DCJ: If we have the "add node-red as a dependency" checkbox - could it not also... "copy default settings.js into project" ? (but ensuring flowFile doesn't clash) ### Dockerfile We should also have an example Dockerfile that can be used to build and run a project. +> DCJ: Here is an example that works with resin.io - note that the flow file is set as an ENV variable (for now) (and the package.json needs node red as a dependency) +```# base-image for node on any machine using a template variable, +# see more about dockerfile templates here: http://docs.resin.io/deployment/docker-templates/ +# and about resin base images here: http://docs.resin.io/runtime/resin-base-images/ +# Note the node:slim image doesn't have node-gyp + +FROM resin/%%RESIN_MACHINE_NAME%%-node:8-slim + +#RUN apt-get update && apt-get install -yq \ +# build-essential && \ +# apt-get clean && rm -rf /var/lib/apt/lists/* + +WORKDIR /usr/src/app + +COPY package.json package.json + +RUN JOBS=MAX npm install --production --unsafe-perm --no-optional && npm cache clean --force && rm -rf /tmp/* + +COPY . ./ + +ENV INITSYSTEM on +ENV FLOWS=flow.json +ENV NODE_PATH=/usr/src/app/node_modules + +EXPOSE 1880 + +CMD ["npm", "start", "node_modules/node-red/red.js"]``` + +A really minimal Dockerfile to build an image 9but not run) could be as simple as + +```FROM node:8-onbuild +ENV FLOWS=flow.json +VOLUME /root/.node-red +EXPOSE 1880``` \ No newline at end of file