mirror of
https://github.com/docker/compose.git
synced 2025-06-26 08:30:13 +02:00
use Bake by default
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
92fafccfb2
commit
0d0e12cc85
@ -22,7 +22,6 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/compose-spec/compose-go/v2/types"
|
||||
@ -34,7 +33,6 @@ import (
|
||||
"github.com/docker/buildx/util/buildflags"
|
||||
xprogress "github.com/docker/buildx/util/progress"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/hints"
|
||||
cliopts "github.com/docker/cli/opts"
|
||||
"github.com/docker/compose/v2/internal/tracing"
|
||||
"github.com/docker/compose/v2/pkg/api"
|
||||
@ -71,10 +69,6 @@ func (s *composeService) Build(ctx context.Context, project *types.Project, opti
|
||||
}, s.stdinfo(), "Building")
|
||||
}
|
||||
|
||||
const bakeSuggest = "Compose can now delegate builds to bake for better performance.\n To do so, set COMPOSE_BAKE=true."
|
||||
|
||||
var suggest sync.Once
|
||||
|
||||
//nolint:gocyclo
|
||||
func (s *composeService) build(ctx context.Context, project *types.Project, options api.BuildOptions, localImages map[string]api.ImageSummary) (map[string]string, error) {
|
||||
imageIDs := map[string]string{}
|
||||
@ -156,11 +150,6 @@ func (s *composeService) build(ctx context.Context, project *types.Project, opti
|
||||
w *xprogress.Printer
|
||||
)
|
||||
if buildkitEnabled {
|
||||
if hints.Enabled() && progress.Mode != progress.ModeQuiet && progress.Mode != progress.ModeJSON {
|
||||
suggest.Do(func() {
|
||||
fmt.Fprintln(s.dockerCli.Out(), bakeSuggest) //nolint:errcheck
|
||||
})
|
||||
}
|
||||
builderName := options.Builder
|
||||
if builderName == "" {
|
||||
builderName = os.Getenv("BUILDX_BUILDER")
|
||||
|
@ -51,12 +51,7 @@ 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
|
||||
b = "true"
|
||||
}
|
||||
bake, err := strconv.ParseBool(b)
|
||||
if err != nil {
|
||||
@ -72,6 +67,7 @@ func buildWithBake(dockerCli command.Cli) (bool, error) {
|
||||
}
|
||||
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{})
|
||||
|
@ -284,7 +284,7 @@ func TestBuildImageDependencies(t *testing.T) {
|
||||
|
||||
t.Run("BuildKit by dependency order", func(t *testing.T) {
|
||||
cli := NewCLI(t, WithEnv(
|
||||
"DOCKER_BUILDKIT=1",
|
||||
"DOCKER_BUILDKIT=1", "COMPOSE_BAKE=0",
|
||||
"COMPOSE_FILE=./fixtures/build-dependencies/classic.yaml",
|
||||
))
|
||||
doTest(t, cli, "build")
|
||||
@ -293,7 +293,7 @@ func TestBuildImageDependencies(t *testing.T) {
|
||||
|
||||
t.Run("BuildKit by additional contexts", func(t *testing.T) {
|
||||
cli := NewCLI(t, WithEnv(
|
||||
"DOCKER_BUILDKIT=1",
|
||||
"DOCKER_BUILDKIT=1", "COMPOSE_BAKE=0",
|
||||
"COMPOSE_FILE=./fixtures/build-dependencies/compose.yaml",
|
||||
))
|
||||
doTest(t, cli, "build")
|
||||
|
Loading…
x
Reference in New Issue
Block a user