Skip to content

Commit 0434654

Browse files
committed
do not require a build section but for rebuild action
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
1 parent 1d08390 commit 0434654

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

pkg/compose/watch.go

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -119,23 +119,12 @@ func (s *composeService) watch(ctx context.Context, syncChannel chan bool, proje
119119
if options.Build == nil {
120120
return fmt.Errorf("--no-build is incompatible with watch action %s in service %s", types.WatchActionRebuild, service.Name)
121121
}
122+
// set the service to always be built - watch triggers `Up()` when it receives a rebuild event
123+
service.PullPolicy = types.PullPolicyBuild
124+
project.Services[i] = service
122125
}
123126
}
124127

125-
if len(services) > 0 && service.Build == nil {
126-
// service explicitly selected for watch has no build section
127-
return fmt.Errorf("can't watch service %q without a build context", service.Name)
128-
}
129-
130-
if len(services) == 0 && service.Build == nil {
131-
logrus.Debugf("service %q has no build context, skipping watch", service.Name)
132-
continue
133-
}
134-
135-
// set the service to always be built - watch triggers `Up()` when it receives a rebuild event
136-
service.PullPolicy = types.PullPolicyBuild
137-
project.Services[i] = service
138-
139128
dockerIgnores, err := watch.LoadDockerIgnore(service.Build)
140129
if err != nil {
141130
return err

pkg/watch/dockerignore.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ func (i dockerPathMatcher) MatchesEntireDir(f string) (bool, error) {
6464
return true, nil
6565
}
6666

67-
func LoadDockerIgnore(build *types.BuildConfig) (*dockerPathMatcher, error) {
67+
func LoadDockerIgnore(build *types.BuildConfig) (PathMatcher, error) {
68+
if build == nil {
69+
return EmptyMatcher{}, nil
70+
}
6871
repoRoot := build.Context
6972
absRoot, err := filepath.Abs(repoRoot)
7073
if err != nil {

0 commit comments

Comments
 (0)