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

Fix load .env from project directory when project file is set by COMPOSE_FILE #11405

Merged
merged 1 commit into from Jan 31, 2024

Conversation

ndeloof
Copy link
Contributor

@ndeloof ndeloof commented Jan 25, 2024

What I did
get location of the compose file (maybe set by env) before loading default .env file. Doing so, if COMPOSE_FILE is set to a distinct directory, we will load sibling .env file as user would expect

Related issue
fixes #11392

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

…OSE_FILE

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
Copy link

codecov bot commented Jan 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (bef8785) 56.61% compared to head (a8bd3b7) 56.55%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11405      +/-   ##
==========================================
- Coverage   56.61%   56.55%   -0.07%     
==========================================
  Files         136      136              
  Lines       11544    11544              
==========================================
- Hits         6536     6529       -7     
- Misses       4384     4390       +6     
- Partials      624      625       +1     

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

Copy link
Contributor

@glours glours left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@glours glours merged commit 3c25af4 into docker:main Jan 31, 2024
26 checks passed
@ndeloof ndeloof deleted the issue_11392 branch February 22, 2024 16:44
@MikaelElkiaer
Copy link

MikaelElkiaer commented Mar 5, 2024

Hey @ndeloof I just dropped a comment on a related issue: #11531 (comment)

It seems there is another regression related to this.
At first this fix did not help me.
Even though I have a .env right next to my docker-compose.yaml - which sets COMPOSE_FILE=subdir/docker-compose.yaml, it still traverses parent directories to resolve a different docker-compose.yaml before adhering to the .env in CWD.

Edit: Created an issue #11575

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

Successfully merging this pull request may close these issues.

[BUG] .env file at the same level of $COMPOSE_FILE not sourced
5 participants