compose-go icon indicating copy to clipboard operation
compose-go copied to clipboard

Support env var resolution before substitution inside .env

Open 4rthem opened this issue 3 years ago • 0 comments

Please consider the following project:

# .env
MAIN_DOMAIN=foo.bar
SUB_DOMAIN=a.${MAIN_DOMAIN}
# docker-compose.yaml
services:
  alpine:
    image: alpine
    environment:
      - SUB_DOMAIN

Here I get (as expected):

$ docker compose run --rm alpine env | grep SUB_DOMAIN
SUB_DOMAIN=a.foo.bar

But when I override MAIN_DOMAIN env I still get the same:

$ MAIN_DOMAIN=another.domain docker compose run --rm alpine env | grep SUB_DOMAIN
SUB_DOMAIN=a.foo.bar

I'd like the defined env variable to take precedence before substitution so I would get:

$ MAIN_DOMAIN=another.domain docker compose run --rm alpine env | grep SUB_DOMAIN
SUB_DOMAIN=a.another.domain

I don't know if original repository joho/godotenv supports this but it would be a nice feature for huge projects based on env vars :)

4rthem avatar Dec 13 '21 14:12 4rthem