diff --git a/cmd/compose/compose.go b/cmd/compose/compose.go index 4921450b1..17e5e071c 100644 --- a/cmd/compose/compose.go +++ b/cmd/compose/compose.go @@ -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))...) } diff --git a/pkg/e2e/compose_test.go b/pkg/e2e/compose_test.go index 6384c29c8..b37ec0f48 100644 --- a/pkg/e2e/compose_test.go +++ b/pkg/e2e/compose_test.go @@ -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", + }) +} diff --git a/pkg/e2e/fixtures/dotenv/.env b/pkg/e2e/fixtures/dotenv/.env new file mode 100644 index 000000000..869938aa7 --- /dev/null +++ b/pkg/e2e/fixtures/dotenv/.env @@ -0,0 +1 @@ +COMPOSE_FILE="${COMPOSE_FILE:-development/compose.yaml}" \ No newline at end of file diff --git a/pkg/e2e/fixtures/dotenv/development/.env b/pkg/e2e/fixtures/dotenv/development/.env new file mode 100644 index 000000000..936902877 --- /dev/null +++ b/pkg/e2e/fixtures/dotenv/development/.env @@ -0,0 +1,2 @@ +IMAGE_NAME="${IMAGE_NAME:-backend}" +IMAGE_TAG="${IMAGE_TAG:-latest}" diff --git a/pkg/e2e/fixtures/dotenv/development/compose.yaml b/pkg/e2e/fixtures/dotenv/development/compose.yaml new file mode 100644 index 000000000..b44805e30 --- /dev/null +++ b/pkg/e2e/fixtures/dotenv/development/compose.yaml @@ -0,0 +1,3 @@ +services: + backend: + image: $IMAGE_NAME:$IMAGE_TAG