浏览代码

watch: only monitor configured paths (#10599)

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

Signed-off-by: Nicolas De Loof <[email protected]>
Nicolas De loof 2 年之前
父节点
当前提交
916aac6c27
共有 1 个文件被更改,包括 8 次插入5 次删除
  1. 8 5
      pkg/compose/watch.go

+ 8 - 5
pkg/compose/watch.go

@@ -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