Give progress its own context

The build and progress can't share the same context, the progress context
needs to live longer for the progress to be able to read all the messages
from build.

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
This commit is contained in:
Djordje Lukic 2020-12-04 11:24:37 +01:00
parent 6830ca1919
commit fcddb77b48
1 changed files with 8 additions and 1 deletions

View File

@ -103,8 +103,15 @@ func (s *composeService) build(ctx context.Context, project *types.Project, opts
Driver: d,
},
}
// Progress needs its own context that lives longer than the
// build one otherwise it won't read all the messages from
// build and will lock
progressCtx, cancel := context.WithCancel(context.Background())
defer cancel()
w := progress.NewPrinter(progressCtx, os.Stdout, "auto")
// We rely on buildx "docker" builder integrated in docker engine, so don't need a DockerAPI here
w := progress.NewPrinter(ctx, os.Stdout, "auto")
_, err = build.Build(ctx, driverInfo, opts, nil, nil, w)
return err
}