From 5c58685968e3fb0e2d3e40b90b9ef821323896f7 Mon Sep 17 00:00:00 2001 From: Jacob Gillespie Date: Mon, 26 Aug 2024 19:08:29 +0200 Subject: [PATCH] Add `shm-size` support to `depot bake` --- pkg/buildx/bake/bake.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pkg/buildx/bake/bake.go b/pkg/buildx/bake/bake.go index f938a852..6fa090f3 100644 --- a/pkg/buildx/bake/bake.go +++ b/pkg/buildx/bake/bake.go @@ -19,6 +19,7 @@ import ( "github.com/docker/buildx/util/buildflags" "github.com/docker/buildx/util/platformutil" "github.com/docker/cli/cli/config" + "github.com/docker/cli/opts" "github.com/docker/docker/builder/remotecontext/urlutil" hcl "github.com/hashicorp/hcl/v2" "github.com/moby/buildkit/client/llb" @@ -624,6 +625,7 @@ type Target struct { NoCache *bool `json:"no-cache,omitempty" hcl:"no-cache,optional" cty:"no-cache"` NetworkMode *string `json:"-" hcl:"-" cty:"-"` NoCacheFilter []string `json:"no-cache-filter,omitempty" hcl:"no-cache-filter,optional" cty:"no-cache-filter"` + ShmSize *string `json:"shm-size,omitempty" hcl:"shm-size,optional"` // IMPORTANT: if you add more fields here, do not forget to update newOverrides and docs/bake-reference.md. // linked is a private field to mark a target used as a linked one @@ -732,6 +734,9 @@ func (t *Target) Merge(t2 *Target) { if t2.NoCacheFilter != nil { // merge t.NoCacheFilter = append(t.NoCacheFilter, t2.NoCacheFilter...) } + if t2.ShmSize != nil { // no merge + t.ShmSize = t2.ShmSize + } if t2.ProjectID != "" { t.ProjectID = t2.ProjectID } @@ -797,6 +802,8 @@ func (t *Target) AddOverrides(overrides map[string]Override) error { t.NoCache = &noCache case "no-cache-filter": t.NoCacheFilter = o.ArrValue + case "shm-size": + t.ShmSize = &value case "pull": pull, err := strconv.ParseBool(value) if err != nil { @@ -1126,6 +1133,12 @@ func toBuildOpt(t *Target, inp *Input) (*build.Options, error) { if t.NetworkMode != nil { networkMode = *t.NetworkMode } + shmSize := new(opts.MemBytes) + if t.ShmSize != nil { + if err := shmSize.Set(*t.ShmSize); err != nil { + return nil, errors.Errorf("invalid value %s for membytes key shm-size", *t.ShmSize) + } + } bi := build.Inputs{ ContextPath: contextPath, @@ -1161,6 +1174,7 @@ func toBuildOpt(t *Target, inp *Input) (*build.Options, error) { Pull: pull, NetworkMode: networkMode, Linked: t.linked, + ShmSize: *shmSize, } platforms, err := platformutil.Parse(t.Platforms)