mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-18 17:37:46 +08:00
Merge pull request #814 from crazy-max/cgroup-parent
build: add cgroup-parent support
This commit is contained in:
commit
5e25191cb6
@ -50,27 +50,25 @@ var (
|
|||||||
|
|
||||||
type Options struct {
|
type Options struct {
|
||||||
Inputs Inputs
|
Inputs Inputs
|
||||||
Tags []string
|
|
||||||
Labels map[string]string
|
|
||||||
BuildArgs map[string]string
|
|
||||||
Pull bool
|
|
||||||
ImageIDFile string
|
|
||||||
ExtraHosts []string
|
|
||||||
NetworkMode string
|
|
||||||
ShmSize opts.MemBytes
|
|
||||||
Ulimits *opts.UlimitOpt
|
|
||||||
|
|
||||||
NoCache bool
|
|
||||||
Target string
|
|
||||||
Platforms []specs.Platform
|
|
||||||
Exports []client.ExportEntry
|
|
||||||
Session []session.Attachable
|
|
||||||
|
|
||||||
CacheFrom []client.CacheOptionsEntry
|
|
||||||
CacheTo []client.CacheOptionsEntry
|
|
||||||
|
|
||||||
Allow []entitlements.Entitlement
|
Allow []entitlements.Entitlement
|
||||||
// DockerTarget
|
BuildArgs map[string]string
|
||||||
|
CacheFrom []client.CacheOptionsEntry
|
||||||
|
CacheTo []client.CacheOptionsEntry
|
||||||
|
CgroupParent string
|
||||||
|
Exports []client.ExportEntry
|
||||||
|
ExtraHosts []string
|
||||||
|
ImageIDFile string
|
||||||
|
Labels map[string]string
|
||||||
|
NetworkMode string
|
||||||
|
NoCache bool
|
||||||
|
Platforms []specs.Platform
|
||||||
|
Pull bool
|
||||||
|
Session []session.Attachable
|
||||||
|
ShmSize opts.MemBytes
|
||||||
|
Tags []string
|
||||||
|
Target string
|
||||||
|
Ulimits *opts.UlimitOpt
|
||||||
}
|
}
|
||||||
|
|
||||||
type Inputs struct {
|
type Inputs struct {
|
||||||
@ -402,6 +400,10 @@ func toSolveOpt(ctx context.Context, d driver.Driver, multiDriver bool, opt Opti
|
|||||||
AllowedEntitlements: opt.Allow,
|
AllowedEntitlements: opt.Allow,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if opt.CgroupParent != "" {
|
||||||
|
so.FrontendAttrs["cgroup-parent"] = opt.CgroupParent
|
||||||
|
}
|
||||||
|
|
||||||
if v, ok := opt.BuildArgs["BUILDKIT_MULTI_PLATFORM"]; ok {
|
if v, ok := opt.BuildArgs["BUILDKIT_MULTI_PLATFORM"]; ok {
|
||||||
if v, _ := strconv.ParseBool(v); v {
|
if v, _ := strconv.ParseBool(v); v {
|
||||||
so.FrontendAttrs["multi-platform"] = "true"
|
so.FrontendAttrs["multi-platform"] = "true"
|
||||||
|
@ -37,6 +37,7 @@ type buildOptions struct {
|
|||||||
buildArgs []string
|
buildArgs []string
|
||||||
cacheFrom []string
|
cacheFrom []string
|
||||||
cacheTo []string
|
cacheTo []string
|
||||||
|
cgroupParent string
|
||||||
extraHosts []string
|
extraHosts []string
|
||||||
imageIDFile string
|
imageIDFile string
|
||||||
labels []string
|
labels []string
|
||||||
@ -287,6 +288,9 @@ func buildCmd(dockerCli command.Cli, rootOpts *rootOptions) *cobra.Command {
|
|||||||
|
|
||||||
flags.StringArrayVar(&options.cacheTo, "cache-to", []string{}, "Cache export destinations (e.g., `user/app:cache`, `type=local,dest=path/to/dir`)")
|
flags.StringArrayVar(&options.cacheTo, "cache-to", []string{}, "Cache export destinations (e.g., `user/app:cache`, `type=local,dest=path/to/dir`)")
|
||||||
|
|
||||||
|
flags.StringVar(&options.cgroupParent, "cgroup-parent", "", "Optional parent cgroup for the container")
|
||||||
|
flags.SetAnnotation("cgroup-parent", "docs.external.url", []string{"https://docs.docker.com/engine/reference/commandline/build/#use-a-custom-parent-cgroup---cgroup-parent"})
|
||||||
|
|
||||||
flags.StringVarP(&options.dockerfileName, "file", "f", "", "Name of the Dockerfile (default: `PATH/Dockerfile`)")
|
flags.StringVarP(&options.dockerfileName, "file", "f", "", "Name of the Dockerfile (default: `PATH/Dockerfile`)")
|
||||||
flags.SetAnnotation("file", "docs.external.url", []string{"https://docs.docker.com/engine/reference/commandline/build/#specify-a-dockerfile--f"})
|
flags.SetAnnotation("file", "docs.external.url", []string{"https://docs.docker.com/engine/reference/commandline/build/#specify-a-dockerfile--f"})
|
||||||
|
|
||||||
@ -326,10 +330,6 @@ func buildCmd(dockerCli command.Cli, rootOpts *rootOptions) *cobra.Command {
|
|||||||
var ignoreBool bool
|
var ignoreBool bool
|
||||||
var ignoreInt int64
|
var ignoreInt int64
|
||||||
|
|
||||||
flags.StringVar(&ignore, "cgroup-parent", "", "Optional parent cgroup for the container")
|
|
||||||
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")
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ Start a build
|
|||||||
| `--builder string` | Override the configured builder instance |
|
| `--builder string` | Override the configured builder instance |
|
||||||
| [`--cache-from stringArray`](#cache-from) | External cache sources (e.g., `user/app:cache`, `type=local,src=path/to/dir`) |
|
| [`--cache-from stringArray`](#cache-from) | External cache sources (e.g., `user/app:cache`, `type=local,src=path/to/dir`) |
|
||||||
| [`--cache-to stringArray`](#cache-to) | Cache export destinations (e.g., `user/app:cache`, `type=local,dest=path/to/dir`) |
|
| [`--cache-to stringArray`](#cache-to) | Cache export destinations (e.g., `user/app:cache`, `type=local,dest=path/to/dir`) |
|
||||||
|
| [`--cgroup-parent string`](https://docs.docker.com/engine/reference/commandline/build/#use-a-custom-parent-cgroup---cgroup-parent) | Optional parent cgroup for the container |
|
||||||
| [`-f`](https://docs.docker.com/engine/reference/commandline/build/#specify-a-dockerfile--f), [`--file string`](https://docs.docker.com/engine/reference/commandline/build/#specify-a-dockerfile--f) | Name of the Dockerfile (default: `PATH/Dockerfile`) |
|
| [`-f`](https://docs.docker.com/engine/reference/commandline/build/#specify-a-dockerfile--f), [`--file string`](https://docs.docker.com/engine/reference/commandline/build/#specify-a-dockerfile--f) | Name of the Dockerfile (default: `PATH/Dockerfile`) |
|
||||||
| `--iidfile string` | Write the image ID to the file |
|
| `--iidfile string` | Write the image ID to the file |
|
||||||
| `--label stringArray` | Set metadata for an image |
|
| `--label stringArray` | Set metadata for an image |
|
||||||
|
Loading…
x
Reference in New Issue
Block a user