mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-18 17:37:46 +08:00
build: warning on deprecated flags
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
36a37a624e
commit
25d2f73858
@ -546,7 +546,7 @@ func toSolveOpt(ctx context.Context, d driver.Driver, multiDriver bool, opt Opti
|
|||||||
so.FrontendAttrs["force-network-mode"] = opt.NetworkMode
|
so.FrontendAttrs["force-network-mode"] = opt.NetworkMode
|
||||||
case "", "default":
|
case "", "default":
|
||||||
default:
|
default:
|
||||||
return nil, nil, errors.Errorf("network mode %q not supported by buildkit", opt.NetworkMode)
|
return nil, nil, errors.Errorf("network mode %q not supported by buildkit. You can define a custom network for your builder using the network driver-opt in buildx create.", opt.NetworkMode)
|
||||||
}
|
}
|
||||||
|
|
||||||
// setup extrahosts
|
// setup extrahosts
|
||||||
|
@ -22,6 +22,7 @@ import (
|
|||||||
"github.com/moby/buildkit/session/auth/authprovider"
|
"github.com/moby/buildkit/session/auth/authprovider"
|
||||||
"github.com/moby/buildkit/util/appcontext"
|
"github.com/moby/buildkit/util/appcontext"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
)
|
)
|
||||||
@ -50,9 +51,6 @@ type buildOptions struct {
|
|||||||
target string
|
target string
|
||||||
ulimits *dockeropts.UlimitOpt
|
ulimits *dockeropts.UlimitOpt
|
||||||
commonOptions
|
commonOptions
|
||||||
|
|
||||||
// unimplemented
|
|
||||||
squash bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type commonOptions struct {
|
type commonOptions struct {
|
||||||
@ -70,9 +68,6 @@ type commonOptions struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runBuild(dockerCli command.Cli, in buildOptions) (err error) {
|
func runBuild(dockerCli command.Cli, in buildOptions) (err error) {
|
||||||
if in.squash {
|
|
||||||
return errors.Errorf("squash currently not implemented")
|
|
||||||
}
|
|
||||||
ctx := appcontext.Context()
|
ctx := appcontext.Context()
|
||||||
|
|
||||||
ctx, end, err := tracing.TraceCurrentCommand(ctx, "build")
|
ctx, end, err := tracing.TraceCurrentCommand(ctx, "build")
|
||||||
@ -268,6 +263,7 @@ func buildCmd(dockerCli command.Cli, rootOpts *rootOptions) *cobra.Command {
|
|||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
options.contextPath = args[0]
|
options.contextPath = args[0]
|
||||||
options.builder = rootOpts.builder
|
options.builder = rootOpts.builder
|
||||||
|
cmd.Flags().VisitAll(checkWarnedFlags)
|
||||||
return runBuild(dockerCli, options)
|
return runBuild(dockerCli, options)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -324,10 +320,6 @@ func buildCmd(dockerCli command.Cli, rootOpts *rootOptions) *cobra.Command {
|
|||||||
|
|
||||||
flags.Var(options.ulimits, "ulimit", "Ulimit options")
|
flags.Var(options.ulimits, "ulimit", "Ulimit options")
|
||||||
|
|
||||||
// not implemented
|
|
||||||
flags.BoolVar(&options.squash, "squash", false, "Squash newly built layers into a single new layer")
|
|
||||||
flags.MarkHidden("squash")
|
|
||||||
|
|
||||||
// hidden flags
|
// hidden flags
|
||||||
var ignore string
|
var ignore string
|
||||||
var ignoreSlice []string
|
var ignoreSlice []string
|
||||||
@ -336,15 +328,22 @@ func buildCmd(dockerCli command.Cli, rootOpts *rootOptions) *cobra.Command {
|
|||||||
|
|
||||||
flags.StringVar(&ignore, "cgroup-parent", "", "Optional parent cgroup for the container")
|
flags.StringVar(&ignore, "cgroup-parent", "", "Optional parent cgroup for the container")
|
||||||
flags.MarkHidden("cgroup-parent")
|
flags.MarkHidden("cgroup-parent")
|
||||||
|
//flags.SetAnnotation("cgroup-parent", "flag-warn", []string{"cgroup-parent is not implemented."})
|
||||||
|
|
||||||
flags.BoolVar(&ignoreBool, "compress", false, "Compress the build context using gzip")
|
flags.BoolVar(&ignoreBool, "compress", false, "Compress the build context using gzip")
|
||||||
flags.MarkHidden("compress")
|
flags.MarkHidden("compress")
|
||||||
|
|
||||||
flags.StringVar(&ignore, "isolation", "", "Container isolation technology")
|
flags.StringVar(&ignore, "isolation", "", "Container isolation technology")
|
||||||
flags.MarkHidden("isolation")
|
flags.MarkHidden("isolation")
|
||||||
|
flags.SetAnnotation("isolation", "flag-warn", []string{"isolation flag is deprecated with BuildKit."})
|
||||||
|
|
||||||
flags.StringSliceVar(&ignoreSlice, "security-opt", []string{}, "Security options")
|
flags.StringSliceVar(&ignoreSlice, "security-opt", []string{}, "Security options")
|
||||||
flags.MarkHidden("security-opt")
|
flags.MarkHidden("security-opt")
|
||||||
|
flags.SetAnnotation("security-opt", "flag-warn", []string{`security-opt flag is deprecated. "RUN --security=insecure" should be used with BuildKit.`})
|
||||||
|
|
||||||
|
flags.BoolVar(&ignoreBool, "squash", false, "Squash newly built layers into a single new layer")
|
||||||
|
flags.MarkHidden("squash")
|
||||||
|
flags.SetAnnotation("squash", "flag-warn", []string{"experimental flag squash is removed with BuildKit. You should squash inside build using a multi-stage Dockerfile for efficiency."})
|
||||||
|
|
||||||
flags.StringVarP(&ignore, "memory", "m", "", "Memory limit")
|
flags.StringVarP(&ignore, "memory", "m", "", "Memory limit")
|
||||||
flags.MarkHidden("memory")
|
flags.MarkHidden("memory")
|
||||||
@ -384,6 +383,19 @@ func commonBuildFlags(options *commonOptions, flags *pflag.FlagSet) {
|
|||||||
flags.StringVar(&options.metadataFile, "metadata-file", "", "Write build result metadata to the file")
|
flags.StringVar(&options.metadataFile, "metadata-file", "", "Write build result metadata to the file")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func checkWarnedFlags(f *pflag.Flag) {
|
||||||
|
if !f.Changed {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for t, m := range f.Annotations {
|
||||||
|
switch t {
|
||||||
|
case "flag-warn":
|
||||||
|
logrus.Warn(m[0])
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func listToMap(values []string, defaultEnv bool) map[string]string {
|
func listToMap(values []string, defaultEnv bool) map[string]string {
|
||||||
result := make(map[string]string, len(values))
|
result := make(map[string]string, len(values))
|
||||||
for _, value := range values {
|
for _, value := range values {
|
||||||
|
@ -131,11 +131,6 @@ Passes additional driver-specific options. Details for each driver:
|
|||||||
- `image=IMAGE` - Sets the container image to be used for running buildkit.
|
- `image=IMAGE` - Sets the container image to be used for running buildkit.
|
||||||
- `network=NETMODE` - Sets the network mode for running the buildkit container.
|
- `network=NETMODE` - Sets the network mode for running the buildkit container.
|
||||||
- `cgroup-parent=CGROUP` - Sets the cgroup parent of the buildkit container if docker is using the "cgroupfs" driver. Defaults to `/docker/buildx`.
|
- `cgroup-parent=CGROUP` - Sets the cgroup parent of the buildkit container if docker is using the "cgroupfs" driver. Defaults to `/docker/buildx`.
|
||||||
- Example:
|
|
||||||
|
|
||||||
```console
|
|
||||||
--driver docker-container --driver-opt image=moby/buildkit:master,network=host
|
|
||||||
```
|
|
||||||
- `kubernetes`
|
- `kubernetes`
|
||||||
- `image=IMAGE` - Sets the container image to be used for running buildkit.
|
- `image=IMAGE` - Sets the container image to be used for running buildkit.
|
||||||
- `namespace=NS` - Sets the Kubernetes namespace. Defaults to the current namespace.
|
- `namespace=NS` - Sets the Kubernetes namespace. Defaults to the current namespace.
|
||||||
@ -150,6 +145,30 @@ Passes additional driver-specific options. Details for each driver:
|
|||||||
- `qemu.install=(true|false)` - Install QEMU emulation for multi platforms support.
|
- `qemu.install=(true|false)` - Install QEMU emulation for multi platforms support.
|
||||||
- `qemu.image=IMAGE` - Sets the QEMU emulation image. Defaults to `tonistiigi/binfmt:latest`
|
- `qemu.image=IMAGE` - Sets the QEMU emulation image. Defaults to `tonistiigi/binfmt:latest`
|
||||||
|
|
||||||
|
**Examples**
|
||||||
|
|
||||||
|
#### Use a custom network
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ docker network create foonet
|
||||||
|
$ docker buildx create --name builder --driver docker-container --driver-opt network=foonet --use
|
||||||
|
$ docker buildx inspect --bootstrap
|
||||||
|
$ docker inspect buildx_buildkit_builder0 --format={{.NetworkSettings.Networks}}
|
||||||
|
map[foonet:0xc00018c0c0]
|
||||||
|
```
|
||||||
|
|
||||||
|
#### OpenTelemetry support
|
||||||
|
|
||||||
|
To capture the trace to [Jaeger](https://github.com/jaegertracing/jaeger), set
|
||||||
|
`JAEGER_TRACE` environment variable to the collection address using the `driver-opt`:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ docker run -d --name jaeger -p 6831:6831/udp -p 16686:16686 jaegertracing/all-in-one
|
||||||
|
$ docker buildx create --name builder --driver docker-container --driver-opt network=host --driver-opt env.JAEGER_TRACE=localhost:6831 --use
|
||||||
|
$ docker buildx inspect --bootstrap
|
||||||
|
# buildx command should be traced at http://127.0.0.1:16686/
|
||||||
|
```
|
||||||
|
|
||||||
### <a name="leave"></a> Remove a node from a builder (--leave)
|
### <a name="leave"></a> Remove a node from a builder (--leave)
|
||||||
|
|
||||||
The `--leave` flag changes the action of the command to remove a node from a
|
The `--leave` flag changes the action of the command to remove a node from a
|
||||||
|
Loading…
x
Reference in New Issue
Block a user