Skip to content

Commit c827613

Browse files
authored
Merge pull request #879 from m14t/feature/environment-variables
Allow configuration via environment variables
2 parents 97814d4 + 4bef3a5 commit c827613

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ $ solid start --help
171171
--webid Enable WebID authentication and access control (uses HTTPS)
172172
--mount [value] Serve on a specific URL path (default: '/')
173173
--config-path [value]
174+
--config-file [value]
174175
--db-path [value]
175176
--auth [value] Pick an authentication strategy for WebID: `tls` or `oidc`
176177
--owner [value] Set the owner of the storage (overwrites the root ACL file)
@@ -197,9 +198,20 @@ $ solid start --help
197198
--email-auth-pass [value] Password of your email service
198199
--useApiApps Do you want to load your default apps on /api/apps?
199200
--api-apps [value] Path to the folder to mount on /api/apps
201+
--redirect-http-from [value] HTTP port or ','-separated ports to redirect to the solid server port (e.g. "80,8080").
202+
--server-name [value] A name for your server (not required, but will be presented on your server's frontpage)
203+
--server-description [value] A description of your server (not required)
204+
--server-logo [value] A logo that represents you, your brand, or your server (not required)
200205
-v, --verbose Print the logs to console
206+
-h, --help output usage information
201207
```
202208

209+
Instead of using flags, these same options can also be configured via environment variables taking the form of `SOLID_` followed by the `SNAKE_CASE` of the flag. For example `--api-apps` can be set via the `SOLID_API_APPS`environment variable, and `--serverUri` can be set with `SOLID_SERVER_URI`.
210+
211+
CLI flags take precedence over Environment variables, which take precedence over entries in the config file.
212+
213+
Configuring Solid via the config file can be a concise and convenient method and is the generally recommended approach. CLI flags can be useful when you would like to override a single configuration parameter, and using environment variables can be helpful in situations where you wish to deploy a single generic Docker image to multiple environments.
214+
203215
## Use Docker
204216

205217
Build with:

bin/lib/start.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,23 @@ module.exports = function (program, server) {
1313
options
1414
.filter((option) => !option.hide)
1515
.forEach((option) => {
16+
const configName = option.name.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase())
17+
const snakeCaseName = configName.replace(/([A-Z])/g, '_$1')
18+
const envName = `SOLID_${snakeCaseName.toUpperCase()}`
19+
1620
let name = '--' + option.name
1721
if (!option.flag) {
1822
name += ' [value]'
1923
}
20-
start.option(name, option.help)
24+
25+
if (process.env[envName]) {
26+
const raw = process.env[envName]
27+
const envValue = /^(true|false)$/.test(raw) ? raw === 'true' : raw
28+
29+
start.option(name, option.help, envValue)
30+
} else {
31+
start.option(name, option.help)
32+
}
2133
})
2234

2335
start.option('-v, --verbose', 'Print the logs to console')

0 commit comments

Comments
 (0)