OpenMediaVault-Plugin-Developers / openmediavault-compose

openmediavault plugin for docker-compose
18 stars 6 forks source link

Change Order of Environment File Loading #32

Closed tomgehrmann closed 1 month ago

tomgehrmann commented 1 month ago

Current Behavior

Currently, the order in which environment files are loaded is counterintuitive. The global environment variables override service-specific ones and global variables cannot be used in service-specific env files. docker compose --file SERVICE_COMPOSE_FILE --file SERVICE_COMPOSE_OVERRIDE_FILE --env-file SERVICE_ENV_FILE --env-file GLOBAL_ENV_FILE config

Proposed Change

Load the global environment file first, then load the service-specific environment file second. docker compose --file SERVICE_COMPOSE_FILE --file SERVICE_COMPOSE_OVERRIDE_FILE --env-file GLOBAL_ENV_FILE --env-file SERVICE_ENV_FILE config

Reasoning

A global environment file suggests that its values can be referenced within service-specific environment files, just like they can be used in the compose file. With the current load order, service-specific variables are overridden by global variables.

Example Use Case

global.env: DOMAINNAME=domain.tld service.env: SERVICEDOMAIN=service.${DOMAINNAME}

ryecoaaron commented 1 month ago

That seems fine to me. I will make the change.

ryecoaaron commented 1 month ago

This change went out in 7.2.7 in the repo now.