watch: only monitor configured paths (#10599)

For performance, don't watch the entire build context.

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De loof 2023-05-23 19:35:50 +02:00 committed by GitHub
parent eafcd1b35e
commit 916aac6c27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 5 deletions

View File

@ -130,9 +130,7 @@ func (s *composeService) Watch(ctx context.Context, project *types.Project, serv
}
name := service.Name
bc := service.Build.Context
dockerIgnores, err := watch.LoadDockerIgnore(bc)
dockerIgnores, err := watch.LoadDockerIgnore(service.Build.Context)
if err != nil {
return err
}
@ -150,12 +148,17 @@ func (s *composeService) Watch(ctx context.Context, project *types.Project, serv
dotGitIgnore,
)
watcher, err := watch.NewWatcher([]string{bc}, ignore)
var paths []string
for _, trigger := range config.Watch {
paths = append(paths, trigger.Path)
}
watcher, err := watch.NewWatcher(paths, ignore)
if err != nil {
return err
}
fmt.Fprintf(s.stdinfo(), "watching %s\n", bc)
fmt.Fprintf(s.stdinfo(), "watching %s\n", paths)
err = watcher.Start()
if err != nil {
return err