mirror of https://github.com/docker/compose.git
Merge pull request #11405 from ndeloof/issue_11392
Fix load .env from project directory when project file is set by COMPOSE_FILE
This commit is contained in:
commit
3c25af4fe9
|
@ -261,10 +261,10 @@ func (o *ProjectOptions) toProjectOptions(po ...cli.ProjectOptionsFn) (*cli.Proj
|
|||
append(po,
|
||||
cli.WithWorkingDirectory(o.ProjectDir),
|
||||
cli.WithOsEnv,
|
||||
cli.WithEnvFiles(o.EnvFiles...),
|
||||
cli.WithDotEnv,
|
||||
cli.WithConfigFileEnv,
|
||||
cli.WithDefaultConfigPath,
|
||||
cli.WithEnvFiles(o.EnvFiles...),
|
||||
cli.WithDotEnv,
|
||||
cli.WithDefaultProfiles(o.Profiles...),
|
||||
cli.WithName(o.ProjectName))...)
|
||||
}
|
||||
|
|
|
@ -313,3 +313,15 @@ func TestRemoveOrphaned(t *testing.T) {
|
|||
res := c.RunDockerComposeCmd(t, "-f", "./fixtures/sentences/compose.yaml", "-p", projectName, "ps", "--format", "{{.Name}}")
|
||||
res.Assert(t, icmd.Expected{Out: fmt.Sprintf("%s-words-1", projectName)})
|
||||
}
|
||||
|
||||
func TestResolveDotEnv(t *testing.T) {
|
||||
c := NewCLI(t)
|
||||
|
||||
cmd := c.NewDockerComposeCmd(t, "config")
|
||||
cmd.Dir = filepath.Join(".", "fixtures", "dotenv")
|
||||
res := icmd.RunCmd(cmd)
|
||||
res.Assert(t, icmd.Expected{
|
||||
ExitCode: 0,
|
||||
Out: "image: backend:latest",
|
||||
})
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
COMPOSE_FILE="${COMPOSE_FILE:-development/compose.yaml}"
|
|
@ -0,0 +1,2 @@
|
|||
IMAGE_NAME="${IMAGE_NAME:-backend}"
|
||||
IMAGE_TAG="${IMAGE_TAG:-latest}"
|
|
@ -0,0 +1,3 @@
|
|||
services:
|
||||
backend:
|
||||
image: $IMAGE_NAME:$IMAGE_TAG
|
Loading…
Reference in New Issue