Skip to content

Commit

Permalink
dockercompose: watch service env files (#5750)
Browse files Browse the repository at this point in the history
* dockercompose: watch service env files

* dockercompose: base relative env files against project path
  • Loading branch information
nicksieger authored May 3, 2022
1 parent 29f6fd1 commit 18478de
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/tiltfile/docker_compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,15 @@ func (s *tiltfileState) dockerCompose(thread *starlark.Thread, fn *starlark.Buil
return nil, err
}
svc.Options = s.dcResOptions[svc.Name]
for _, f := range svc.ServiceConfig.EnvFile {
if !filepath.IsAbs(f) {
f = filepath.Join(project.ProjectPath, f)
}
err = io.RecordReadPath(thread, io.WatchFileOnly, f)
if err != nil {
return nil, err
}
}
s.dcByName[svc.Name] = svc
}

Expand Down
24 changes: 24 additions & 0 deletions internal/tiltfile/tiltfile_docker_compose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,30 @@ func TestDockerComposeEnvFile(t *testing.T) {
f.assertConfigFiles(expectedConfFiles...)
}

func TestDockerComposeServiceEnvFile(t *testing.T) {
f := newFixture(t)

f.file("docker-compose.yml", `services:
bar:
image: bar-image
env_file:
- bar.env
`)
f.file("bar.env", "BAR_PORT=4000\n")
f.file("Tiltfile", "docker_compose('docker-compose.yml')")

f.load()
f.assertDcManifest("bar")

expectedConfFiles := []string{
"Tiltfile",
".tiltignore",
"docker-compose.yml",
"bar.env",
}
f.assertConfigFiles(expectedConfFiles...)
}

func TestDockerComposeConflict(t *testing.T) {
f := newFixture(t)

Expand Down

0 comments on commit 18478de

Please sign in to comment.