DocIntel icon indicating copy to clipboard operation
DocIntel copied to clipboard

Read configuration from environment vars

Open nor3th opened this issue 3 years ago • 2 comments

Hey

Are the docintel apps able to read custom configuration variables from the docker environment variable settings? This would spare having to adjust the configuration in the docker-compose.yml as well as the appsettings.json file.

Regards

nor3th avatar Dec 03 '22 22:12 nor3th

Thanks for the suggestion. I'll see what can be done.

ancailliau avatar Dec 13 '22 07:12 ancailliau

The underlying asp.net core framework supports configuration via environment variables out of the box. So every option from the appsettings.json can also be configured via an env variable in docker-compose.yml. For nested options, you have to replace the curly braces with double underscores. Example:

{
    "ApplicationName" :  "DocIntel",
    "Email": {
        "EmailEnabled": false
    }
}

becomes in docker-compose:

  webapp:
    image: "docintelapp/webapp"
    container_name: docintel-dev-webapp
    ports:
      - 5005:80
    environment:
      - APPLICATIONNAME=DocIntel
      - EMAIL__EMAILENABLED=false

see also https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-7.0#evcp

wintamute avatar May 04 '23 14:05 wintamute