Skip to content

Commit 0d0e12c

Browse files
ndeloofglours
authored andcommitted
use Bake by default
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
1 parent 92fafcc commit 0d0e12c

3 files changed

Lines changed: 4 additions & 19 deletions

File tree

pkg/compose/build.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"fmt"
2323
"os"
2424
"strings"
25-
"sync"
2625
"time"
2726

2827
"github.com/compose-spec/compose-go/v2/types"
@@ -34,7 +33,6 @@ import (
3433
"github.com/docker/buildx/util/buildflags"
3534
xprogress "github.com/docker/buildx/util/progress"
3635
"github.com/docker/cli/cli/command"
37-
"github.com/docker/cli/cli/hints"
3836
cliopts "github.com/docker/cli/opts"
3937
"github.com/docker/compose/v2/internal/tracing"
4038
"github.com/docker/compose/v2/pkg/api"
@@ -71,10 +69,6 @@ func (s *composeService) Build(ctx context.Context, project *types.Project, opti
7169
}, s.stdinfo(), "Building")
7270
}
7371

74-
const bakeSuggest = "Compose can now delegate builds to bake for better performance.\n To do so, set COMPOSE_BAKE=true."
75-
76-
var suggest sync.Once
77-
7872
//nolint:gocyclo
7973
func (s *composeService) build(ctx context.Context, project *types.Project, options api.BuildOptions, localImages map[string]api.ImageSummary) (map[string]string, error) {
8074
imageIDs := map[string]string{}
@@ -156,11 +150,6 @@ func (s *composeService) build(ctx context.Context, project *types.Project, opti
156150
w *xprogress.Printer
157151
)
158152
if buildkitEnabled {
159-
if hints.Enabled() && progress.Mode != progress.ModeQuiet && progress.Mode != progress.ModeJSON {
160-
suggest.Do(func() {
161-
fmt.Fprintln(s.dockerCli.Out(), bakeSuggest) //nolint:errcheck
162-
})
163-
}
164153
builderName := options.Builder
165154
if builderName == "" {
166155
builderName = os.Getenv("BUILDX_BUILDER")

pkg/compose/build_bake.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,7 @@ import (
5151
func buildWithBake(dockerCli command.Cli) (bool, error) {
5252
b, ok := os.LookupEnv("COMPOSE_BAKE")
5353
if !ok {
54-
if dockerCli.ConfigFile().Plugins["compose"]["build"] == "bake" {
55-
b, ok = "true", true
56-
}
57-
}
58-
if !ok {
59-
return false, nil
54+
b = "true"
6055
}
6156
bake, err := strconv.ParseBool(b)
6257
if err != nil {
@@ -72,6 +67,7 @@ func buildWithBake(dockerCli command.Cli) (bool, error) {
7267
}
7368
if !enabled {
7469
logrus.Warnf("Docker Compose is configured to build using Bake, but buildkit isn't enabled")
70+
return false, nil
7571
}
7672

7773
_, err = manager.GetPlugin("buildx", dockerCli, &cobra.Command{})

pkg/e2e/build_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ func TestBuildImageDependencies(t *testing.T) {
284284

285285
t.Run("BuildKit by dependency order", func(t *testing.T) {
286286
cli := NewCLI(t, WithEnv(
287-
"DOCKER_BUILDKIT=1",
287+
"DOCKER_BUILDKIT=1", "COMPOSE_BAKE=0",
288288
"COMPOSE_FILE=./fixtures/build-dependencies/classic.yaml",
289289
))
290290
doTest(t, cli, "build")
@@ -293,7 +293,7 @@ func TestBuildImageDependencies(t *testing.T) {
293293

294294
t.Run("BuildKit by additional contexts", func(t *testing.T) {
295295
cli := NewCLI(t, WithEnv(
296-
"DOCKER_BUILDKIT=1",
296+
"DOCKER_BUILDKIT=1", "COMPOSE_BAKE=0",
297297
"COMPOSE_FILE=./fixtures/build-dependencies/compose.yaml",
298298
))
299299
doTest(t, cli, "build")

0 commit comments

Comments
 (0)