Skip to content

Commit 2ba5e4c

Browse files
committed
in watch mode force pull policy to build for services with both build and develop attributes
This default behaviour will force a rebuild of the service images at watch process startup and be sure containers will be in sync with the local source code Signed-off-by: Guillaume Lours <[email protected]>
1 parent 0ab21a2 commit 2ba5e4c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cmd/compose/watch.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import (
2020
"context"
2121
"fmt"
2222

23+
"github.com/compose-spec/compose-go/types"
24+
2325
"github.com/docker/cli/cli/command"
2426
"github.com/docker/compose/v2/internal/locker"
2527
"github.com/docker/compose/v2/pkg/api"
@@ -85,6 +87,12 @@ func runWatch(ctx context.Context, dockerCli command.Cli, backend api.Service, w
8587
}
8688

8789
if !watchOpts.noUp {
90+
for index, service := range project.Services {
91+
if service.Build != nil && service.Develop != nil {
92+
service.PullPolicy = types.PullPolicyBuild
93+
}
94+
project.Services[index] = service
95+
}
8896
upOpts := api.UpOptions{
8997
Create: api.CreateOptions{
9098
Build: &build,

0 commit comments

Comments
 (0)