Add support for n8n configuration via file

This commit is contained in:
Jan Oberhauser 2020-03-27 12:30:42 +01:00
parent 45ee6472de
commit 764172d46f
2 changed files with 58 additions and 0 deletions

View file

@ -177,3 +177,52 @@ webhook URLs get registred with external services.
```bash
export WEBHOOK_TUNNEL_URL="https://n8n.example.com/"
```
## Configuration via file
It is also possible to configure n8n via a configuration file.
It is not necessary to define all values. Only the ones which should be
different from the defaults.
If needed also multiple files can be supplied to for example have generic
base settings and some specific ones depending on the environment.
The path to the JSON configuration file to use can be set via the environment
variable `N8N_CONFIG_FILES`.
```bash
# Single file
export N8N_CONFIG_FILES=/folder/my-config.json
# Multiple files can be comma-separated
export N8N_CONFIG_FILES=/folder/my-config.json,/folder/production.json
```
A possible configuration file could look like this:
```json
{
"executions": {
"process": "main",
"saveDataOnSuccess": "none"
},
"generic": {
"timezone": "Europe/Berlin"
},
"security": {
"basicAuth": {
"active": true,
"user": "frank",
"password": "some-secure-password"
}
},
"nodes": {
"exclude": "[\"n8n-nodes-base.executeCommand\",\"n8n-nodes-base.writeBinaryFile\"]"
}
}
```
All possible values which can be set and their defaults can be found here:
[https://github.com/n8n-io/n8n/blob/master/packages/cli/config/index.ts](https://github.com/n8n-io/n8n/blob/master/packages/cli/config/index.ts)

View file

@ -273,6 +273,15 @@ const config = convict({
});
// Overwrite default configuration with settings which got defined in
// optional configuration files
if (process.env.N8N_CONFIG_FILES !== undefined) {
const configFiles = process.env.N8N_CONFIG_FILES.split(',');
console.log(`\nLoading configuration overwrites from:\n - ${configFiles.join('\n - ')}\n`);
config.loadFile(configFiles);
}
config.validate({
allowed: 'strict',
});