Skip to content

Configuration through environment variables #838

Open

Description

@he8us

Hello,

I'm interested by Solid and want to host my own POD (I host everything myself).

My production environment runs Docker and all the configuration is done through environment variables. I checked the documentation and I didn't found anything about it. Was this possibility already discussed ? Is this out-of-scope ?

If you give me a go, I can do a proposal.

See you,
Cédric

Activity

  1. kjetilk commented on Oct 3, 2018

    @kjetilk
    Member

    I haven't used Docker to any extent, but I sat here struggling a few minutes ago and really wanted an environment variable so that I could point at a different config file... :-) So, yes, I'd really be in favour of having that!

    Would you want to have environment variables for all the config options, or just basic pointers to config file(s)?

  2. he8us commented on Oct 3, 2018

    @he8us
    ContributorAuthor

    IMHO, every configuration option should be configurable via the environment.

    I'm an addict of the 12 Factors methodology and the Chapter 3 explain what I have in mind: https://12factor.net/config

    To be more specific we have the defaults:

    module.exports = {
      'auth': 'oidc',
      'localAuth': {
        'tls': true,
        'password': true
      },
      'configPath': './config',
      'dbPath': './.db',
      'port': 8443,
      'serverUri': 'https://localhost:8443',
      'webid': true,
      'dataBrowserPath': 'default'
    }

    which can be overriden by the config.json file

    {
      "root": "./data",
      "port": "8443",
      "serverUri": "https://192.168.99.100:8443",
      "webid": true,
      "mount": "/",
      "configPath": "./config",
      "dbPath": "./.db",
      "sslKey": "./cert.key",
      "sslCert": "./cert.pem",
      "multiuser": true,
      "corsProxy": "/proxy"
    }

    And what I propose is a third level of overrides, so we can have the same global configuration but override some parts depending of the environment or the server architecture.

    #Environment Variables
    SOLID_SERVER_URI='https://myown.pod'
    SOLID_MULTIUSER=false
  3. kjetilk commented on Oct 3, 2018

    @kjetilk
    Member

    OK, that sounds great to me!

    I think you should base it on the release/v5.0.0 branch, so hopefully we can release it with that one. Also be aware that in version 6, we are going to rework the code extensively, (see #788 for detailed discussion), so we can't guarantee that the code will make it into that, but a good config system is on my list of architectural elements that we require. I think we will also rely more on other people's code for such.

  4. sramam commented on Oct 3, 2018

    @sramam

    I'm new to the project and haven't looked at the code yet, but would something like node-config be useful in this context?

    I've used node-config before and it works really nicely for the purpose.

    It does allow the config to be an actual javascript file, with attendant risks of "developer creativity".

  5. kjetilk commented on Oct 3, 2018

    @kjetilk
    Member

    Yes, that does look reasonable!

  6. he8us commented on Oct 3, 2018

    @he8us
    ContributorAuthor

    Actually, that was the library I had in mind. And I agree with @sramam, I used it in multiple projects in the past and it's really powerful. I will submit a PR in the coming days, I just need to understand the code ;)

    I read the full discussion on #788 and I think you should look closely to node-config to be part of the rewrite/refactor since it's one of the best config system I used.

  7. kjetilk commented on Oct 3, 2018

    @kjetilk
    Member

    Ok, great stuff! Go for it! I hope we can bring the code into 6.0.0 too!

  8. m14t commented on Oct 20, 2018

    @m14t

    I just created PR #879 for this.

    node-config seemed a little opinionated to pull in to an existing project since it wants your config file to live in config/${NODE_ENV}.json.

    Given that we already have a list of options we want to support, I looped over this in ~20 lines of code to accomplish this without any 3rd party libraries.

    If this is close to acceptable, I'd love to respond to any feedback on that PR.

    I hope I didn't steal your thunder @he8us!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions