Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial docker-projects design note #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ with enough detail to review the intent and direction of the feature.
- [Dynamic MQTT Node](designs/dynamic-mqtt-node.md)
- [Exportable Subflow](designs/exportable-subflow/README.md)
- [Node Timeout API](designs/timeout-api.md)
- [Docker Projects](designs/docker-projects.md)

#### In-progress

Expand Down
92 changes: 92 additions & 0 deletions designs/docker-projects.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
---
state: draft
---

# Docker-enable Projects

## Summary

This design makes Node-RED Projects easier to use with Docker.

In summary, this involves:

1. add a default `Dockerfile` when a Node-RED project is created
2. add a default `settings.js` file to provide a 'production-ready' configuration
for the project
3. add an `npm start` script to `package.json`

The `Dockerfile` and `settings.js` files will be editable from within the editor.

A new `build` sidebar will be added that can be used to run `docker build` and
see its output. It will also support `docker push` to publish built images to dockerhub.

The project settings view will have a docker section where tags/arch options can
be set.

## Authors

- @knolleary

## Details

### Enabling this feature

Another option will be added to `editorTheme` to either enable or disable this
feature.

It will be disabled if:
- projects is not enabled
- the `docker` cli is not foun

Whether it is enabled by default if the prereqs are met is TBD.

### Dockerfile

The default Dockerfile will be based on the `nodered/node-red` image. This means
the user won't have to add `node-red` in as an explicit dependency of the project.

The user will be able to edit the Dockerfile via the editor.

**Todo: Add default Dockerfile here**

### settings.js

The default `settings.js` file will look like:

```
const path = require("path");

module.exports = {
uiPort: process.env.PORT || 1880,
credentialSecret: process.env.NODE_RED_CREDENTIAL_SECRET,
httpAdminRoot: false,
}
```

This means:
- the port defaults to 1880 but can be overridden by the `PORT` env var
- the credential secret can be provided by an env var
- the admin api (inc editor) is disabled
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I basically agree disabled should be default... but ... Is this something that could be exposed as a "mini-settings" config as part of the Docker sidebar ? (ie in additions to docker build and push - should we expose a really limited couple of choices that users would want to change "all the time" - like Base image (default node-red-docker:latest) and this enable admin option ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not as part of the Docker sidebar, but yes, the Project Settings dialog will expose both settings.js and Dockerfile so they can be edited. As a minimum, editing the raw files, but if there is a way to provide a tick-box means of setting 'common' properties, then we should do that.

The hard part of that is knowing how to apply the settings to the files themselves - especially if they have hand-edited the file.


The user will be able to edit the settings file via the editor.

### Build sidebar

**More design work is needed for the sidebar.**

The build sidebar will allow the user to run a Docker build of their project.
The log output will be available via the existing Event Log.

For example, would it be useful to detect and list the images it has built?

The sidebar would also allow the user to publish a built image to Dockerhub.


The design needs to consider how this sidebar could be repurposed for other build
targets in the future. For example, building an Electron-based application rather
than a Docker image.

Copy link
Member

@dceejay dceejay Nov 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Been looking at Electron recently - and there are potentially too many options unless we want to be really prescriptive. However - there are things we could do to help - most of which could be covered by adding fields to package.json (either to existing Node-RED section or a new electron specific section. (Things like the human friendly "productName", which screen to show first (dashboard/editor/map etc), kiosk mode, and again whether to allow admin/editing) - So again a set of minimal options to help config the export - for other tools to then pick up.


## History

- 2019-11-15 - first pass