Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions pkg/compose/build_bake.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,15 +289,11 @@ func (s *composeService) doBuildBake(ctx context.Context, project *types.Project
_ = os.Remove(metadataFile)
}()

buildx, err := manager.GetPlugin("buildx", s.dockerCli, &cobra.Command{})
buildx, err := s.getBuildxPlugin()
if err != nil {
return nil, err
}

if versions.LessThan(buildx.Version[1:], "0.17.0") {
return nil, fmt.Errorf("compose build requires buildx 0.17 or later")
}

args := []string{"bake", "--file", "-", "--progress", "rawjson", "--metadata-file", metadataFile}
// FIXME we should prompt user about this, but this is a breaking change in UX
for _, path := range read {
Expand Down Expand Up @@ -414,6 +410,27 @@ func (s *composeService) doBuildBake(ctx context.Context, project *types.Project
return results, nil
}

func (s *composeService) getBuildxPlugin() (*manager.Plugin, error) {
buildx, err := manager.GetPlugin("buildx", s.dockerCli, &cobra.Command{})
if err != nil {
return nil, err
}

if buildx.Err != nil {
return nil, buildx.Err
}

if buildx.Version == "" {
return nil, fmt.Errorf("failed to get version of buildx")
}

if versions.LessThan(buildx.Version[1:], "0.17.0") {
return nil, fmt.Errorf("compose build requires buildx 0.17 or later")
}

return buildx, nil
}

// makeConsole wraps the provided writer to match [containerd.File] interface if it is of type *streams.Out.
// buildkit's NewDisplay doesn't actually require a [io.Reader], it only uses the [containerd.Console] type to
// benefits from ANSI capabilities, but only does writes.
Expand Down
Loading