From 0a9d1277c51d9947af8c042f0b005ad93a2afd71 Mon Sep 17 00:00:00 2001 From: Silvin Lubecki Date: Mon, 24 Jul 2023 16:11:06 +0200 Subject: [PATCH] Display builder's name on the first build line. Code borrowed from buildx commands/build.go. Signed-off-by: Silvin Lubecki --- pkg/compose/build.go | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/pkg/compose/build.go b/pkg/compose/build.go index 5d3f8316f..3b19c75a0 100644 --- a/pkg/compose/build.go +++ b/pkg/compose/build.go @@ -73,6 +73,7 @@ func (s *composeService) build(ctx context.Context, project *types.Project, opti var ( b *builder.Builder nodes []builder.Node + w *xprogress.Printer ) if buildkitEnabled { builderName := options.Builder @@ -88,17 +89,22 @@ func (s *composeService) build(ctx context.Context, project *types.Project, opti if err != nil { return nil, err } - } - // 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() + // 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, err := xprogress.NewPrinter(progressCtx, s.stdout(), os.Stdout, options.Progress) - if err != nil { - return nil, err + w, err = xprogress.NewPrinter(progressCtx, s.stdout(), os.Stdout, options.Progress, + xprogress.WithDesc( + fmt.Sprintf("building with %q instance using %s driver", b.Name, b.Driver), + fmt.Sprintf("%s:%s", b.Driver, b.Name), + )) + + if err != nil { + return nil, err + } } builtDigests := make([]string, len(project.Services)) @@ -152,8 +158,10 @@ func (s *composeService) build(ctx context.Context, project *types.Project, opti }) // enforce all build event get consumed - if errw := w.Wait(); errw != nil { - return nil, errw + if buildkitEnabled { + if errw := w.Wait(); errw != nil { + return nil, errw + } } if err != nil {