0

I was wondering, let's say I had the following .env file:

STAGING_ALLOWED_DOMAINS=example.com
STAGING_SITES=example.com=web:8000

Is there a way to condense the following services to utilise the same environment settings, or do they always need to be explicitly listed for each service?

services:
    web:
        environment:
            ALLOWED_DOMAINS: "${STAGING_ALLOWED_DOMAINS}"
            SITES: "${STAGING_SITES}"
    nginx:
        environment:
            ALLOWED_DOMAINS: "${STAGING_ALLOWED_DOMAINS}"
            SITES: "${STAGING_SITES}"
    celery:
        environment:
            ALLOWED_DOMAINS: "${STAGING_ALLOWED_DOMAINS}"
            SITES: "${STAGING_SITES}"
    celery-beat:
        environment:
            ALLOWED_DOMAINS: "${STAGING_ALLOWED_DOMAINS}"
            SITES: "${STAGING_SITES}"

Is there a cleaner way to share environment configurations?

Micheal J. Roberts
  • 3,735
  • 4
  • 37
  • 76
  • 2
    Does this answer your question? [Re-using environmental variables in docker-compose yml](https://stackoverflow.com/questions/36283908/re-using-environmental-variables-in-docker-compose-yml) – leopal Jan 24 '20 at 10:09
  • @leopal Ahhh yes, that may well do the trick! Thank you so much. – Micheal J. Roberts Jan 24 '20 at 10:11

0 Answers0