mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
api/server/router/build: BuilderVersion: allow buildkit on Windows
Commit 7b153b9e28 changed the daemon to
advertise the recommended builder to use to V2 (BuildKit) for Linux
daemons, and V1 (Legacy Builder) for Windows daemons. For Linux daemons
we allowed the default to be overridden through the "features" field
in the daemon config (daemon.json), but for Windows we hard-coded it
to be V1, and no option to override.
With work in progress on implementing support for Windows in BuildKit,
we should remove this hardcoded assumption, and allow the default to
be overridden to advertise that BuildKit is supported.
Note that BuildKit on Windows is still very much a "work in progress",
and enabling it in the daemon may not even work, so users should not
try to enable this feature; a warning-level log is added to make it
visible that the feature is enabled.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -4,7 +4,7 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"github.com/docker/docker/api/server/router"
|
"github.com/docker/docker/api/server/router"
|
||||||
build2 "github.com/docker/docker/api/types/build"
|
"github.com/docker/docker/api/types/build"
|
||||||
)
|
)
|
||||||
|
|
||||||
// buildRouter is a router to talk with the build controller
|
// buildRouter is a router to talk with the build controller
|
||||||
@@ -46,15 +46,22 @@ func (br *buildRouter) initRoutes() {
|
|||||||
//
|
//
|
||||||
// This value is only a recommendation as advertised by the daemon, and it is
|
// This value is only a recommendation as advertised by the daemon, and it is
|
||||||
// up to the client to choose which builder to use.
|
// up to the client to choose which builder to use.
|
||||||
func BuilderVersion(features map[string]bool) build2.BuilderVersion {
|
func BuilderVersion(features map[string]bool) build.BuilderVersion {
|
||||||
// TODO(thaJeztah) move the default to daemon/config
|
// TODO(thaJeztah) move the default to daemon/config
|
||||||
|
bv := build.BuilderBuildKit
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
return build2.BuilderV1
|
// BuildKit is not yet the default on Windows.
|
||||||
|
bv = build.BuilderV1
|
||||||
}
|
}
|
||||||
|
|
||||||
bv := build2.BuilderBuildKit
|
// Allow the features field in the daemon config to override the
|
||||||
if v, ok := features["buildkit"]; ok && !v {
|
// default builder to advertise.
|
||||||
bv = build2.BuilderV1
|
if enable, ok := features["buildkit"]; ok {
|
||||||
|
if enable {
|
||||||
|
bv = build.BuilderBuildKit
|
||||||
|
} else {
|
||||||
|
bv = build.BuilderV1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return bv
|
return bv
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -294,6 +294,12 @@ func (cli *daemonCLI) start(ctx context.Context) (err error) {
|
|||||||
return fmt.Errorf("error initializing buildkit: %w", err)
|
return fmt.Errorf("error initializing buildkit: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
if enabled, ok := d.Features()["buildkit"]; ok && enabled {
|
||||||
|
log.G(ctx).Warn("Buildkit feature is enabled in the daemon.json configuration file. Support for BuildKit on Windows is experimental, and enabling this feature may not work. Use at your own risk!")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
routers := buildRouters(routerOptions{
|
routers := buildRouters(routerOptions{
|
||||||
features: d.Features,
|
features: d.Features,
|
||||||
daemon: d,
|
daemon: d,
|
||||||
|
|||||||
Reference in New Issue
Block a user