Skip to content

Commit

Permalink
Merge pull request #2719 from jsternberg/bake-remote-size
Browse files Browse the repository at this point in the history
bake: raise maximum size limit and fix size check
  • Loading branch information
tonistiigi authored Oct 4, 2024
2 parents 4815316 + 9fc6f39 commit 4507a49
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions bake/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ import (
controllerapi "github.com/docker/buildx/controller/pb"
"github.com/docker/buildx/driver"
"github.com/docker/buildx/util/progress"
"github.com/docker/go-units"
"github.com/moby/buildkit/client"
"github.com/moby/buildkit/client/llb"
"github.com/moby/buildkit/frontend/dockerui"
gwclient "github.com/moby/buildkit/frontend/gateway/client"
"github.com/moby/buildkit/session"
"github.com/pkg/errors"
"google.golang.org/protobuf/proto"
)

const maxBakeDefinitionSize = 2 * 1024 * 1024 // 2 MB

type Input struct {
State *llb.State
URL string
Expand Down Expand Up @@ -178,9 +180,9 @@ func filesFromURLRef(ctx context.Context, c gwclient.Client, ref gwclient.Refere
name := inp.URL
inp.URL = ""

if len(dt) > proto.Size(stat) {
if proto.Size(stat) > 1024*512 {
return nil, errors.Errorf("non-archive definition URL bigger than maximum allowed size")
if int64(len(dt)) > stat.Size {
if stat.Size > maxBakeDefinitionSize {
return nil, errors.Errorf("non-archive definition URL bigger than maximum allowed size (%s)", units.HumanSize(maxBakeDefinitionSize))
}

dt, err = ref.ReadFile(ctx, gwclient.ReadRequest{
Expand Down

0 comments on commit 4507a49

Please sign in to comment.