Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support of COMPOSE_ENV_FILES env variable to pass a list of env files #11061

Merged
merged 1 commit into from Oct 5, 2023

Conversation

glours
Copy link
Contributor

@glours glours commented Oct 2, 2023

What I did
Add a new COMPOSE_ENV_FILES to allow users to define once the env files they want to associate to their Compose configuration
This PR will need a follow up PR in the doc repo to add the new env var cc @aevesdocker

Related issue
Internal discussion with Docker Captains

(not mandatory) A picture of a cute animal, if possible in relation to what you did
image

…iles

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
@glours glours self-assigned this Oct 5, 2023
@glours glours requested review from milas and ndeloof October 5, 2023 18:16
@glours glours marked this pull request as ready for review October 5, 2023 18:16
@codecov
Copy link

codecov bot commented Oct 5, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (a345515) 57.55% compared to head (d286ef2) 57.54%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11061      +/-   ##
==========================================
- Coverage   57.55%   57.54%   -0.01%     
==========================================
  Files         129      129              
  Lines       11237    11241       +4     
==========================================
+ Hits         6467     6469       +2     
- Misses       4141     4144       +3     
+ Partials      629      628       -1     
Files Coverage Δ
cmd/compose/compose.go 68.35% <100.00%> (+0.34%) ⬆️

... and 5 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ndeloof ndeloof merged commit 9dd081b into docker:main Oct 5, 2023
25 checks passed
@nickjj
Copy link

nickjj commented Oct 21, 2023

Hi,

I'm not sure if this handles the use case described in the Docker Captains channel.

# docker-compose.yml
services:
  debian:
    image: "debian:bookworm-slim"
    restart: "${DOCKER_RESTART_POLICY:-unless-stopped}"
# .env
COMPOSE_ENV_FILES=.env,.env.local
DOCKER_RESTART_POLICY=yes
# .env.local
DOCKER_RESTART_POLICY=no

If you run docker compose config the value of restart is yes but it would be expected that it's no through the logic of:

  • docker compose was called without explicitly defining any --env-file flags which means it will look for .env by default
  • The new COMPOSE_ENV_FILES env var will be used which says to interpolate the .env file and then .env.local
    • This is the part that is failing the use case expectation
  • no should be set

If you run COMPOSE_ENV_FILES=.env,.env.local docker compose config then everything works as expected but this requires altering your shell or creating a custom alias to run docker compose with that set. The original use case was to allow for running docker compose commands without modification.

Was this an accidental oversight or am I missing something?

@glours
Copy link
Contributor Author

glours commented Oct 23, 2023

Hey @nickjj
I totally forgot to add the support via the .env files 🤦
Can you open a new issue to track it, please?

@nickjj
Copy link

nickjj commented Oct 23, 2023

No problem, here it is: #11122

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

Successfully merging this pull request may close these issues.

None yet

3 participants