Skip to content

Commit

Permalink
do not require a build section but for rebuild action
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
  • Loading branch information
ndeloof committed Dec 2, 2024
1 parent a8469db commit 0b2f059
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
17 changes: 3 additions & 14 deletions pkg/compose/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,23 +119,12 @@ func (s *composeService) watch(ctx context.Context, syncChannel chan bool, proje
if options.Build == nil {
return fmt.Errorf("--no-build is incompatible with watch action %s in service %s", types.WatchActionRebuild, service.Name)
}
// set the service to always be built - watch triggers `Up()` when it receives a rebuild event
service.PullPolicy = types.PullPolicyBuild
project.Services[i] = service
}
}

if len(services) > 0 && service.Build == nil {
// service explicitly selected for watch has no build section
return fmt.Errorf("can't watch service %q without a build context", service.Name)
}

if len(services) == 0 && service.Build == nil {
logrus.Debugf("service %q has no build context, skipping watch", service.Name)
continue
}

// set the service to always be built - watch triggers `Up()` when it receives a rebuild event
service.PullPolicy = types.PullPolicyBuild
project.Services[i] = service

dockerIgnores, err := watch.LoadDockerIgnore(service.Build)
if err != nil {
return err
Expand Down
5 changes: 4 additions & 1 deletion pkg/watch/dockerignore.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ func (i dockerPathMatcher) MatchesEntireDir(f string) (bool, error) {
return true, nil
}

func LoadDockerIgnore(build *types.BuildConfig) (*dockerPathMatcher, error) {
func LoadDockerIgnore(build *types.BuildConfig) (PathMatcher, error) {
if build == nil {
return EmptyMatcher{}, nil
}
repoRoot := build.Context
absRoot, err := filepath.Abs(repoRoot)
if err != nil {
Expand Down

0 comments on commit 0b2f059

Please sign in to comment.