From fcddb77b4825b14a0c06689d94f9086b9482899b Mon Sep 17 00:00:00 2001 From: Djordje Lukic Date: Fri, 4 Dec 2020 11:24:37 +0100 Subject: [PATCH] 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 --- local/build.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/local/build.go b/local/build.go index 1d85458981c..2d1a5a130e1 100644 --- a/local/build.go +++ b/local/build.go @@ -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 }