Skip to content

Commit

Permalink
use bake by default
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
  • Loading branch information
ndeloof committed Jan 30, 2025
1 parent 8402888 commit 2a136eb
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions pkg/compose/build_bake.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,40 +48,33 @@ import (
)

func buildWithBake(dockerCli command.Cli) (bool, error) {
b, ok := os.LookupEnv("COMPOSE_BAKE")
if !ok {
if dockerCli.ConfigFile().Plugins["compose"]["build"] == "bake" {
b, ok = "true", true
}
}
if !ok {
return false, nil
}
bake, err := strconv.ParseBool(b)
if err != nil {
return false, err
}
if !bake {
return false, nil
}

enabled, err := dockerCli.BuildKitEnabled()
if err != nil {
return false, err
}
if !enabled {
logrus.Warnf("Docker Compose is configured to build using Bake, but buildkit isn't enabled")
return false, nil
}

_, err = manager.GetPlugin("buildx", dockerCli, &cobra.Command{})
if err != nil {
if manager.IsNotFound(err) {
logrus.Warnf("Docker Compose is configured to build using Bake, but buildx isn't installed")
logrus.Warn("buildx plugin not installed.")
return false, nil
}
return false, err
}
return true, err

b, ok := os.LookupEnv("COMPOSE_BAKE")
if !ok {
// User can opt-out with COMPOSE_BAKE=false but we use bake by default
return true, nil
}
bake, err := strconv.ParseBool(b)
if err != nil {
return false, err
}
return bake, nil
}

// We _could_ use bake.* types from github.com/docker/buildx but long term plan is to remove buildx as a dependency
Expand Down

0 comments on commit 2a136eb

Please sign in to comment.