Browse Source

vendor: update buildkit to cce2080ddb

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Tonis Tiigi 7 years ago
parent
commit
360d2f2ce7
38 changed files with 1538 additions and 481 deletions
  1. 1 1
      vendor.conf
  2. 136 78
      vendor/github.com/moby/buildkit/api/services/control/control.pb.go
  3. 1 0
      vendor/github.com/moby/buildkit/api/services/control/control.proto
  4. 5 5
      vendor/github.com/moby/buildkit/cache/manager.go
  5. 1 5
      vendor/github.com/moby/buildkit/client/client.go
  6. 55 33
      vendor/github.com/moby/buildkit/client/llb/exec.go
  7. 10 5
      vendor/github.com/moby/buildkit/client/llb/imagemetaresolver/resolver.go
  8. 57 5
      vendor/github.com/moby/buildkit/client/llb/marshal.go
  9. 22 4
      vendor/github.com/moby/buildkit/client/llb/meta.go
  10. 2 1
      vendor/github.com/moby/buildkit/client/llb/resolver.go
  11. 30 35
      vendor/github.com/moby/buildkit/client/llb/source.go
  12. 126 55
      vendor/github.com/moby/buildkit/client/llb/state.go
  13. 22 4
      vendor/github.com/moby/buildkit/client/workers.go
  14. 23 3
      vendor/github.com/moby/buildkit/control/control.go
  15. 25 9
      vendor/github.com/moby/buildkit/frontend/dockerfile/builder/build.go
  16. 85 17
      vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert.go
  17. 2 2
      vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert_norunmount.go
  18. 16 4
      vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert_runmount.go
  19. 7 8
      vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/image.go
  20. 1 2
      vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands.go
  21. 27 7
      vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands_runmount.go
  22. 2 2
      vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/parse.go
  23. 2 1
      vendor/github.com/moby/buildkit/frontend/frontend.go
  24. 2 1
      vendor/github.com/moby/buildkit/frontend/gateway/client/client.go
  25. 25 7
      vendor/github.com/moby/buildkit/frontend/gateway/gateway.go
  26. 102 46
      vendor/github.com/moby/buildkit/frontend/gateway/pb/gateway.pb.go
  27. 1 0
      vendor/github.com/moby/buildkit/frontend/gateway/pb/gateway.proto
  28. 5 3
      vendor/github.com/moby/buildkit/solver/llbsolver/bridge.go
  29. 71 23
      vendor/github.com/moby/buildkit/solver/llbsolver/ops/exec.go
  30. 12 10
      vendor/github.com/moby/buildkit/solver/llbsolver/ops/source.go
  31. 12 2
      vendor/github.com/moby/buildkit/solver/llbsolver/solver.go
  32. 42 5
      vendor/github.com/moby/buildkit/solver/llbsolver/vertex.go
  33. 543 73
      vendor/github.com/moby/buildkit/solver/pb/ops.pb.go
  34. 32 5
      vendor/github.com/moby/buildkit/solver/pb/ops.proto
  35. 12 1
      vendor/github.com/moby/buildkit/source/identifier.go
  36. 17 15
      vendor/github.com/moby/buildkit/util/imageutil/config.go
  37. 1 1
      vendor/github.com/moby/buildkit/vendor.conf
  38. 3 3
      vendor/github.com/moby/buildkit/worker/worker.go

+ 1 - 1
vendor.conf

@@ -26,7 +26,7 @@ github.com/imdario/mergo v0.3.5
 golang.org/x/sync fd80eb99c8f653c847d294a001bdf2a3a6f768f5
 
 # buildkit
-github.com/moby/buildkit dbf67a691ce77023a0a5ce9b005298631f8bbb4e
+github.com/moby/buildkit cce2080ddbe4698912f2290892b247c83627efa8
 github.com/tonistiigi/fsutil 8abad97ee3969cdf5e9c367f46adba2c212b3ddb
 github.com/grpc-ecosystem/grpc-opentracing 8e809c8a86450a29b90dcc9efbf062d0fe6d9746
 github.com/opentracing/opentracing-go 1361b9cd60be79c4c3a7fa9841b3c132e40066a7

+ 136 - 78
vendor/github.com/moby/buildkit/api/services/control/control.pb.go

@@ -542,8 +542,9 @@ func (m *ListWorkersResponse) GetRecord() []*WorkerRecord {
 }
 
 type WorkerRecord struct {
-	ID     string            `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"`
-	Labels map[string]string `protobuf:"bytes,2,rep,name=Labels" json:"Labels,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
+	ID        string            `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"`
+	Labels    map[string]string `protobuf:"bytes,2,rep,name=Labels" json:"Labels,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
+	Platforms []pb.Platform     `protobuf:"bytes,3,rep,name=platforms" json:"platforms"`
 }
 
 func (m *WorkerRecord) Reset()                    { *m = WorkerRecord{} }
@@ -565,6 +566,13 @@ func (m *WorkerRecord) GetLabels() map[string]string {
 	return nil
 }
 
+func (m *WorkerRecord) GetPlatforms() []pb.Platform {
+	if m != nil {
+		return m.Platforms
+	}
+	return nil
+}
+
 func init() {
 	proto.RegisterType((*PruneRequest)(nil), "moby.buildkit.v1.PruneRequest")
 	proto.RegisterType((*DiskUsageRequest)(nil), "moby.buildkit.v1.DiskUsageRequest")
@@ -1650,6 +1658,18 @@ func (m *WorkerRecord) MarshalTo(dAtA []byte) (int, error) {
 			i += copy(dAtA[i:], v)
 		}
 	}
+	if len(m.Platforms) > 0 {
+		for _, msg := range m.Platforms {
+			dAtA[i] = 0x1a
+			i++
+			i = encodeVarintControl(dAtA, i, uint64(msg.Size()))
+			n, err := msg.MarshalTo(dAtA[i:])
+			if err != nil {
+				return 0, err
+			}
+			i += n
+		}
+	}
 	return i, nil
 }
 
@@ -1979,6 +1999,12 @@ func (m *WorkerRecord) Size() (n int) {
 			n += mapEntrySize + 1 + sovControl(uint64(mapEntrySize))
 		}
 	}
+	if len(m.Platforms) > 0 {
+		for _, e := range m.Platforms {
+			l = e.Size()
+			n += 1 + l + sovControl(uint64(l))
+		}
+	}
 	return n
 }
 
@@ -4663,6 +4689,37 @@ func (m *WorkerRecord) Unmarshal(dAtA []byte) error {
 			}
 			m.Labels[mapkey] = mapvalue
 			iNdEx = postIndex
+		case 3:
+			if wireType != 2 {
+				return fmt.Errorf("proto: wrong wireType = %d for field Platforms", wireType)
+			}
+			var msglen int
+			for shift := uint(0); ; shift += 7 {
+				if shift >= 64 {
+					return ErrIntOverflowControl
+				}
+				if iNdEx >= l {
+					return io.ErrUnexpectedEOF
+				}
+				b := dAtA[iNdEx]
+				iNdEx++
+				msglen |= (int(b) & 0x7F) << shift
+				if b < 0x80 {
+					break
+				}
+			}
+			if msglen < 0 {
+				return ErrInvalidLengthControl
+			}
+			postIndex := iNdEx + msglen
+			if postIndex > l {
+				return io.ErrUnexpectedEOF
+			}
+			m.Platforms = append(m.Platforms, pb.Platform{})
+			if err := m.Platforms[len(m.Platforms)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+				return err
+			}
+			iNdEx = postIndex
 		default:
 			iNdEx = preIndex
 			skippy, err := skipControl(dAtA[iNdEx:])
@@ -4792,80 +4849,81 @@ var (
 func init() { proto.RegisterFile("control.proto", fileDescriptorControl) }
 
 var fileDescriptorControl = []byte{
-	// 1192 bytes of a gzipped FileDescriptorProto
-	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0xcd, 0x6e, 0x23, 0x45,
-	0x10, 0x66, 0x6c, 0xc7, 0x3f, 0x65, 0x27, 0x0a, 0x0d, 0xac, 0x46, 0x03, 0x24, 0x66, 0x00, 0xc9,
-	0x8a, 0x76, 0xc7, 0xd9, 0xc0, 0x22, 0xc8, 0x61, 0xb5, 0xeb, 0x78, 0x11, 0x89, 0x12, 0xb1, 0x74,
-	0x36, 0xac, 0xc4, 0x6d, 0x6c, 0x77, 0xbc, 0xa3, 0xd8, 0xd3, 0xa6, 0xbb, 0x27, 0xda, 0xf0, 0x14,
-	0x1c, 0xb8, 0xf2, 0x14, 0x1c, 0x38, 0x73, 0x40, 0xda, 0x23, 0x67, 0x0e, 0x59, 0x94, 0x3b, 0x3c,
-	0x03, 0xea, 0x9f, 0xb1, 0xdb, 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 0x7b, 0xd0, 0x81, 0x56, 0xea, 0x31, 0x3e, 0x01, 0xb9, 0x5f, 0x41, 0xcd, 0x20,
+	0x5a, 0xa4, 0xcb, 0x6f, 0xfe, 0x5b, 0x84, 0xca, 0xb6, 0xfa, 0x1b, 0x80, 0x9e, 0x81, 0x3d, 0x5e,
+	0x9a, 0x91, 0x97, 0xf7, 0x7c, 0x76, 0xfb, 0x76, 0x3f, 0xbe, 0x12, 0xa3, 0x63, 0xfd, 0x0d, 0x2c,
+	0xc9, 0x35, 0x1e, 0xcd, 0x09, 0xb2, 0xb9, 0xdf, 0xbb, 0x57, 0xaf, 0xe3, 0x1b, 0x96, 0x60, 0x92,
+	0xf3, 0x70, 0x1e, 0x93, 0xb9, 0x38, 0xb9, 0xeb, 0xd7, 0x0c, 0x52, 0xb4, 0x0f, 0x65, 0xdd, 0x9a,
+	0xe6, 0x41, 0xcd, 0xa9, 0xe7, 0x36, 0x2e, 0x07, 0x28, 0xb2, 0x0d, 0x0b, 0xed, 0x8f, 0xb7, 0xc2,
+	0x79, 0xae, 0x99, 0x25, 0xed, 0x5e, 0xf3, 0xbc, 0x69, 0x6d, 0x58, 0xe8, 0x07, 0xa8, 0x19, 0x45,
+	0x8b, 0x3e, 0xc9, 0x9b, 0xe4, 0xbf, 0x00, 0xf7, 0xd3, 0x6b, 0x50, 0xca, 0xd9, 0x76, 0xfd, 0xd5,
+	0xc5, 0x9a, 0xf5, 0xd7, 0xc5, 0x9a, 0xf5, 0xcf, 0xc5, 0x9a, 0xd5, 0x2d, 0xcb, 0x6f, 0xf8, 0xb3,
+	0xff, 0x03, 0x00, 0x00, 0xff, 0xff, 0x86, 0xd4, 0x0f, 0xa1, 0x0a, 0x0e, 0x00, 0x00,
 }

+ 1 - 0
vendor/github.com/moby/buildkit/api/services/control/control.proto

@@ -118,4 +118,5 @@ message ListWorkersResponse {
 message WorkerRecord {
 	string ID = 1;
 	map<string, string> Labels = 2;
+	repeated pb.Platform platforms = 3 [(gogoproto.nullable) = false];
 }

+ 5 - 5
vendor/github.com/moby/buildkit/cache/manager.go

@@ -17,7 +17,7 @@ import (
 )
 
 var (
-	errLocked   = errors.New("locked")
+	ErrLocked   = errors.New("locked")
 	errNotFound = errors.New("not found")
 	errInvalid  = errors.New("invalid")
 )
@@ -122,7 +122,7 @@ func (cm *cacheManager) get(ctx context.Context, id string, fromSnapshotter bool
 
 	if rec.mutable {
 		if len(rec.refs) != 0 {
-			return nil, errors.Wrapf(errLocked, "%s is locked", id)
+			return nil, errors.Wrapf(ErrLocked, "%s is locked", id)
 		}
 		if rec.equalImmutable != nil {
 			return rec.equalImmutable.ref(), nil
@@ -279,12 +279,12 @@ func (cm *cacheManager) GetMutable(ctx context.Context, id string) (MutableRef,
 	}
 
 	if len(rec.refs) != 0 {
-		return nil, errors.Wrapf(errLocked, "%s is locked", id)
+		return nil, errors.Wrapf(ErrLocked, "%s is locked", id)
 	}
 
 	if rec.equalImmutable != nil {
 		if len(rec.equalImmutable.refs) != 0 {
-			return nil, errors.Wrapf(errLocked, "%s is locked", id)
+			return nil, errors.Wrapf(ErrLocked, "%s is locked", id)
 		}
 		delete(cm.records, rec.equalImmutable.ID())
 		if err := rec.equalImmutable.remove(ctx, false); err != nil {
@@ -513,7 +513,7 @@ func (cm *cacheManager) DiskUsage(ctx context.Context, opt client.DiskUsageInfo)
 }
 
 func IsLocked(err error) bool {
-	return errors.Cause(err) == errLocked
+	return errors.Cause(err) == ErrLocked
 }
 
 func IsNotFound(err error) bool {

+ 1 - 5
vendor/github.com/moby/buildkit/client/client.go

@@ -5,7 +5,6 @@ import (
 	"crypto/tls"
 	"crypto/x509"
 	"io/ioutil"
-	"time"
 
 	"github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc"
 	controlapi "github.com/moby/buildkit/api/services/control"
@@ -23,7 +22,7 @@ type Client struct {
 type ClientOpt interface{}
 
 // New returns a new buildkit client. Address can be empty for the system-default address.
-func New(address string, opts ...ClientOpt) (*Client, error) {
+func New(ctx context.Context, address string, opts ...ClientOpt) (*Client, error) {
 	gopts := []grpc.DialOption{
 		grpc.WithDialer(dialer),
 		grpc.FailOnNonTempDialError(true),
@@ -54,9 +53,6 @@ func New(address string, opts ...ClientOpt) (*Client, error) {
 		address = appdefaults.Address
 	}
 
-	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
-	defer cancel()
-
 	conn, err := grpc.DialContext(ctx, address, gopts...)
 	if err != nil {
 		return nil, errors.Wrapf(err, "failed to dial %q . make sure buildkitd is running", address)

+ 55 - 33
vendor/github.com/moby/buildkit/client/llb/exec.go

@@ -17,8 +17,8 @@ type Meta struct {
 	ProxyEnv *ProxyEnv
 }
 
-func NewExecOp(root Output, meta Meta, readOnly bool, md OpMetadata) *ExecOp {
-	e := &ExecOp{meta: meta, cachedOpMetadata: md}
+func NewExecOp(root Output, meta Meta, readOnly bool, c Constraints) *ExecOp {
+	e := &ExecOp{meta: meta, constraints: c}
 	rootMount := &mount{
 		target:   pb.RootMount,
 		source:   root,
@@ -28,32 +28,35 @@ func NewExecOp(root Output, meta Meta, readOnly bool, md OpMetadata) *ExecOp {
 	if readOnly {
 		e.root = root
 	} else {
-		e.root = &output{vertex: e, getIndex: e.getMountIndexFn(rootMount)}
+		o := &output{vertex: e, getIndex: e.getMountIndexFn(rootMount)}
+		if p := c.Platform; p != nil {
+			o.platform = p
+		}
+		e.root = o
 	}
 	rootMount.output = e.root
-
 	return e
 }
 
 type mount struct {
-	target   string
-	readonly bool
-	source   Output
-	output   Output
-	selector string
-	cacheID  string
-	tmpfs    bool
+	target       string
+	readonly     bool
+	source       Output
+	output       Output
+	selector     string
+	cacheID      string
+	tmpfs        bool
+	cacheSharing CacheMountSharingMode
 	// hasOutput bool
 }
 
 type ExecOp struct {
-	root             Output
-	mounts           []*mount
-	meta             Meta
-	cachedPBDigest   digest.Digest
-	cachedPB         []byte
-	cachedOpMetadata OpMetadata
-	isValidated      bool
+	MarshalCache
+	root        Output
+	mounts      []*mount
+	meta        Meta
+	constraints Constraints
+	isValidated bool
 }
 
 func (e *ExecOp) AddMount(target string, source Output, opt ...MountOption) Output {
@@ -70,9 +73,13 @@ func (e *ExecOp) AddMount(target string, source Output, opt ...MountOption) Outp
 	} else if m.tmpfs {
 		m.output = &output{vertex: e, err: errors.Errorf("tmpfs mount for %s can't be used as a parent", target)}
 	} else {
-		m.output = &output{vertex: e, getIndex: e.getMountIndexFn(m)}
+		o := &output{vertex: e, getIndex: e.getMountIndexFn(m)}
+		if p := e.constraints.Platform; p != nil {
+			o.platform = p
+		}
+		m.output = o
 	}
-	e.cachedPB = nil
+	e.Store(nil, nil, nil)
 	e.isValidated = false
 	return m.output
 }
@@ -107,9 +114,9 @@ func (e *ExecOp) Validate() error {
 	return nil
 }
 
-func (e *ExecOp) Marshal() (digest.Digest, []byte, *OpMetadata, error) {
-	if e.cachedPB != nil {
-		return e.cachedPBDigest, e.cachedPB, &e.cachedOpMetadata, nil
+func (e *ExecOp) Marshal(c *Constraints) (digest.Digest, []byte, *pb.OpMetadata, error) {
+	if e.Cached(c) {
+		return e.Load()
 	}
 	if err := e.Validate(); err != nil {
 		return "", nil, nil, err
@@ -137,10 +144,9 @@ func (e *ExecOp) Marshal() (digest.Digest, []byte, *OpMetadata, error) {
 		}
 	}
 
-	pop := &pb.Op{
-		Op: &pb.Op_Exec{
-			Exec: peo,
-		},
+	pop, md := MarshalConstraints(c, &e.constraints)
+	pop.Op = &pb.Op_Exec{
+		Exec: peo,
 	}
 
 	outIndex := 0
@@ -150,7 +156,7 @@ func (e *ExecOp) Marshal() (digest.Digest, []byte, *OpMetadata, error) {
 			if m.tmpfs {
 				return "", nil, nil, errors.Errorf("tmpfs mounts must use scratch")
 			}
-			inp, err := m.source.ToInput()
+			inp, err := m.source.ToInput(c)
 			if err != nil {
 				return "", nil, nil, err
 			}
@@ -190,6 +196,14 @@ func (e *ExecOp) Marshal() (digest.Digest, []byte, *OpMetadata, error) {
 			pm.CacheOpt = &pb.CacheOpt{
 				ID: m.cacheID,
 			}
+			switch m.cacheSharing {
+			case CacheMountShared:
+				pm.CacheOpt.Sharing = pb.CacheSharingOpt_SHARED
+			case CacheMountPrivate:
+				pm.CacheOpt.Sharing = pb.CacheSharingOpt_PRIVATE
+			case CacheMountLocked:
+				pm.CacheOpt.Sharing = pb.CacheSharingOpt_LOCKED
+			}
 		}
 		if m.tmpfs {
 			pm.MountType = pb.MountType_TMPFS
@@ -201,9 +215,8 @@ func (e *ExecOp) Marshal() (digest.Digest, []byte, *OpMetadata, error) {
 	if err != nil {
 		return "", nil, nil, err
 	}
-	e.cachedPBDigest = digest.FromBytes(dt)
-	e.cachedPB = dt
-	return e.cachedPBDigest, dt, &e.cachedOpMetadata, nil
+	e.Store(dt, md, c)
+	return e.Load()
 }
 
 func (e *ExecOp) Output() Output {
@@ -273,9 +286,10 @@ func SourcePath(src string) MountOption {
 	}
 }
 
-func AsPersistentCacheDir(id string) MountOption {
+func AsPersistentCacheDir(id string, sharing CacheMountSharingMode) MountOption {
 	return func(m *mount) {
 		m.cacheID = id
+		m.cacheSharing = sharing
 	}
 }
 
@@ -366,7 +380,7 @@ func WithProxy(ps ProxyEnv) RunOption {
 }
 
 type ExecInfo struct {
-	opMetaWrapper
+	constraintsWrapper
 	State          State
 	Mounts         []MountInfo
 	ReadonlyRootFS bool
@@ -385,3 +399,11 @@ type ProxyEnv struct {
 	FtpProxy   string
 	NoProxy    string
 }
+
+type CacheMountSharingMode int
+
+const (
+	CacheMountShared CacheMountSharingMode = iota
+	CacheMountPrivate
+	CacheMountLocked
+)

+ 10 - 5
vendor/github.com/moby/buildkit/client/llb/imagemetaresolver/resolver.go

@@ -12,6 +12,7 @@ import (
 	"github.com/moby/buildkit/util/contentutil"
 	"github.com/moby/buildkit/util/imageutil"
 	digest "github.com/opencontainers/go-digest"
+	specs "github.com/opencontainers/image-spec/specs-go/v1"
 )
 
 var defaultImageMetaResolver llb.ImageMetaResolver
@@ -22,12 +23,12 @@ var WithDefault = llb.ImageOptionFunc(func(ii *llb.ImageInfo) {
 })
 
 type imageMetaResolverOpts struct {
-	platform string
+	platform *specs.Platform
 }
 
 type ImageMetaResolverOpt func(o *imageMetaResolverOpts)
 
-func WithPlatform(p string) ImageMetaResolverOpt {
+func WithDefaultPlatform(p *specs.Platform) ImageMetaResolverOpt {
 	return func(o *imageMetaResolverOpts) {
 		o.platform = p
 	}
@@ -59,7 +60,7 @@ func Default() llb.ImageMetaResolver {
 type imageMetaResolver struct {
 	resolver remotes.Resolver
 	buffer   contentutil.Buffer
-	platform string
+	platform *specs.Platform
 	locker   *locker.Locker
 	cache    map[string]resolveResult
 }
@@ -69,7 +70,7 @@ type resolveResult struct {
 	dgst   digest.Digest
 }
 
-func (imr *imageMetaResolver) ResolveImageConfig(ctx context.Context, ref string) (digest.Digest, []byte, error) {
+func (imr *imageMetaResolver) ResolveImageConfig(ctx context.Context, ref string, platform *specs.Platform) (digest.Digest, []byte, error) {
 	imr.locker.Lock(ref)
 	defer imr.locker.Unlock(ref)
 
@@ -77,7 +78,11 @@ func (imr *imageMetaResolver) ResolveImageConfig(ctx context.Context, ref string
 		return res.dgst, res.config, nil
 	}
 
-	dgst, config, err := imageutil.Config(ctx, ref, imr.resolver, imr.buffer, imr.platform)
+	if platform == nil {
+		platform = imr.platform
+	}
+
+	dgst, config, err := imageutil.Config(ctx, ref, imr.resolver, imr.buffer, platform)
 	if err != nil {
 		return "", nil, err
 	}

+ 57 - 5
vendor/github.com/moby/buildkit/client/llb/marshal.go

@@ -4,6 +4,7 @@ import (
 	"io"
 	"io/ioutil"
 
+	"github.com/containerd/containerd/platforms"
 	"github.com/moby/buildkit/solver/pb"
 	digest "github.com/opencontainers/go-digest"
 )
@@ -12,11 +13,11 @@ import (
 // Corresponds to the Definition structure defined in solver/pb.Definition.
 type Definition struct {
 	Def      [][]byte
-	Metadata map[digest.Digest]OpMetadata
+	Metadata map[digest.Digest]pb.OpMetadata
 }
 
 func (def *Definition) ToPB() *pb.Definition {
-	md := make(map[digest.Digest]OpMetadata)
+	md := make(map[digest.Digest]pb.OpMetadata)
 	for k, v := range def.Metadata {
 		md[k] = v
 	}
@@ -28,14 +29,12 @@ func (def *Definition) ToPB() *pb.Definition {
 
 func (def *Definition) FromPB(x *pb.Definition) {
 	def.Def = x.Def
-	def.Metadata = make(map[digest.Digest]OpMetadata)
+	def.Metadata = make(map[digest.Digest]pb.OpMetadata)
 	for k, v := range x.Metadata {
 		def.Metadata[k] = v
 	}
 }
 
-type OpMetadata = pb.OpMetadata
-
 func WriteTo(def *Definition, w io.Writer) error {
 	b, err := def.ToPB().Marshal()
 	if err != nil {
@@ -58,3 +57,56 @@ func ReadFrom(r io.Reader) (*Definition, error) {
 	def.FromPB(&pbDef)
 	return &def, nil
 }
+
+func MarshalConstraints(base, override *Constraints) (*pb.Op, *pb.OpMetadata) {
+	c := *base
+	c.WorkerConstraints = append([]string{}, c.WorkerConstraints...)
+
+	if p := override.Platform; p != nil {
+		c.Platform = p
+	}
+
+	for _, wc := range override.WorkerConstraints {
+		c.WorkerConstraints = append(c.WorkerConstraints, wc)
+	}
+
+	c.Metadata = mergeMetadata(c.Metadata, override.Metadata)
+
+	if c.Platform == nil {
+		defaultPlatform := platforms.Normalize(platforms.DefaultSpec())
+		c.Platform = &defaultPlatform
+	}
+
+	return &pb.Op{
+		Platform: &pb.Platform{
+			OS:           c.Platform.OS,
+			Architecture: c.Platform.Architecture,
+			Variant:      c.Platform.Variant,
+			OSVersion:    c.Platform.OSVersion,
+			OSFeatures:   c.Platform.OSFeatures,
+		},
+		Constraints: &pb.WorkerConstraints{
+			Filter: c.WorkerConstraints,
+		},
+	}, &c.Metadata
+}
+
+type MarshalCache struct {
+	digest      digest.Digest
+	dt          []byte
+	md          *pb.OpMetadata
+	constraints *Constraints
+}
+
+func (mc *MarshalCache) Cached(c *Constraints) bool {
+	return mc.dt != nil && mc.constraints == c
+}
+func (mc *MarshalCache) Load() (digest.Digest, []byte, *pb.OpMetadata, error) {
+	return mc.digest, mc.dt, mc.md, nil
+}
+func (mc *MarshalCache) Store(dt []byte, md *pb.OpMetadata, c *Constraints) {
+	mc.digest = digest.FromBytes(dt)
+	mc.dt = dt
+	mc.md = md
+	mc.constraints = c
+}

+ 22 - 4
vendor/github.com/moby/buildkit/client/llb/meta.go

@@ -4,16 +4,19 @@ import (
 	"fmt"
 	"path"
 
+	"github.com/containerd/containerd/platforms"
 	"github.com/google/shlex"
+	specs "github.com/opencontainers/image-spec/specs-go/v1"
 )
 
 type contextKeyT string
 
 var (
-	keyArgs = contextKeyT("llb.exec.args")
-	keyDir  = contextKeyT("llb.exec.dir")
-	keyEnv  = contextKeyT("llb.exec.env")
-	keyUser = contextKeyT("llb.exec.user")
+	keyArgs     = contextKeyT("llb.exec.args")
+	keyDir      = contextKeyT("llb.exec.dir")
+	keyEnv      = contextKeyT("llb.exec.env")
+	keyUser     = contextKeyT("llb.exec.user")
+	keyPlatform = contextKeyT("llb.platform")
 )
 
 func addEnv(key, value string) StateOption {
@@ -106,6 +109,21 @@ func shlexf(str string, v ...interface{}) StateOption {
 	}
 }
 
+func platform(p specs.Platform) StateOption {
+	return func(s State) State {
+		return s.WithValue(keyPlatform, platforms.Normalize(p))
+	}
+}
+
+func getPlatform(s State) *specs.Platform {
+	v := s.Value(keyPlatform)
+	if v != nil {
+		p := v.(specs.Platform)
+		return &p
+	}
+	return nil
+}
+
 type EnvList []KeyValue
 
 type KeyValue struct {

+ 2 - 1
vendor/github.com/moby/buildkit/client/llb/resolver.go

@@ -4,6 +4,7 @@ import (
 	"context"
 
 	digest "github.com/opencontainers/go-digest"
+	specs "github.com/opencontainers/image-spec/specs-go/v1"
 )
 
 func WithMetaResolver(mr ImageMetaResolver) ImageOption {
@@ -13,5 +14,5 @@ func WithMetaResolver(mr ImageMetaResolver) ImageOption {
 }
 
 type ImageMetaResolver interface {
-	ResolveImageConfig(ctx context.Context, ref string) (digest.Digest, []byte, error)
+	ResolveImageConfig(ctx context.Context, ref string, platform *specs.Platform) (digest.Digest, []byte, error)
 }

+ 30 - 35
vendor/github.com/moby/buildkit/client/llb/source.go

@@ -15,22 +15,21 @@ import (
 )
 
 type SourceOp struct {
-	id               string
-	attrs            map[string]string
-	output           Output
-	cachedPBDigest   digest.Digest
-	cachedPB         []byte
-	cachedOpMetadata OpMetadata
-	err              error
+	MarshalCache
+	id          string
+	attrs       map[string]string
+	output      Output
+	constraints Constraints
+	err         error
 }
 
-func NewSource(id string, attrs map[string]string, md OpMetadata) *SourceOp {
+func NewSource(id string, attrs map[string]string, c Constraints) *SourceOp {
 	s := &SourceOp{
-		id:               id,
-		attrs:            attrs,
-		cachedOpMetadata: md,
+		id:          id,
+		attrs:       attrs,
+		constraints: c,
 	}
-	s.output = &output{vertex: s}
+	s.output = &output{vertex: s, platform: c.Platform}
 	return s
 }
 
@@ -44,26 +43,26 @@ func (s *SourceOp) Validate() error {
 	return nil
 }
 
-func (s *SourceOp) Marshal() (digest.Digest, []byte, *OpMetadata, error) {
-	if s.cachedPB != nil {
-		return s.cachedPBDigest, s.cachedPB, &s.cachedOpMetadata, nil
+func (s *SourceOp) Marshal(constraints *Constraints) (digest.Digest, []byte, *pb.OpMetadata, error) {
+	if s.Cached(constraints) {
+		return s.Load()
 	}
 	if err := s.Validate(); err != nil {
 		return "", nil, nil, err
 	}
 
-	proto := &pb.Op{
-		Op: &pb.Op_Source{
-			Source: &pb.SourceOp{Identifier: s.id, Attrs: s.attrs},
-		},
+	proto, md := MarshalConstraints(constraints, &s.constraints)
+
+	proto.Op = &pb.Op_Source{
+		Source: &pb.SourceOp{Identifier: s.id, Attrs: s.attrs},
 	}
 	dt, err := proto.Marshal()
 	if err != nil {
 		return "", nil, nil, err
 	}
-	s.cachedPB = dt
-	s.cachedPBDigest = digest.FromBytes(dt)
-	return s.cachedPBDigest, dt, &s.cachedOpMetadata, nil
+
+	s.Store(dt, md, constraints)
+	return s.Load()
 }
 
 func (s *SourceOp) Output() Output {
@@ -74,10 +73,6 @@ func (s *SourceOp) Inputs() []Output {
 	return nil
 }
 
-func Source(id string) State {
-	return NewState(NewSource(id, nil, OpMetadata{}).Output())
-}
-
 func Image(ref string, opts ...ImageOption) State {
 	r, err := reference.ParseNormalizedNamed(ref)
 	if err == nil {
@@ -87,12 +82,12 @@ func Image(ref string, opts ...ImageOption) State {
 	for _, opt := range opts {
 		opt.SetImageOption(&info)
 	}
-	src := NewSource("docker-image://"+ref, nil, info.Metadata()) // controversial
+	src := NewSource("docker-image://"+ref, nil, info.Constraints) // controversial
 	if err != nil {
 		src.err = err
 	}
 	if info.metaResolver != nil {
-		_, dt, err := info.metaResolver.ResolveImageConfig(context.TODO(), ref)
+		_, dt, err := info.metaResolver.ResolveImageConfig(context.TODO(), ref, info.Constraints.Platform)
 		if err != nil {
 			src.err = err
 		} else {
@@ -136,7 +131,7 @@ func (fn ImageOptionFunc) SetImageOption(ii *ImageInfo) {
 }
 
 type ImageInfo struct {
-	opMetaWrapper
+	constraintsWrapper
 	metaResolver ImageMetaResolver
 }
 
@@ -169,7 +164,7 @@ func Git(remote, ref string, opts ...GitOption) State {
 	if url != "" {
 		attrs[pb.AttrFullRemoteURL] = url
 	}
-	source := NewSource("git://"+id, attrs, gi.Metadata())
+	source := NewSource("git://"+id, attrs, gi.Constraints)
 	return NewState(source.Output())
 }
 
@@ -183,7 +178,7 @@ func (fn gitOptionFunc) SetGitOption(gi *GitInfo) {
 }
 
 type GitInfo struct {
-	opMetaWrapper
+	constraintsWrapper
 	KeepGitDir bool
 }
 
@@ -220,7 +215,7 @@ func Local(name string, opts ...LocalOption) State {
 		attrs[pb.AttrSharedKeyHint] = gi.SharedKeyHint
 	}
 
-	source := NewSource("local://"+name, attrs, gi.Metadata())
+	source := NewSource("local://"+name, attrs, gi.Constraints)
 	return NewState(source.Output())
 }
 
@@ -280,7 +275,7 @@ func SharedKeyHint(h string) LocalOption {
 }
 
 type LocalInfo struct {
-	opMetaWrapper
+	constraintsWrapper
 	SessionID       string
 	IncludePatterns string
 	ExcludePatterns string
@@ -310,12 +305,12 @@ func HTTP(url string, opts ...HTTPOption) State {
 		attrs[pb.AttrHTTPGID] = strconv.Itoa(hi.GID)
 	}
 
-	source := NewSource(url, attrs, hi.Metadata())
+	source := NewSource(url, attrs, hi.Constraints)
 	return NewState(source.Output())
 }
 
 type HTTPInfo struct {
-	opMetaWrapper
+	constraintsWrapper
 	Checksum digest.Digest
 	Filename string
 	Perm     int

+ 126 - 55
vendor/github.com/moby/buildkit/client/llb/state.go

@@ -3,21 +3,23 @@ package llb
 import (
 	"context"
 
+	"github.com/containerd/containerd/platforms"
 	"github.com/moby/buildkit/solver/pb"
 	"github.com/moby/buildkit/util/system"
 	digest "github.com/opencontainers/go-digest"
+	specs "github.com/opencontainers/image-spec/specs-go/v1"
 )
 
 type StateOption func(State) State
 
 type Output interface {
-	ToInput() (*pb.Input, error)
+	ToInput(*Constraints) (*pb.Input, error)
 	Vertex() Vertex
 }
 
 type Vertex interface {
 	Validate() error
-	Marshal() (digest.Digest, []byte, *OpMetadata, error)
+	Marshal(*Constraints) (digest.Digest, []byte, *pb.OpMetadata, error)
 	Output() Output
 	Inputs() []Output
 }
@@ -29,12 +31,25 @@ func NewState(o Output) State {
 	}
 	s = dir("/")(s)
 	s = addEnv("PATH", system.DefaultPathEnv)(s)
+	s = s.ensurePlatform()
 	return s
 }
 
 type State struct {
-	out Output
-	ctx context.Context
+	out  Output
+	ctx  context.Context
+	opts []ConstraintsOpt
+}
+
+func (s State) ensurePlatform() State {
+	if o, ok := s.out.(interface {
+		Platform() *specs.Platform
+	}); ok {
+		if p := o.Platform(); p != nil {
+			s = platform(*p)(s)
+		}
+	}
+	return s
 }
 
 func (s State) WithValue(k, v interface{}) State {
@@ -48,18 +63,32 @@ func (s State) Value(k interface{}) interface{} {
 	return s.ctx.Value(k)
 }
 
-func (s State) Marshal(md ...MetadataOpt) (*Definition, error) {
+func (s State) SetMarhalDefaults(co ...ConstraintsOpt) State {
+	s.opts = co
+	return s
+}
+
+func (s State) Marshal(co ...ConstraintsOpt) (*Definition, error) {
 	def := &Definition{
-		Metadata: make(map[digest.Digest]OpMetadata, 0),
+		Metadata: make(map[digest.Digest]pb.OpMetadata, 0),
 	}
 	if s.Output() == nil {
 		return def, nil
 	}
-	def, err := marshal(s.Output().Vertex(), def, map[digest.Digest]struct{}{}, map[Vertex]struct{}{}, md)
+
+	defaultPlatform := platforms.Normalize(platforms.DefaultSpec())
+	c := &Constraints{
+		Platform: &defaultPlatform,
+	}
+	for _, o := range append(s.opts, co...) {
+		o.SetConstraintsOption(c)
+	}
+
+	def, err := marshal(s.Output().Vertex(), def, map[digest.Digest]struct{}{}, map[Vertex]struct{}{}, c)
 	if err != nil {
 		return def, err
 	}
-	inp, err := s.Output().ToInput()
+	inp, err := s.Output().ToInput(c)
 	if err != nil {
 		return def, err
 	}
@@ -72,29 +101,25 @@ func (s State) Marshal(md ...MetadataOpt) (*Definition, error) {
 	return def, nil
 }
 
-func marshal(v Vertex, def *Definition, cache map[digest.Digest]struct{}, vertexCache map[Vertex]struct{}, md []MetadataOpt) (*Definition, error) {
+func marshal(v Vertex, def *Definition, cache map[digest.Digest]struct{}, vertexCache map[Vertex]struct{}, c *Constraints) (*Definition, error) {
 	if _, ok := vertexCache[v]; ok {
 		return def, nil
 	}
 	for _, inp := range v.Inputs() {
 		var err error
-		def, err = marshal(inp.Vertex(), def, cache, vertexCache, md)
+		def, err = marshal(inp.Vertex(), def, cache, vertexCache, c)
 		if err != nil {
 			return def, err
 		}
 	}
 
-	dgst, dt, opMeta, err := v.Marshal()
+	dgst, dt, opMeta, err := v.Marshal(c)
 	if err != nil {
 		return def, err
 	}
 	vertexCache[v] = struct{}{}
 	if opMeta != nil {
-		m := mergeMetadata(def.Metadata[dgst], *opMeta)
-		for _, f := range md {
-			f.SetMetadataOption(&m)
-		}
-		def.Metadata[dgst] = m
+		def.Metadata[dgst] = mergeMetadata(def.Metadata[dgst], *opMeta)
 	}
 	if _, ok := cache[dgst]; ok {
 		return def, nil
@@ -113,14 +138,19 @@ func (s State) Output() Output {
 }
 
 func (s State) WithOutput(o Output) State {
-	return State{
+	s = State{
 		out: o,
 		ctx: s.ctx,
 	}
+	s = s.ensurePlatform()
+	return s
 }
 
 func (s State) Run(ro ...RunOption) ExecState {
 	ei := &ExecInfo{State: s}
+	if p := s.GetPlatform(); p != nil {
+		ei.Constraints.Platform = p
+	}
 	for _, o := range ro {
 		o.SetRunOption(ei)
 	}
@@ -132,7 +162,7 @@ func (s State) Run(ro ...RunOption) ExecState {
 		ProxyEnv: ei.ProxyEnv,
 	}
 
-	exec := NewExecOp(s.Output(), meta, ei.ReadonlyRootFS, ei.Metadata())
+	exec := NewExecOp(s.Output(), meta, ei.ReadonlyRootFS, ei.Constraints)
 	for _, m := range ei.Mounts {
 		exec.AddMount(m.Target, m.Source, m.Opts...)
 	}
@@ -178,6 +208,14 @@ func (s State) User(v string) State {
 	return user(v)(s)
 }
 
+func (s State) Platform(p specs.Platform) State {
+	return platform(p)(s)
+}
+
+func (s State) GetPlatform() *specs.Platform {
+	return getPlatform(s)
+}
+
 func (s State) With(so ...StateOption) State {
 	for _, o := range so {
 		s = o(s)
@@ -189,9 +227,10 @@ type output struct {
 	vertex   Vertex
 	getIndex func() (pb.OutputIndex, error)
 	err      error
+	platform *specs.Platform
 }
 
-func (o *output) ToInput() (*pb.Input, error) {
+func (o *output) ToInput(c *Constraints) (*pb.Input, error) {
 	if o.err != nil {
 		return nil, o.err
 	}
@@ -203,7 +242,7 @@ func (o *output) ToInput() (*pb.Input, error) {
 			return nil, err
 		}
 	}
-	dgst, _, _, err := o.vertex.Marshal()
+	dgst, _, _, err := o.vertex.Marshal(c)
 	if err != nil {
 		return nil, err
 	}
@@ -214,8 +253,12 @@ func (o *output) Vertex() Vertex {
 	return o.vertex
 }
 
-type MetadataOpt interface {
-	SetMetadataOption(*OpMetadata)
+func (o *output) Platform() *specs.Platform {
+	return o.platform
+}
+
+type ConstraintsOpt interface {
+	SetConstraintsOption(*Constraints)
 	RunOption
 	LocalOption
 	HTTPOption
@@ -223,33 +266,33 @@ type MetadataOpt interface {
 	GitOption
 }
 
-type metadataOptFunc func(m *OpMetadata)
+type constraintsOptFunc func(m *Constraints)
 
-func (fn metadataOptFunc) SetMetadataOption(m *OpMetadata) {
+func (fn constraintsOptFunc) SetConstraintsOption(m *Constraints) {
 	fn(m)
 }
 
-func (fn metadataOptFunc) SetRunOption(ei *ExecInfo) {
-	ei.ApplyMetadata(fn)
+func (fn constraintsOptFunc) SetRunOption(ei *ExecInfo) {
+	ei.applyConstraints(fn)
 }
 
-func (fn metadataOptFunc) SetLocalOption(li *LocalInfo) {
-	li.ApplyMetadata(fn)
+func (fn constraintsOptFunc) SetLocalOption(li *LocalInfo) {
+	li.applyConstraints(fn)
 }
 
-func (fn metadataOptFunc) SetHTTPOption(hi *HTTPInfo) {
-	hi.ApplyMetadata(fn)
+func (fn constraintsOptFunc) SetHTTPOption(hi *HTTPInfo) {
+	hi.applyConstraints(fn)
 }
 
-func (fn metadataOptFunc) SetImageOption(ii *ImageInfo) {
-	ii.ApplyMetadata(fn)
+func (fn constraintsOptFunc) SetImageOption(ii *ImageInfo) {
+	ii.applyConstraints(fn)
 }
 
-func (fn metadataOptFunc) SetGitOption(gi *GitInfo) {
-	gi.ApplyMetadata(fn)
+func (fn constraintsOptFunc) SetGitOption(gi *GitInfo) {
+	gi.applyConstraints(fn)
 }
 
-func mergeMetadata(m1, m2 OpMetadata) OpMetadata {
+func mergeMetadata(m1, m2 pb.OpMetadata) pb.OpMetadata {
 	if m2.IgnoreCache {
 		m1.IgnoreCache = true
 	}
@@ -268,49 +311,77 @@ func mergeMetadata(m1, m2 OpMetadata) OpMetadata {
 	return m1
 }
 
-var IgnoreCache = metadataOptFunc(func(md *OpMetadata) {
-	md.IgnoreCache = true
+var IgnoreCache = constraintsOptFunc(func(c *Constraints) {
+	c.Metadata.IgnoreCache = true
 })
 
-func WithDescription(m map[string]string) MetadataOpt {
-	return metadataOptFunc(func(md *OpMetadata) {
-		md.Description = m
+func WithDescription(m map[string]string) ConstraintsOpt {
+	return constraintsOptFunc(func(c *Constraints) {
+		c.Metadata.Description = m
 	})
 }
 
 // WithExportCache forces results for this vertex to be exported with the cache
-func WithExportCache() MetadataOpt {
-	return metadataOptFunc(func(md *OpMetadata) {
-		md.ExportCache = &pb.ExportCache{Value: true}
+func WithExportCache() ConstraintsOpt {
+	return constraintsOptFunc(func(c *Constraints) {
+		c.Metadata.ExportCache = &pb.ExportCache{Value: true}
 	})
 }
 
 // WithoutExportCache sets results for this vertex to be not exported with
 // the cache
-func WithoutExportCache() MetadataOpt {
-	return metadataOptFunc(func(md *OpMetadata) {
+func WithoutExportCache() ConstraintsOpt {
+	return constraintsOptFunc(func(c *Constraints) {
 		// ExportCache with value false means to disable exporting
-		md.ExportCache = &pb.ExportCache{Value: false}
+		c.Metadata.ExportCache = &pb.ExportCache{Value: false}
 	})
 }
 
 // WithoutDefaultExportCache resets the cache export for the vertex to use
 // the default defined by the build configuration.
-func WithoutDefaultExportCache() MetadataOpt {
-	return metadataOptFunc(func(md *OpMetadata) {
+func WithoutDefaultExportCache() ConstraintsOpt {
+	return constraintsOptFunc(func(c *Constraints) {
 		// nil means no vertex based config has been set
-		md.ExportCache = nil
+		c.Metadata.ExportCache = nil
 	})
 }
 
-type opMetaWrapper struct {
-	OpMetadata
+type constraintsWrapper struct {
+	Constraints
+}
+
+func (cw *constraintsWrapper) applyConstraints(f func(c *Constraints)) {
+	f(&cw.Constraints)
 }
 
-func (mw *opMetaWrapper) ApplyMetadata(f func(m *OpMetadata)) {
-	f(&mw.OpMetadata)
+type Constraints struct {
+	Platform          *specs.Platform
+	WorkerConstraints []string
+	Metadata          pb.OpMetadata
 }
 
-func (mw *opMetaWrapper) Metadata() OpMetadata {
-	return mw.OpMetadata
+func Platform(p specs.Platform) ConstraintsOpt {
+	return constraintsOptFunc(func(c *Constraints) {
+		c.Platform = &p
+	})
+}
+
+var (
+	LinuxAmd64   = Platform(specs.Platform{OS: "linux", Architecture: "amd64"})
+	LinuxArmhf   = Platform(specs.Platform{OS: "linux", Architecture: "arm", Variant: "v7"})
+	LinuxArm     = LinuxArmhf
+	LinuxArmel   = Platform(specs.Platform{OS: "linux", Architecture: "arm", Variant: "v6"})
+	LinuxArm64   = Platform(specs.Platform{OS: "linux", Architecture: "arm64"})
+	LinuxS390x   = Platform(specs.Platform{OS: "linux", Architecture: "s390x"})
+	LinuxPpc64le = Platform(specs.Platform{OS: "linux", Architecture: "ppc64le"})
+	Darwin       = Platform(specs.Platform{OS: "darwin", Architecture: "amd64"})
+	Windows      = Platform(specs.Platform{OS: "windows", Architecture: "amd64"})
+)
+
+func Require(filters ...string) ConstraintsOpt {
+	return constraintsOptFunc(func(c *Constraints) {
+		for _, f := range filters {
+			c.WorkerConstraints = append(c.WorkerConstraints, f)
+		}
+	})
 }

+ 22 - 4
vendor/github.com/moby/buildkit/client/workers.go

@@ -4,12 +4,15 @@ import (
 	"context"
 
 	controlapi "github.com/moby/buildkit/api/services/control"
+	"github.com/moby/buildkit/solver/pb"
+	specs "github.com/opencontainers/image-spec/specs-go/v1"
 	"github.com/pkg/errors"
 )
 
 type WorkerInfo struct {
-	ID     string
-	Labels map[string]string
+	ID        string
+	Labels    map[string]string
+	Platforms []specs.Platform
 }
 
 func (c *Client) ListWorkers(ctx context.Context, opts ...ListWorkersOption) ([]*WorkerInfo, error) {
@@ -28,8 +31,9 @@ func (c *Client) ListWorkers(ctx context.Context, opts ...ListWorkersOption) ([]
 
 	for _, w := range resp.Record {
 		wi = append(wi, &WorkerInfo{
-			ID:     w.ID,
-			Labels: w.Labels,
+			ID:        w.ID,
+			Labels:    w.Labels,
+			Platforms: toClientPlatforms(w.Platforms),
 		})
 	}
 
@@ -47,3 +51,17 @@ func WithWorkerFilter(f []string) ListWorkersOption {
 		wi.Filter = f
 	}
 }
+
+func toClientPlatforms(p []pb.Platform) []specs.Platform {
+	out := make([]specs.Platform, 0, len(p))
+	for _, pp := range p {
+		out = append(out, specs.Platform{
+			OS:           pp.OS,
+			Architecture: pp.Architecture,
+			Variant:      pp.Variant,
+			OSVersion:    pp.OSVersion,
+			OSFeatures:   pp.OSFeatures,
+		})
+	}
+	return out
+}

+ 23 - 3
vendor/github.com/moby/buildkit/control/control.go

@@ -13,7 +13,9 @@ import (
 	"github.com/moby/buildkit/session/grpchijack"
 	"github.com/moby/buildkit/solver"
 	"github.com/moby/buildkit/solver/llbsolver"
+	"github.com/moby/buildkit/solver/pb"
 	"github.com/moby/buildkit/worker"
+	specs "github.com/opencontainers/image-spec/specs-go/v1"
 	"github.com/pkg/errors"
 	"github.com/sirupsen/logrus"
 	"golang.org/x/sync/errgroup"
@@ -35,7 +37,10 @@ type Controller struct { // TODO: ControlService
 }
 
 func NewController(opt Opt) (*Controller, error) {
-	solver := llbsolver.New(opt.WorkerController, opt.Frontends, opt.CacheKeyStorage, opt.CacheImporter)
+	solver, err := llbsolver.New(opt.WorkerController, opt.Frontends, opt.CacheKeyStorage, opt.CacheImporter)
+	if err != nil {
+		return nil, errors.Wrap(err, "failed to create solver")
+	}
 
 	c := &Controller{
 		opt:    opt,
@@ -265,8 +270,9 @@ func (c *Controller) ListWorkers(ctx context.Context, r *controlapi.ListWorkersR
 	}
 	for _, w := range workers {
 		resp.Record = append(resp.Record, &controlapi.WorkerRecord{
-			ID:     w.ID(),
-			Labels: w.Labels(),
+			ID:        w.ID(),
+			Labels:    w.Labels(),
+			Platforms: toPBPlatforms(w.Platforms()),
 		})
 	}
 	return resp, nil
@@ -290,3 +296,17 @@ func parseCacheExporterOpt(opt map[string]string) solver.CacheExportMode {
 	}
 	return solver.CacheExportModeMin
 }
+
+func toPBPlatforms(p []specs.Platform) []pb.Platform {
+	out := make([]pb.Platform, 0, len(p))
+	for _, pp := range p {
+		out = append(out, pb.Platform{
+			OS:           pp.OS,
+			Architecture: pp.Architecture,
+			Variant:      pp.Variant,
+			OSVersion:    pp.OSVersion,
+			OSFeatures:   pp.OSFeatures,
+		})
+	}
+	return out
+}

+ 25 - 9
vendor/github.com/moby/buildkit/frontend/dockerfile/builder/build.go

@@ -8,10 +8,12 @@ import (
 	"regexp"
 	"strings"
 
+	"github.com/containerd/containerd/platforms"
 	"github.com/docker/docker/builder/dockerignore"
 	"github.com/moby/buildkit/client/llb"
 	"github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb"
 	"github.com/moby/buildkit/frontend/gateway/client"
+	specs "github.com/opencontainers/image-spec/specs-go/v1"
 	"github.com/pkg/errors"
 	"golang.org/x/sync/errgroup"
 )
@@ -28,14 +30,26 @@ const (
 	buildArgPrefix        = "build-arg:"
 	labelPrefix           = "label:"
 	keyNoCache            = "no-cache"
+	keyTargetPlatform     = "platform"
 )
 
 var httpPrefix = regexp.MustCompile("^https?://")
-var gitUrlPathWithFragmentSuffix = regexp.MustCompile(".git(?:#.+)?$")
+var gitUrlPathWithFragmentSuffix = regexp.MustCompile("\\.git(?:#.+)?$")
 
 func Build(ctx context.Context, c client.Client) error {
 	opts := c.Opts()
 
+	// TODO: read buildPlatforms from workers
+	buildPlatforms := []specs.Platform{platforms.DefaultSpec()}
+	targetPlatform := platforms.DefaultSpec()
+	if v := opts[keyTargetPlatform]; v != "" {
+		var err error
+		targetPlatform, err = platforms.Parse(v)
+		if err != nil {
+			return errors.Wrapf(err, "failed to parse target platform %s", v)
+		}
+	}
+
 	filename := opts[keyFilename]
 	if filename == "" {
 		filename = defaultDockerfileName
@@ -166,14 +180,16 @@ func Build(ctx context.Context, c client.Client) error {
 	}
 
 	st, img, err := dockerfile2llb.Dockerfile2LLB(ctx, dtDockerfile, dockerfile2llb.ConvertOpt{
-		Target:       opts[keyTarget],
-		MetaResolver: c,
-		BuildArgs:    filter(opts, buildArgPrefix),
-		Labels:       filter(opts, labelPrefix),
-		SessionID:    c.SessionID(),
-		BuildContext: buildContext,
-		Excludes:     excludes,
-		IgnoreCache:  ignoreCache,
+		Target:         opts[keyTarget],
+		MetaResolver:   c,
+		BuildArgs:      filter(opts, buildArgPrefix),
+		Labels:         filter(opts, labelPrefix),
+		SessionID:      c.SessionID(),
+		BuildContext:   buildContext,
+		Excludes:       excludes,
+		IgnoreCache:    ignoreCache,
+		TargetPlatform: &targetPlatform,
+		BuildPlatforms: buildPlatforms,
 	})
 
 	if err != nil {

+ 85 - 17
vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert.go

@@ -12,6 +12,7 @@ import (
 	"strconv"
 	"strings"
 
+	"github.com/containerd/containerd/platforms"
 	"github.com/docker/distribution/reference"
 	"github.com/docker/docker/pkg/signal"
 	"github.com/docker/go-connections/nat"
@@ -20,7 +21,7 @@ import (
 	"github.com/moby/buildkit/frontend/dockerfile/instructions"
 	"github.com/moby/buildkit/frontend/dockerfile/parser"
 	"github.com/moby/buildkit/frontend/dockerfile/shell"
-	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
+	specs "github.com/opencontainers/image-spec/specs-go/v1"
 	"github.com/pkg/errors"
 	"golang.org/x/sync/errgroup"
 )
@@ -30,7 +31,7 @@ const (
 	localNameContext = "context"
 	historyComment   = "buildkit.dockerfile.v0"
 
-	CopyImage = "tonistiigi/copy:v0.1.3@sha256:87c46e7b413cdd2c2702902b481b390ce263ac9d942253d366f3b1a3c16f96d6"
+	CopyImage = "tonistiigi/copy:v0.1.3@sha256:e57a3b4d6240f55bac26b655d2cfb751f8b9412d6f7bb1f787e946391fb4b21b"
 )
 
 type ConvertOpt struct {
@@ -46,6 +47,8 @@ type ConvertOpt struct {
 	IgnoreCache []string
 	// CacheIDNamespace scopes the IDs for different cache mounts
 	CacheIDNamespace string
+	TargetPlatform   *specs.Platform
+	BuildPlatforms   []specs.Platform
 }
 
 func Dockerfile2LLB(ctx context.Context, dt []byte, opt ConvertOpt) (*llb.State, *Image, error) {
@@ -53,6 +56,18 @@ func Dockerfile2LLB(ctx context.Context, dt []byte, opt ConvertOpt) (*llb.State,
 		return nil, nil, errors.Errorf("the Dockerfile cannot be empty")
 	}
 
+	if opt.TargetPlatform != nil && opt.BuildPlatforms == nil {
+		opt.BuildPlatforms = []specs.Platform{*opt.TargetPlatform}
+	}
+	if len(opt.BuildPlatforms) == 0 {
+		opt.BuildPlatforms = []specs.Platform{platforms.DefaultSpec()}
+	}
+	implicitTargetPlatform := false
+	if opt.TargetPlatform == nil {
+		implicitTargetPlatform = true
+		opt.TargetPlatform = &opt.BuildPlatforms[0]
+	}
+
 	dockerfile, err := parser.Parse(bytes.NewReader(dt))
 	if err != nil {
 		return nil, nil, err
@@ -92,6 +107,20 @@ func Dockerfile2LLB(ctx context.Context, dt []byte, opt ConvertOpt) (*llb.State,
 			deps:     make(map[*dispatchState]struct{}),
 			ctxPaths: make(map[string]struct{}),
 		}
+
+		if v := st.Platform; v != "" {
+			v, err := shlex.ProcessWord(v, toEnvList(metaArgs, nil))
+			if err != nil {
+				return nil, nil, errors.Wrapf(err, "failed to process arguments for platform %s", v)
+			}
+
+			p, err := platforms.Parse(v)
+			if err != nil {
+				return nil, nil, errors.Wrapf(err, "failed to parse platform %s", v)
+			}
+			ds.platform = &p
+		}
+
 		if d, ok := dispatchStatesByName[st.BaseName]; ok {
 			ds.base = d
 		}
@@ -150,7 +179,7 @@ func Dockerfile2LLB(ctx context.Context, dt []byte, opt ConvertOpt) (*llb.State,
 		if d.base == nil {
 			if d.stage.BaseName == emptyImageName {
 				d.state = llb.Scratch()
-				d.image = emptyImage()
+				d.image = emptyImage(*opt.TargetPlatform)
 				continue
 			}
 			func(i int, d *dispatchState) {
@@ -159,16 +188,25 @@ func Dockerfile2LLB(ctx context.Context, dt []byte, opt ConvertOpt) (*llb.State,
 					if err != nil {
 						return err
 					}
+					platform := d.platform
+					if platform == nil {
+						platform = opt.TargetPlatform
+					}
 					d.stage.BaseName = reference.TagNameOnly(ref).String()
 					var isScratch bool
 					if metaResolver != nil && reachable {
-						dgst, dt, err := metaResolver.ResolveImageConfig(ctx, d.stage.BaseName)
+						dgst, dt, err := metaResolver.ResolveImageConfig(ctx, d.stage.BaseName, platform)
 						if err == nil { // handle the error while builder is actually running
 							var img Image
 							if err := json.Unmarshal(dt, &img); err != nil {
 								return err
 							}
 							img.Created = nil
+							// if there is no explicit target platform, try to match based on image config
+							if d.platform == nil && implicitTargetPlatform {
+								p := autoDetectPlatform(img, *platform, opt.BuildPlatforms)
+								platform = &p
+							}
 							d.image = img
 							if dgst != "" {
 								ref, err = reference.WithDigest(ref, dgst)
@@ -186,7 +224,7 @@ func Dockerfile2LLB(ctx context.Context, dt []byte, opt ConvertOpt) (*llb.State,
 					if isScratch {
 						d.state = llb.Scratch()
 					} else {
-						d.state = llb.Image(d.stage.BaseName, dfCmd(d.stage.SourceCode))
+						d.state = llb.Image(d.stage.BaseName, dfCmd(d.stage.SourceCode), llb.Platform(*platform))
 					}
 					return nil
 				})
@@ -242,6 +280,8 @@ func Dockerfile2LLB(ctx context.Context, dt []byte, opt ConvertOpt) (*llb.State,
 			buildContext:         llb.NewState(buildContext),
 			proxyEnv:             proxyEnv,
 			cacheIDNamespace:     opt.CacheIDNamespace,
+			buildPlatforms:       opt.BuildPlatforms,
+			targetPlatform:       *opt.TargetPlatform,
 		}
 
 		if err = dispatchOnBuild(d, d.image.Config.OnBuild, opt); err != nil {
@@ -280,7 +320,14 @@ func Dockerfile2LLB(ctx context.Context, dt []byte, opt ConvertOpt) (*llb.State,
 	}
 	buildContext.Output = bc.Output()
 
-	return &target.state, &target.image, nil
+	st := target.state.SetMarhalDefaults(llb.Platform(*opt.TargetPlatform))
+
+	if !implicitTargetPlatform {
+		target.image.OS = opt.TargetPlatform.OS
+		target.image.Architecture = opt.TargetPlatform.Architecture
+	}
+
+	return &st, &target.image, nil
 }
 
 func toCommand(ic instructions.Command, dispatchStatesByName map[string]*dispatchState, allDispatchStates []*dispatchState) (command, error) {
@@ -325,6 +372,8 @@ type dispatchOpt struct {
 	buildContext         llb.State
 	proxyEnv             *llb.ProxyEnv
 	cacheIDNamespace     string
+	targetPlatform       specs.Platform
+	buildPlatforms       []specs.Platform
 }
 
 func dispatch(d *dispatchState, cmd command, opt dispatchOpt) error {
@@ -348,7 +397,7 @@ func dispatch(d *dispatchState, cmd command, opt dispatchOpt) error {
 	case *instructions.WorkdirCommand:
 		err = dispatchWorkdir(d, c, true)
 	case *instructions.AddCommand:
-		err = dispatchCopy(d, c.SourcesAndDest, opt.buildContext, true, c, "")
+		err = dispatchCopy(d, c.SourcesAndDest, opt.buildContext, true, c, "", opt)
 		if err == nil {
 			for _, src := range c.Sources() {
 				d.ctxPaths[path.Join("/", filepath.ToSlash(src))] = struct{}{}
@@ -381,7 +430,7 @@ func dispatch(d *dispatchState, cmd command, opt dispatchOpt) error {
 		if len(cmd.sources) != 0 {
 			l = cmd.sources[0].state
 		}
-		err = dispatchCopy(d, c.SourcesAndDest, l, false, c, c.Chown)
+		err = dispatchCopy(d, c.SourcesAndDest, l, false, c, c.Chown, opt)
 		if err == nil && len(cmd.sources) == 0 {
 			for _, src := range c.Sources() {
 				d.ctxPaths[path.Join("/", filepath.ToSlash(src))] = struct{}{}
@@ -395,6 +444,7 @@ func dispatch(d *dispatchState, cmd command, opt dispatchOpt) error {
 type dispatchState struct {
 	state        llb.State
 	image        Image
+	platform     *specs.Platform
 	stage        instructions.Stage
 	base         *dispatchState
 	deps         map[*dispatchState]struct{}
@@ -467,7 +517,11 @@ func dispatchRun(d *dispatchState, c *instructions.RunCommand, proxy *llb.ProxyE
 		opt = append(opt, llb.WithProxy(*proxy))
 	}
 
-	opt = append(opt, dispatchRunMounts(d, c, sources, dopt)...)
+	runMounts, err := dispatchRunMounts(d, c, sources, dopt)
+	if err != nil {
+		return err
+	}
+	opt = append(opt, runMounts...)
 
 	d.state = d.state.Run(opt...).Root()
 	return commitToHistory(&d.image, "RUN "+runCommandString(args, d.buildArgs), true, &d.state)
@@ -486,9 +540,9 @@ func dispatchWorkdir(d *dispatchState, c *instructions.WorkdirCommand, commit bo
 	return nil
 }
 
-func dispatchCopy(d *dispatchState, c instructions.SourcesAndDest, sourceState llb.State, isAddCommand bool, cmdToPrint interface{}, chown string) error {
+func dispatchCopy(d *dispatchState, c instructions.SourcesAndDest, sourceState llb.State, isAddCommand bool, cmdToPrint interface{}, chown string, opt dispatchOpt) error {
 	// TODO: this should use CopyOp instead. Current implementation is inefficient
-	img := llb.Image(CopyImage)
+	img := llb.Image(CopyImage, llb.Platform(opt.buildPlatforms[0]))
 
 	dest := path.Join(".", pathRelativeToWorkingDir(d.state, c.Dest()))
 	if c.Dest() == "." || c.Dest()[len(c.Dest())-1] == filepath.Separator {
@@ -554,12 +608,12 @@ func dispatchCopy(d *dispatchState, c instructions.SourcesAndDest, sourceState l
 		args = append(args[:1], append([]string{"--unpack"}, args[1:]...)...)
 	}
 
-	opt := []llb.RunOption{llb.Args(args), llb.Dir("/dest"), llb.ReadonlyRootFS(), dfCmd(cmdToPrint)}
+	runOpt := []llb.RunOption{llb.Args(args), llb.Dir("/dest"), llb.ReadonlyRootFS(), dfCmd(cmdToPrint)}
 	if d.ignoreCache {
-		opt = append(opt, llb.IgnoreCache)
+		runOpt = append(runOpt, llb.IgnoreCache)
 	}
-	run := img.Run(append(opt, mounts...)...)
-	d.state = run.AddMount("/dest", d.state)
+	run := img.Run(append(runOpt, mounts...)...)
+	d.state = run.AddMount("/dest", d.state).Platform(opt.targetPlatform)
 
 	return commitToHistory(&d.image, commitMessage.String(), true, &d.state)
 }
@@ -767,7 +821,7 @@ func getArgValue(arg instructions.ArgCommand) string {
 	return v
 }
 
-func dfCmd(cmd interface{}) llb.MetadataOpt {
+func dfCmd(cmd interface{}) llb.ConstraintsOpt {
 	// TODO: add fmt.Stringer to instructions.Command to remove interface{}
 	var cmdStr string
 	if cmd, ok := cmd.(fmt.Stringer); ok {
@@ -798,7 +852,7 @@ func commitToHistory(img *Image, msg string, withLayer bool, st *llb.State) erro
 		msg += " # buildkit"
 	}
 
-	img.History = append(img.History, ocispec.History{
+	img.History = append(img.History, specs.History{
 		CreatedBy:  msg,
 		Comment:    historyComment,
 		EmptyLayer: !withLayer,
@@ -930,3 +984,17 @@ func withShell(img Image, args []string) []string {
 	}
 	return append(shell, strings.Join(args, " "))
 }
+
+func autoDetectPlatform(img Image, target specs.Platform, supported []specs.Platform) specs.Platform {
+	os := img.OS
+	arch := img.Architecture
+	if target.OS == os && target.Architecture == arch {
+		return target
+	}
+	for _, p := range supported {
+		if p.OS == os && p.Architecture == arch {
+			return p
+		}
+	}
+	return target
+}

+ 2 - 2
vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert_norunmount.go

@@ -11,6 +11,6 @@ func detectRunMount(cmd *command, dispatchStatesByName map[string]*dispatchState
 	return false
 }
 
-func dispatchRunMounts(d *dispatchState, c *instructions.RunCommand, sources []*dispatchState, opt dispatchOpt) []llb.RunOption {
-	return nil
+func dispatchRunMounts(d *dispatchState, c *instructions.RunCommand, sources []*dispatchState, opt dispatchOpt) ([]llb.RunOption, error) {
+	return nil, nil
 }

+ 16 - 4
vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert_runmount.go

@@ -9,6 +9,7 @@ import (
 
 	"github.com/moby/buildkit/client/llb"
 	"github.com/moby/buildkit/frontend/dockerfile/instructions"
+	"github.com/pkg/errors"
 )
 
 func detectRunMount(cmd *command, dispatchStatesByName map[string]*dispatchState, allDispatchStates []*dispatchState) bool {
@@ -40,7 +41,7 @@ func detectRunMount(cmd *command, dispatchStatesByName map[string]*dispatchState
 	return false
 }
 
-func dispatchRunMounts(d *dispatchState, c *instructions.RunCommand, sources []*dispatchState, opt dispatchOpt) []llb.RunOption {
+func dispatchRunMounts(d *dispatchState, c *instructions.RunCommand, sources []*dispatchState, opt dispatchOpt) ([]llb.RunOption, error) {
 	var out []llb.RunOption
 	mounts := instructions.GetMounts(c)
 
@@ -61,14 +62,25 @@ func dispatchRunMounts(d *dispatchState, c *instructions.RunCommand, sources []*
 			mountOpts = append(mountOpts, llb.Readonly)
 		}
 		if mount.Type == instructions.MountTypeCache {
-			mountOpts = append(mountOpts, llb.AsPersistentCacheDir(opt.cacheIDNamespace+"/"+mount.CacheID))
+			sharing := llb.CacheMountShared
+			if mount.CacheSharing == instructions.MountSharingPrivate {
+				sharing = llb.CacheMountPrivate
+			}
+			if mount.CacheSharing == instructions.MountSharingLocked {
+				sharing = llb.CacheMountLocked
+			}
+			mountOpts = append(mountOpts, llb.AsPersistentCacheDir(opt.cacheIDNamespace+"/"+mount.CacheID, sharing))
+		}
+		target := path.Join("/", mount.Target)
+		if target == "/" {
+			return nil, errors.Errorf("invalid mount target %q", mount.Target)
 		}
 		if src := path.Join("/", mount.Source); src != "/" {
 			mountOpts = append(mountOpts, llb.SourcePath(src))
 		}
-		out = append(out, llb.AddMount(path.Join("/", mount.Target), st, mountOpts...))
+		out = append(out, llb.AddMount(target, st, mountOpts...))
 
 		d.ctxPaths[path.Join("/", filepath.ToSlash(mount.Source))] = struct{}{}
 	}
-	return out
+	return out, nil
 }

+ 7 - 8
vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/image.go

@@ -1,12 +1,11 @@
 package dockerfile2llb
 
 import (
-	"runtime"
 	"time"
 
 	"github.com/docker/docker/api/types/strslice"
 	"github.com/moby/buildkit/util/system"
-	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
+	specs "github.com/opencontainers/image-spec/specs-go/v1"
 )
 
 // HealthConfig holds configuration settings for the HEALTHCHECK feature.
@@ -31,7 +30,7 @@ type HealthConfig struct {
 }
 
 type ImageConfig struct {
-	ocispec.ImageConfig
+	specs.ImageConfig
 
 	Healthcheck *HealthConfig `json:",omitempty"` // Healthcheck describes how to check the container is healthy
 	ArgsEscaped bool          `json:",omitempty"` // True if command is already escaped (Windows specific)
@@ -46,7 +45,7 @@ type ImageConfig struct {
 // Image is the JSON structure which describes some basic information about the image.
 // This provides the `application/vnd.oci.image.config.v1+json` mediatype when marshalled to JSON.
 type Image struct {
-	ocispec.Image
+	specs.Image
 
 	// Config defines the execution parameters which should be used as a base when running a container using the image.
 	Config ImageConfig `json:"config,omitempty"`
@@ -61,11 +60,11 @@ func clone(src Image) Image {
 	return img
 }
 
-func emptyImage() Image {
+func emptyImage(platform specs.Platform) Image {
 	img := Image{
-		Image: ocispec.Image{
-			Architecture: runtime.GOARCH,
-			OS:           runtime.GOOS,
+		Image: specs.Image{
+			Architecture: platform.Architecture,
+			OS:           platform.OS,
 		},
 	}
 	img.RootFS.Type = "layers"

+ 1 - 2
vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands.go

@@ -6,7 +6,6 @@ import (
 
 	"github.com/docker/docker/api/types/container"
 	"github.com/docker/docker/api/types/strslice"
-	specs "github.com/opencontainers/image-spec/specs-go/v1"
 )
 
 // KeyValuePair represent an arbitrary named value (useful in slice instead of map[string] string to preserve ordering)
@@ -382,7 +381,7 @@ type Stage struct {
 	Commands   []Command
 	BaseName   string
 	SourceCode string
-	Platform   specs.Platform
+	Platform   string
 }
 
 // AddCommand to the stage

+ 27 - 7
vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands_runmount.go

@@ -20,6 +20,16 @@ var allowedMountTypes = map[string]struct{}{
 	MountTypeTmpfs: {},
 }
 
+const MountSharingShared = "shared"
+const MountSharingPrivate = "private"
+const MountSharingLocked = "locked"
+
+var allowedSharingTypes = map[string]struct{}{
+	MountSharingShared:  {},
+	MountSharingPrivate: {},
+	MountSharingLocked:  {},
+}
+
 type mountsKeyT string
 
 var mountsKey = mountsKeyT("dockerfile/run/mounts")
@@ -76,12 +86,13 @@ type mountState struct {
 }
 
 type Mount struct {
-	Type     string
-	From     string
-	Source   string
-	Target   string
-	ReadOnly bool
-	CacheID  string
+	Type         string
+	From         string
+	Source       string
+	Target       string
+	ReadOnly     bool
+	CacheID      string
+	CacheSharing string
 }
 
 func parseMount(value string) (*Mount, error) {
@@ -120,7 +131,7 @@ func parseMount(value string) (*Mount, error) {
 		switch key {
 		case "type":
 			if !isValidMountType(strings.ToLower(value)) {
-				return nil, errors.Errorf("invalid mount type %q", value)
+				return nil, errors.Errorf("unsupported mount type %q", value)
 			}
 			m.Type = strings.ToLower(value)
 		case "from":
@@ -144,6 +155,11 @@ func parseMount(value string) (*Mount, error) {
 			roAuto = false
 		case "id":
 			m.CacheID = value
+		case "sharing":
+			if _, ok := allowedSharingTypes[strings.ToLower(value)]; !ok {
+				return nil, errors.Errorf("unsupported sharing value %q", value)
+			}
+			m.CacheSharing = strings.ToLower(value)
 		default:
 			return nil, errors.Errorf("unexpected key '%s' in '%s'", key, field)
 		}
@@ -157,5 +173,9 @@ func parseMount(value string) (*Mount, error) {
 		}
 	}
 
+	if m.CacheSharing != "" && m.Type != MountTypeCache {
+		return nil, errors.Errorf("invalid cache sharing set for %v mount", m.Type)
+	}
+
 	return m, nil
 }

+ 2 - 2
vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/parse.go

@@ -10,7 +10,6 @@ import (
 
 	"github.com/docker/docker/api/types/container"
 	"github.com/docker/docker/api/types/strslice"
-	"github.com/docker/docker/pkg/system"
 	"github.com/moby/buildkit/frontend/dockerfile/command"
 	"github.com/moby/buildkit/frontend/dockerfile/parser"
 	"github.com/pkg/errors"
@@ -279,13 +278,14 @@ func parseFrom(req parseRequest) (*Stage, error) {
 	if err := req.flags.Parse(); err != nil {
 		return nil, err
 	}
+
 	code := strings.TrimSpace(req.original)
 	return &Stage{
 		BaseName:   req.args[0],
 		Name:       stageName,
 		SourceCode: code,
 		Commands:   []Command{},
-		Platform:   *system.ParsePlatform(flPlatform.Value),
+		Platform:   flPlatform.Value,
 	}, nil
 
 }

+ 2 - 1
vendor/github.com/moby/buildkit/frontend/frontend.go

@@ -9,6 +9,7 @@ import (
 	"github.com/moby/buildkit/solver"
 	"github.com/moby/buildkit/solver/pb"
 	digest "github.com/opencontainers/go-digest"
+	specs "github.com/opencontainers/image-spec/specs-go/v1"
 )
 
 type Frontend interface {
@@ -17,7 +18,7 @@ type Frontend interface {
 
 type FrontendLLBBridge interface {
 	Solve(ctx context.Context, req SolveRequest) (solver.CachedResult, map[string][]byte, error)
-	ResolveImageConfig(ctx context.Context, ref string) (digest.Digest, []byte, error)
+	ResolveImageConfig(ctx context.Context, ref string, platform *specs.Platform) (digest.Digest, []byte, error)
 	Exec(ctx context.Context, meta executor.Meta, rootfs cache.ImmutableRef, stdin io.ReadCloser, stdout, stderr io.WriteCloser) error
 }
 

+ 2 - 1
vendor/github.com/moby/buildkit/frontend/gateway/client/client.go

@@ -5,12 +5,13 @@ import (
 
 	"github.com/moby/buildkit/solver/pb"
 	digest "github.com/opencontainers/go-digest"
+	specs "github.com/opencontainers/image-spec/specs-go/v1"
 )
 
 // TODO: make this take same options as LLBBridge. Add Return()
 type Client interface {
 	Solve(ctx context.Context, req SolveRequest, exporterAttr map[string][]byte, final bool) (Reference, error)
-	ResolveImageConfig(ctx context.Context, ref string) (digest.Digest, []byte, error)
+	ResolveImageConfig(ctx context.Context, ref string, platform *specs.Platform) (digest.Digest, []byte, error)
 	Opts() map[string]string
 	SessionID() string
 }

+ 25 - 7
vendor/github.com/moby/buildkit/frontend/gateway/gateway.go

@@ -8,6 +8,7 @@ import (
 	"net"
 	"os"
 	"strings"
+	"sync"
 	"time"
 
 	"github.com/docker/distribution/reference"
@@ -21,7 +22,7 @@ import (
 	"github.com/moby/buildkit/solver"
 	"github.com/moby/buildkit/util/tracing"
 	"github.com/moby/buildkit/worker"
-	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
+	specs "github.com/opencontainers/image-spec/specs-go/v1"
 	"github.com/pkg/errors"
 	"github.com/sirupsen/logrus"
 	"golang.org/x/net/http2"
@@ -62,7 +63,7 @@ func (gf *gatewayFrontend) Solve(ctx context.Context, llbBridge frontend.Fronten
 	sid := session.FromContext(ctx)
 
 	_, isDevel := opts[keyDevel]
-	var img ocispec.Image
+	var img specs.Image
 	var rootFS cache.ImmutableRef
 	var readonly bool // TODO: try to switch to read-only by default.
 
@@ -94,7 +95,7 @@ func (gf *gatewayFrontend) Solve(ctx context.Context, llbBridge frontend.Fronten
 			return nil, nil, err
 		}
 
-		dgst, config, err := llbBridge.ResolveImageConfig(ctx, reference.TagNameOnly(sourceRef).String())
+		dgst, config, err := llbBridge.ResolveImageConfig(ctx, reference.TagNameOnly(sourceRef).String(), nil) // TODO:
 		if err != nil {
 			return nil, nil, err
 		}
@@ -103,9 +104,11 @@ func (gf *gatewayFrontend) Solve(ctx context.Context, llbBridge frontend.Fronten
 			return nil, nil, err
 		}
 
-		sourceRef, err = reference.WithDigest(sourceRef, dgst)
-		if err != nil {
-			return nil, nil, err
+		if dgst != "" {
+			sourceRef, err = reference.WithDigest(sourceRef, dgst)
+			if err != nil {
+				return nil, nil, err
+			}
 		}
 
 		src := llb.Image(sourceRef.String())
@@ -248,6 +251,7 @@ func (d dummyAddr) String() string {
 }
 
 type llbBridgeForwarder struct {
+	mu           sync.Mutex
 	callCtx      context.Context
 	llbBridge    frontend.FrontendLLBBridge
 	refs         map[string]solver.Result
@@ -258,7 +262,17 @@ type llbBridgeForwarder struct {
 
 func (lbf *llbBridgeForwarder) ResolveImageConfig(ctx context.Context, req *pb.ResolveImageConfigRequest) (*pb.ResolveImageConfigResponse, error) {
 	ctx = tracing.ContextWithSpanFromContext(ctx, lbf.callCtx)
-	dgst, dt, err := lbf.llbBridge.ResolveImageConfig(ctx, req.Ref)
+	var platform *specs.Platform
+	if p := req.Platform; p != nil {
+		platform = &specs.Platform{
+			OS:           p.OS,
+			Architecture: p.Architecture,
+			Variant:      p.Variant,
+			OSVersion:    p.OSVersion,
+			OSFeatures:   p.OSFeatures,
+		}
+	}
+	dgst, dt, err := lbf.llbBridge.ResolveImageConfig(ctx, req.Ref, platform)
 	if err != nil {
 		return nil, err
 	}
@@ -292,7 +306,9 @@ func (lbf *llbBridgeForwarder) Solve(ctx context.Context, req *pb.SolveRequest)
 	}
 
 	id := identity.NewID()
+	lbf.mu.Lock()
 	lbf.refs[id] = ref
+	lbf.mu.Unlock()
 	if req.Final {
 		lbf.lastRef = ref
 		lbf.exporterAttr = exp
@@ -304,7 +320,9 @@ func (lbf *llbBridgeForwarder) Solve(ctx context.Context, req *pb.SolveRequest)
 }
 func (lbf *llbBridgeForwarder) ReadFile(ctx context.Context, req *pb.ReadFileRequest) (*pb.ReadFileResponse, error) {
 	ctx = tracing.ContextWithSpanFromContext(ctx, lbf.callCtx)
+	lbf.mu.Lock()
 	ref, ok := lbf.refs[req.Ref]
+	lbf.mu.Unlock()
 	if !ok {
 		return nil, errors.Errorf("no such ref: %v", req.Ref)
 	}

+ 102 - 46
vendor/github.com/moby/buildkit/frontend/gateway/pb/gateway.pb.go

@@ -45,7 +45,8 @@ var _ = math.Inf
 const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
 
 type ResolveImageConfigRequest struct {
-	Ref string `protobuf:"bytes,1,opt,name=Ref,proto3" json:"Ref,omitempty"`
+	Ref      string       `protobuf:"bytes,1,opt,name=Ref,proto3" json:"Ref,omitempty"`
+	Platform *pb.Platform `protobuf:"bytes,2,opt,name=Platform" json:"Platform,omitempty"`
 }
 
 func (m *ResolveImageConfigRequest) Reset()                    { *m = ResolveImageConfigRequest{} }
@@ -60,6 +61,13 @@ func (m *ResolveImageConfigRequest) GetRef() string {
 	return ""
 }
 
+func (m *ResolveImageConfigRequest) GetPlatform() *pb.Platform {
+	if m != nil {
+		return m.Platform
+	}
+	return nil
+}
+
 type ResolveImageConfigResponse struct {
 	Digest github_com_opencontainers_go_digest.Digest `protobuf:"bytes,1,opt,name=Digest,proto3,customtype=github.com/opencontainers/go-digest.Digest" json:"Digest"`
 	Config []byte                                     `protobuf:"bytes,2,opt,name=Config,proto3" json:"Config,omitempty"`
@@ -451,6 +459,16 @@ func (m *ResolveImageConfigRequest) MarshalTo(dAtA []byte) (int, error) {
 		i = encodeVarintGateway(dAtA, i, uint64(len(m.Ref)))
 		i += copy(dAtA[i:], m.Ref)
 	}
+	if m.Platform != nil {
+		dAtA[i] = 0x12
+		i++
+		i = encodeVarintGateway(dAtA, i, uint64(m.Platform.Size()))
+		n1, err := m.Platform.MarshalTo(dAtA[i:])
+		if err != nil {
+			return 0, err
+		}
+		i += n1
+	}
 	return i, nil
 }
 
@@ -503,11 +521,11 @@ func (m *SolveRequest) MarshalTo(dAtA []byte) (int, error) {
 		dAtA[i] = 0xa
 		i++
 		i = encodeVarintGateway(dAtA, i, uint64(m.Definition.Size()))
-		n1, err := m.Definition.MarshalTo(dAtA[i:])
+		n2, err := m.Definition.MarshalTo(dAtA[i:])
 		if err != nil {
 			return 0, err
 		}
-		i += n1
+		i += n2
 	}
 	if len(m.Frontend) > 0 {
 		dAtA[i] = 0x12
@@ -627,11 +645,11 @@ func (m *ReadFileRequest) MarshalTo(dAtA []byte) (int, error) {
 		dAtA[i] = 0x1a
 		i++
 		i = encodeVarintGateway(dAtA, i, uint64(m.Range.Size()))
-		n2, err := m.Range.MarshalTo(dAtA[i:])
+		n3, err := m.Range.MarshalTo(dAtA[i:])
 		if err != nil {
 			return 0, err
 		}
-		i += n2
+		i += n3
 	}
 	return i, nil
 }
@@ -740,6 +758,10 @@ func (m *ResolveImageConfigRequest) Size() (n int) {
 	if l > 0 {
 		n += 1 + l + sovGateway(uint64(l))
 	}
+	if m.Platform != nil {
+		l = m.Platform.Size()
+		n += 1 + l + sovGateway(uint64(l))
+	}
 	return n
 }
 
@@ -929,6 +951,39 @@ func (m *ResolveImageConfigRequest) Unmarshal(dAtA []byte) error {
 			}
 			m.Ref = string(dAtA[iNdEx:postIndex])
 			iNdEx = postIndex
+		case 2:
+			if wireType != 2 {
+				return fmt.Errorf("proto: wrong wireType = %d for field Platform", wireType)
+			}
+			var msglen int
+			for shift := uint(0); ; shift += 7 {
+				if shift >= 64 {
+					return ErrIntOverflowGateway
+				}
+				if iNdEx >= l {
+					return io.ErrUnexpectedEOF
+				}
+				b := dAtA[iNdEx]
+				iNdEx++
+				msglen |= (int(b) & 0x7F) << shift
+				if b < 0x80 {
+					break
+				}
+			}
+			if msglen < 0 {
+				return ErrInvalidLengthGateway
+			}
+			postIndex := iNdEx + msglen
+			if postIndex > l {
+				return io.ErrUnexpectedEOF
+			}
+			if m.Platform == nil {
+				m.Platform = &pb.Platform{}
+			}
+			if err := m.Platform.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+				return err
+			}
+			iNdEx = postIndex
 		default:
 			iNdEx = preIndex
 			skippy, err := skipGateway(dAtA[iNdEx:])
@@ -1998,45 +2053,46 @@ var (
 func init() { proto.RegisterFile("gateway.proto", fileDescriptorGateway) }
 
 var fileDescriptorGateway = []byte{
-	// 629 bytes of a gzipped FileDescriptorProto
-	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0x4d, 0x4f, 0xdb, 0x40,
-	0x10, 0xad, 0x63, 0x40, 0x64, 0x12, 0x3e, 0xb4, 0xaa, 0x2a, 0xe3, 0x03, 0x44, 0x56, 0x45, 0x2d,
-	0x5a, 0x6c, 0x35, 0x6d, 0x25, 0x44, 0xa5, 0x4a, 0x0d, 0x1f, 0x12, 0x15, 0x12, 0x68, 0x7b, 0xa8,
-	0xc4, 0xcd, 0x4e, 0xc6, 0x66, 0x45, 0xb2, 0xeb, 0xda, 0x1b, 0xda, 0xa8, 0x97, 0xf6, 0xe7, 0xf4,
-	0x9f, 0x70, 0xec, 0x99, 0x03, 0xaa, 0xf8, 0x25, 0x95, 0xd7, 0xeb, 0x60, 0x48, 0x49, 0xe9, 0x6d,
-	0xdf, 0x78, 0xe6, 0xed, 0x9b, 0x79, 0xb3, 0x86, 0x85, 0x38, 0x90, 0xf8, 0x25, 0x18, 0x79, 0x49,
-	0x2a, 0xa4, 0x20, 0x2b, 0x03, 0x11, 0x8e, 0xbc, 0x70, 0xc8, 0xfa, 0xbd, 0x33, 0x26, 0xbd, 0xf3,
-	0x97, 0x5e, 0x94, 0x0a, 0x2e, 0x91, 0xf7, 0xec, 0xcd, 0x98, 0xc9, 0xd3, 0x61, 0xe8, 0x75, 0xc5,
-	0xc0, 0x8f, 0x45, 0x2c, 0x7c, 0x55, 0x11, 0x0e, 0x23, 0x85, 0x14, 0x50, 0xa7, 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, 0xb3, 0x00, 0x8d, 0x63, 0xc6, 0xcb, 0x97, 0xe2, 0x2c,
-	0x42, 0xf3, 0x58, 0xf0, 0xf1, 0x43, 0x68, 0xff, 0x34, 0xa1, 0x7e, 0x78, 0xd8, 0xe9, 0xa4, 0xac,
-	0x17, 0x23, 0xf9, 0x61, 0x00, 0x99, 0x7c, 0x35, 0xe4, 0xf5, 0x94, 0xae, 0xee, 0x7d, 0x94, 0xf6,
-	0x9b, 0xff, 0xac, 0xd2, 0x4d, 0x9c, 0xc0, 0xac, 0x72, 0x96, 0x3c, 0x7b, 0xe0, 0x36, 0xdb, 0xee,
-	0xbf, 0x13, 0x35, 0x77, 0x17, 0xe6, 0xcb, 0xa1, 0x91, 0x8d, 0xa9, 0xf2, 0x6e, 0xed, 0x84, 0xfd,
-	0xfc, 0x41, 0xb9, 0xfa, 0x92, 0x4f, 0x30, 0x93, 0x4f, 0x9c, 0xac, 0x4f, 0x29, 0xaa, 0x58, 0x62,
-	0x4f, 0xeb, 0xb3, 0xea, 0x55, 0xa7, 0x79, 0x71, 0xbd, 0x6a, 0xfc, 0xba, 0x5e, 0x35, 0x7e, 0x5f,
-	0xaf, 0x1a, 0xe1, 0x9c, 0xfa, 0x2f, 0xbe, 0xfa, 0x13, 0x00, 0x00, 0xff, 0xff, 0xd8, 0x21, 0xd1,
-	0x98, 0xa0, 0x05, 0x00, 0x00,
+	// 652 bytes of a gzipped FileDescriptorProto
+	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0x4d, 0x4f, 0xdb, 0x4a,
+	0x14, 0x7d, 0x8e, 0x01, 0x25, 0x37, 0xe6, 0x43, 0xa3, 0xa7, 0x27, 0xe3, 0x05, 0x44, 0xd6, 0x13,
+	0xcf, 0xe2, 0x15, 0x5b, 0x4d, 0x5b, 0x09, 0x51, 0xa9, 0x52, 0xc3, 0x87, 0x44, 0x85, 0x44, 0x34,
+	0x5d, 0x20, 0xb1,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 0x86, 0x36,
+	0x67, 0xca, 0xbb, 0x33, 0x13, 0xce, 0xff, 0x4f, 0xca, 0xd5, 0x97, 0x9c, 0xc0, 0x5c, 0xf1, 0xe2,
+	0x68, 0x63, 0x46, 0x51, 0xcd, 0x12, 0x67, 0x56, 0x9f, 0x75, 0xaf, 0x7a, 0xd6, 0xe5, 0xcd, 0x9a,
+	0xf1, 0xfd, 0x66, 0xcd, 0xf8, 0x71, 0xb3, 0x66, 0x84, 0x0b, 0xea, 0x0f, 0xfa, 0xe2, 0x67, 0x00,
+	0x00, 0x00, 0xff, 0xff, 0xbc, 0x68, 0x1b, 0xf0, 0xca, 0x05, 0x00, 0x00,
 }

+ 1 - 0
vendor/github.com/moby/buildkit/frontend/gateway/pb/gateway.proto

@@ -18,6 +18,7 @@ service LLBBridge {
 
 message ResolveImageConfigRequest {
 	string Ref = 1;
+	pb.Platform Platform = 2;
 }
 
 message ResolveImageConfigResponse {

+ 5 - 3
vendor/github.com/moby/buildkit/solver/llbsolver/bridge.go

@@ -15,6 +15,7 @@ import (
 	"github.com/moby/buildkit/util/tracing"
 	"github.com/moby/buildkit/worker"
 	digest "github.com/opencontainers/go-digest"
+	specs "github.com/opencontainers/image-spec/specs-go/v1"
 	"github.com/pkg/errors"
 )
 
@@ -25,6 +26,7 @@ type llbBridge struct {
 	ci            *remotecache.CacheImporter
 	cms           map[string]solver.CacheManager
 	cmsMu         sync.Mutex
+	platforms     []specs.Platform
 }
 
 func (b *llbBridge) Solve(ctx context.Context, req frontend.SolveRequest) (res solver.CachedResult, exp map[string][]byte, err error) {
@@ -59,7 +61,7 @@ func (b *llbBridge) Solve(ctx context.Context, req frontend.SolveRequest) (res s
 	}
 
 	if req.Definition != nil && req.Definition.Def != nil {
-		edge, err := Load(req.Definition, WithCacheSources(cms))
+		edge, err := Load(req.Definition, WithCacheSources(cms), RuntimePlatforms(b.platforms))
 		if err != nil {
 			return nil, nil, err
 		}
@@ -108,12 +110,12 @@ func (s *llbBridge) Exec(ctx context.Context, meta executor.Meta, root cache.Imm
 	return err
 }
 
-func (s *llbBridge) ResolveImageConfig(ctx context.Context, ref string) (digest.Digest, []byte, error) {
+func (s *llbBridge) ResolveImageConfig(ctx context.Context, ref string, platform *specs.Platform) (digest.Digest, []byte, error) {
 	w, err := s.resolveWorker()
 	if err != nil {
 		return "", nil, err
 	}
-	return w.ResolveImageConfig(ctx, ref)
+	return w.ResolveImageConfig(ctx, ref, platform)
 }
 
 type lazyCacheManager struct {

+ 71 - 23
vendor/github.com/moby/buildkit/solver/llbsolver/ops/exec.go

@@ -11,9 +11,11 @@ import (
 	"sort"
 	"strings"
 	"sync"
+	"time"
 
 	"github.com/boltdb/bolt"
 	"github.com/containerd/containerd/mount"
+	"github.com/docker/docker/pkg/locker"
 	"github.com/moby/buildkit/cache"
 	"github.com/moby/buildkit/cache/metadata"
 	"github.com/moby/buildkit/executor"
@@ -37,16 +39,19 @@ type execOp struct {
 	exec      executor.Executor
 	w         worker.Worker
 	numInputs int
+
+	cacheMounts map[string]*cacheRefShare
 }
 
 func NewExecOp(v solver.Vertex, op *pb.Op_Exec, cm cache.Manager, md *metadata.Store, exec executor.Executor, w worker.Worker) (solver.Op, error) {
 	return &execOp{
-		op:        op.Exec,
-		cm:        cm,
-		md:        md,
-		exec:      exec,
-		numInputs: len(v.Inputs()),
-		w:         w,
+		op:          op.Exec,
+		cm:          cm,
+		md:          md,
+		exec:        exec,
+		numInputs:   len(v.Inputs()),
+		w:           w,
+		cacheMounts: map[string]*cacheRefShare{},
 	}, nil
 }
 
@@ -165,32 +170,72 @@ func (e *execOp) getMountDeps() ([]dep, error) {
 	return deps, nil
 }
 
-func (e *execOp) getRefCacheDir(ctx context.Context, ref cache.ImmutableRef, id string, m *pb.Mount) (cache.MutableRef, error) {
+func (e *execOp) getRefCacheDir(ctx context.Context, ref cache.ImmutableRef, id string, m *pb.Mount, sharing pb.CacheSharingOpt) (mref cache.MutableRef, err error) {
 
 	key := "cache-dir:" + id
 	if ref != nil {
 		key += ":" + ref.ID()
 	}
 
-	return sharedCacheRefs.get(key, func() (cache.MutableRef, error) {
-		return e.getRefCacheDirNoCache(ctx, key, ref, id, m)
-	})
+	if ref, ok := e.cacheMounts[key]; ok {
+		return ref.clone(), nil
+	}
+	defer func() {
+		if err == nil {
+			share := &cacheRefShare{MutableRef: mref, refs: map[*cacheRef]struct{}{}}
+			e.cacheMounts[key] = share
+			mref = share.clone()
+		}
+	}()
+
+	switch sharing {
+	case pb.CacheSharingOpt_SHARED:
+		return sharedCacheRefs.get(key, func() (cache.MutableRef, error) {
+			return e.getRefCacheDirNoCache(ctx, key, ref, id, m, false)
+		})
+	case pb.CacheSharingOpt_PRIVATE:
+		return e.getRefCacheDirNoCache(ctx, key, ref, id, m, false)
+	case pb.CacheSharingOpt_LOCKED:
+		return e.getRefCacheDirNoCache(ctx, key, ref, id, m, true)
+	default:
+		return nil, errors.Errorf("invalid cache sharing option: %s", sharing.String())
+	}
+
 }
 
-func (e *execOp) getRefCacheDirNoCache(ctx context.Context, key string, ref cache.ImmutableRef, id string, m *pb.Mount) (cache.MutableRef, error) {
+func (e *execOp) getRefCacheDirNoCache(ctx context.Context, key string, ref cache.ImmutableRef, id string, m *pb.Mount, block bool) (cache.MutableRef, error) {
 	makeMutable := func(cache.ImmutableRef) (cache.MutableRef, error) {
 		desc := fmt.Sprintf("cached mount %s from exec %s", m.Dest, strings.Join(e.op.Meta.Args, " "))
 		return e.cm.New(ctx, ref, cache.WithDescription(desc), cache.CachePolicyRetain)
 	}
 
-	sis, err := e.md.Search(key)
-	if err != nil {
-		return nil, err
-	}
-	for _, si := range sis {
-		if mRef, err := e.cm.GetMutable(ctx, si.ID()); err == nil {
-			logrus.Debugf("reusing ref for cache dir: %s", mRef.ID())
-			return mRef, nil
+	cacheRefsLocker.Lock(key)
+	defer cacheRefsLocker.Unlock(key)
+	for {
+		sis, err := e.md.Search(key)
+		if err != nil {
+			return nil, err
+		}
+		locked := false
+		for _, si := range sis {
+			if mRef, err := e.cm.GetMutable(ctx, si.ID()); err == nil {
+				logrus.Debugf("reusing ref for cache dir: %s", mRef.ID())
+				return mRef, nil
+			} else if errors.Cause(err) == cache.ErrLocked {
+				locked = true
+			}
+		}
+		if block && locked {
+			cacheRefsLocker.Unlock(key)
+			select {
+			case <-ctx.Done():
+				cacheRefsLocker.Lock(key)
+				return nil, ctx.Err()
+			case <-time.After(100 * time.Millisecond):
+				cacheRefsLocker.Lock(key)
+			}
+		} else {
+			break
 		}
 	}
 	mRef, err := makeMutable(ref)
@@ -287,7 +332,7 @@ func (e *execOp) Exec(ctx context.Context, inputs []solver.Result) ([]solver.Res
 			if m.CacheOpt == nil {
 				return nil, errors.Errorf("missing cache mount options")
 			}
-			mRef, err := e.getRefCacheDir(ctx, ref, m.CacheOpt.ID, m)
+			mRef, err := e.getRefCacheDir(ctx, ref, m.CacheOpt.ID, m, m.CacheOpt.Sharing)
 			if err != nil {
 				return nil, err
 			}
@@ -418,6 +463,7 @@ func (m *tmpfsMount) Release() error {
 	return nil
 }
 
+var cacheRefsLocker = locker.New()
 var sharedCacheRefs = &cacheRefs{}
 
 type cacheRefs struct {
@@ -466,9 +512,11 @@ func (r *cacheRefShare) clone() cache.MutableRef {
 }
 
 func (r *cacheRefShare) release(ctx context.Context) error {
-	r.main.mu.Lock()
-	defer r.main.mu.Unlock()
-	delete(r.main.shares, r.key)
+	if r.main != nil {
+		r.main.mu.Lock()
+		defer r.main.mu.Unlock()
+		delete(r.main.shares, r.key)
+	}
 	return r.MutableRef.Release(ctx)
 }
 

+ 12 - 10
vendor/github.com/moby/buildkit/solver/llbsolver/ops/source.go

@@ -14,18 +14,20 @@ import (
 const sourceCacheType = "buildkit.source.v0"
 
 type sourceOp struct {
-	mu  sync.Mutex
-	op  *pb.Op_Source
-	sm  *source.Manager
-	src source.SourceInstance
-	w   worker.Worker
+	mu       sync.Mutex
+	op       *pb.Op_Source
+	platform *pb.Platform
+	sm       *source.Manager
+	src      source.SourceInstance
+	w        worker.Worker
 }
 
-func NewSourceOp(_ solver.Vertex, op *pb.Op_Source, sm *source.Manager, w worker.Worker) (solver.Op, error) {
+func NewSourceOp(_ solver.Vertex, op *pb.Op_Source, platform *pb.Platform, sm *source.Manager, w worker.Worker) (solver.Op, error) {
 	return &sourceOp{
-		op: op,
-		sm: sm,
-		w:  w,
+		op:       op,
+		sm:       sm,
+		w:        w,
+		platform: platform,
 	}, nil
 }
 
@@ -35,7 +37,7 @@ func (s *sourceOp) instance(ctx context.Context) (source.SourceInstance, error)
 	if s.src != nil {
 		return s.src, nil
 	}
-	id, err := source.FromLLB(s.op)
+	id, err := source.FromLLB(s.op, s.platform)
 	if err != nil {
 		return nil, err
 	}

+ 12 - 2
vendor/github.com/moby/buildkit/solver/llbsolver/solver.go

@@ -13,6 +13,7 @@ import (
 	"github.com/moby/buildkit/solver"
 	"github.com/moby/buildkit/util/progress"
 	"github.com/moby/buildkit/worker"
+	specs "github.com/opencontainers/image-spec/specs-go/v1"
 	"github.com/pkg/errors"
 )
 
@@ -30,9 +31,10 @@ type Solver struct {
 	resolveWorker ResolveWorkerFunc
 	frontends     map[string]frontend.Frontend
 	ci            *remotecache.CacheImporter
+	platforms     []specs.Platform
 }
 
-func New(wc *worker.Controller, f map[string]frontend.Frontend, cacheStore solver.CacheKeyStorage, ci *remotecache.CacheImporter) *Solver {
+func New(wc *worker.Controller, f map[string]frontend.Frontend, cacheStore solver.CacheKeyStorage, ci *remotecache.CacheImporter) (*Solver, error) {
 	s := &Solver{
 		resolveWorker: defaultResolver(wc),
 		frontends:     f,
@@ -43,11 +45,18 @@ func New(wc *worker.Controller, f map[string]frontend.Frontend, cacheStore solve
 
 	cache := solver.NewCacheManager("local", cacheStore, results)
 
+	// executing is currently only allowed on default worker
+	w, err := wc.GetDefault()
+	if err != nil {
+		return nil, err
+	}
+	s.platforms = w.Platforms()
+
 	s.solver = solver.NewSolver(solver.SolverOpt{
 		ResolveOpFunc: s.resolver(),
 		DefaultCache:  cache,
 	})
-	return s
+	return s, nil
 }
 
 func (s *Solver) resolver() solver.ResolveOpFunc {
@@ -67,6 +76,7 @@ func (s *Solver) Bridge(b solver.Builder) frontend.FrontendLLBBridge {
 		resolveWorker: s.resolveWorker,
 		ci:            s.ci,
 		cms:           map[string]solver.CacheManager{},
+		platforms:     s.platforms,
 	}
 }
 

+ 42 - 5
vendor/github.com/moby/buildkit/solver/llbsolver/vertex.go

@@ -3,10 +3,12 @@ package llbsolver
 import (
 	"strings"
 
+	"github.com/containerd/containerd/platforms"
 	"github.com/moby/buildkit/solver"
 	"github.com/moby/buildkit/solver/pb"
 	"github.com/moby/buildkit/source"
 	digest "github.com/opencontainers/go-digest"
+	specs "github.com/opencontainers/image-spec/specs-go/v1"
 	"github.com/pkg/errors"
 )
 
@@ -38,11 +40,44 @@ func (v *vertex) Name() string {
 	return v.name
 }
 
-type LoadOpt func(*solver.VertexOptions)
+type LoadOpt func(*pb.Op, *pb.OpMetadata, *solver.VertexOptions) error
 
 func WithCacheSources(cms []solver.CacheManager) LoadOpt {
-	return func(opt *solver.VertexOptions) {
+	return func(_ *pb.Op, _ *pb.OpMetadata, opt *solver.VertexOptions) error {
 		opt.CacheSources = cms
+		return nil
+	}
+}
+
+func RuntimePlatforms(p []specs.Platform) LoadOpt {
+	var defaultPlatform *pb.Platform
+	for i := range p {
+		p[i] = platforms.Normalize(p[i])
+	}
+	return func(op *pb.Op, _ *pb.OpMetadata, opt *solver.VertexOptions) error {
+		if op.Platform == nil {
+			if defaultPlatform == nil {
+				p := platforms.DefaultSpec()
+				defaultPlatform = &pb.Platform{
+					OS:           p.OS,
+					Architecture: p.Architecture,
+				}
+			}
+			op.Platform = defaultPlatform
+		}
+		if _, ok := op.Op.(*pb.Op_Exec); ok {
+			var found bool
+			for _, pp := range p {
+				if pp.OS == op.Platform.OS && pp.Architecture == op.Platform.Architecture && pp.Variant == op.Platform.Variant {
+					found = true
+					break
+				}
+			}
+			if !found {
+				return errors.Errorf("runtime execution on platform %s not supported", platforms.Format(specs.Platform{OS: op.Platform.OS, Architecture: op.Platform.Architecture, Variant: op.Platform.Variant}))
+			}
+		}
+		return nil
 	}
 }
 
@@ -67,9 +102,11 @@ func newVertex(dgst digest.Digest, op *pb.Op, opMeta *pb.OpMetadata, load func(d
 		}
 	}
 	for _, fn := range opts {
-		fn(&opt)
+		if err := fn(op, opMeta, &opt); err != nil {
+			return nil, err
+		}
 	}
-	vtx := &vertex{sys: op.Op, options: opt, digest: dgst, name: llbOpName(op)}
+	vtx := &vertex{sys: op, options: opt, digest: dgst, name: llbOpName(op)}
 	for _, in := range op.Inputs {
 		sub, err := load(in.Digest)
 		if err != nil {
@@ -129,7 +166,7 @@ func loadLLB(def *pb.Definition, fn func(digest.Digest, *pb.Op, func(digest.Dige
 func llbOpName(op *pb.Op) string {
 	switch op := op.Op.(type) {
 	case *pb.Op_Source:
-		if id, err := source.FromLLB(op); err == nil {
+		if id, err := source.FromLLB(op, nil); err == nil {
 			if id, ok := id.(*source.LocalIdentifier); ok {
 				if len(id.IncludePatterns) == 1 {
 					return op.Source.Identifier + " (" + id.IncludePatterns[0] + ")"

File diff suppressed because it is too large
+ 543 - 73
vendor/github.com/moby/buildkit/solver/pb/ops.pb.go


+ 32 - 5
vendor/github.com/moby/buildkit/solver/pb/ops.proto

@@ -15,7 +15,18 @@ message Op {
 		SourceOp source = 3;
 		CopyOp copy = 4;
 		BuildOp build = 5;
-	 }
+	}
+	Platform platform = 10;
+	WorkerConstraints constraints = 11;
+}
+
+// Platform is github.com/opencontainers/image-spec/specs-go/v1.Platform
+message Platform {
+	string Architecture = 1;
+	string OS = 2;
+	string Variant = 3;
+	string OSVersion = 4; // unused
+	repeated string OSFeatures = 5; // unused
 }
 
 // Input represents an input edge for an Op.
@@ -54,6 +65,7 @@ message Mount {
 	CacheOpt cacheOpt = 20;
 }
 
+// MountType defines a type of a mount from a supported set
 enum MountType {
 	BIND = 0;
 	SECRET = 1;
@@ -62,8 +74,22 @@ enum MountType {
 	TMPFS = 4;
 }
 
+// CacheOpt defines options specific to cache mounts
 message CacheOpt {
+	// ID is an optional namespace for the mount
 	string ID = 1;
+	// Sharing is the sharing mode for the mount 
+	CacheSharingOpt sharing = 2;
+}
+
+// CacheSharingOpt defines different sharing modes for cache mount
+enum CacheSharingOpt {
+	// SHARED cache mount can be used concurrently by multiple writers
+	SHARED = 0;
+	// PRIVATE creates a new mount if there are multiple writers
+	PRIVATE = 1;
+	// LOCKED pauses second writer until first one releases the mount
+	LOCKED = 2;
 }
 
 // CopyOp copies files across Ops.
@@ -106,8 +132,9 @@ message OpMetadata {
 	// ignore_cache specifies to ignore the cache for this Op.
 	bool ignore_cache = 1;
 	// Description can be used for keeping any text fields that builder doesn't parse
-	map<string, string> description = 2;  
-	WorkerConstraint worker_constraint = 3;
+	map<string, string> description = 2; 
+	// index 3 reserved for WorkerConstraint in previous versions
+	// WorkerConstraint worker_constraint = 3;
 	ExportCache export_cache = 4;
 }
 
@@ -122,8 +149,8 @@ message ProxyEnv {
 	string no_proxy = 4;
 }
 
-// WorkerConstraint is experimental and likely to be changed.
-message WorkerConstraint {
+// WorkerConstraints defines conditions for the worker
+message WorkerConstraints {
 	repeated string filter = 1; // containerd-style filter
 }
 

+ 12 - 1
vendor/github.com/moby/buildkit/source/identifier.go

@@ -8,6 +8,7 @@ import (
 	"github.com/containerd/containerd/reference"
 	"github.com/moby/buildkit/solver/pb"
 	digest "github.com/opencontainers/go-digest"
+	specs "github.com/opencontainers/image-spec/specs-go/v1"
 	"github.com/pkg/errors"
 )
 
@@ -50,11 +51,20 @@ func FromString(s string) (Identifier, error) {
 		return nil, errors.Wrapf(errNotFound, "unknown schema %s", parts[0])
 	}
 }
-func FromLLB(op *pb.Op_Source) (Identifier, error) {
+func FromLLB(op *pb.Op_Source, platform *pb.Platform) (Identifier, error) {
 	id, err := FromString(op.Source.Identifier)
 	if err != nil {
 		return nil, err
 	}
+	if id, ok := id.(*ImageIdentifier); ok && platform != nil {
+		id.Platform = &specs.Platform{
+			OS:           platform.OS,
+			Architecture: platform.Architecture,
+			Variant:      platform.Variant,
+			OSVersion:    platform.OSVersion,
+			OSFeatures:   platform.OSFeatures,
+		}
+	}
 	if id, ok := id.(*GitIdentifier); ok {
 		for k, v := range op.Source.Attrs {
 			switch k {
@@ -136,6 +146,7 @@ func FromLLB(op *pb.Op_Source) (Identifier, error) {
 
 type ImageIdentifier struct {
 	Reference reference.Spec
+	Platform  *specs.Platform
 }
 
 func NewImageIdentifier(str string) (*ImageIdentifier, error) {

+ 17 - 15
vendor/github.com/moby/buildkit/util/imageutil/config.go

@@ -10,7 +10,7 @@ import (
 	"github.com/containerd/containerd/reference"
 	"github.com/containerd/containerd/remotes"
 	digest "github.com/opencontainers/go-digest"
-	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
+	specs "github.com/opencontainers/image-spec/specs-go/v1"
 	"github.com/pkg/errors"
 )
 
@@ -19,16 +19,18 @@ type IngesterProvider interface {
 	content.Provider
 }
 
-func Config(ctx context.Context, str string, resolver remotes.Resolver, ingester IngesterProvider, platform string) (digest.Digest, []byte, error) {
-	if platform == "" {
-		platform = platforms.Default()
+func Config(ctx context.Context, str string, resolver remotes.Resolver, ingester IngesterProvider, platform *specs.Platform) (digest.Digest, []byte, error) {
+	// TODO: fix containerd to take struct instead of string
+	platformStr := platforms.Default()
+	if platform != nil {
+		platformStr = platforms.Format(*platform)
 	}
 	ref, err := reference.Parse(str)
 	if err != nil {
 		return "", nil, errors.WithStack(err)
 	}
 
-	desc := ocispec.Descriptor{
+	desc := specs.Descriptor{
 		Digest: ref.Digest(),
 	}
 	if desc.Digest != "" {
@@ -56,12 +58,12 @@ func Config(ctx context.Context, str string, resolver remotes.Resolver, ingester
 
 	handlers := []images.Handler{
 		remotes.FetchHandler(ingester, fetcher),
-		childrenConfigHandler(ingester, platform),
+		childrenConfigHandler(ingester, platformStr),
 	}
 	if err := images.Dispatch(ctx, images.Handlers(handlers...), desc); err != nil {
 		return "", nil, err
 	}
-	config, err := images.Config(ctx, ingester, desc, platform)
+	config, err := images.Config(ctx, ingester, desc, platformStr)
 	if err != nil {
 		return "", nil, err
 	}
@@ -75,10 +77,10 @@ func Config(ctx context.Context, str string, resolver remotes.Resolver, ingester
 }
 
 func childrenConfigHandler(provider content.Provider, platform string) images.HandlerFunc {
-	return func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
-		var descs []ocispec.Descriptor
+	return func(ctx context.Context, desc specs.Descriptor) ([]specs.Descriptor, error) {
+		var descs []specs.Descriptor
 		switch desc.MediaType {
-		case images.MediaTypeDockerSchema2Manifest, ocispec.MediaTypeImageManifest:
+		case images.MediaTypeDockerSchema2Manifest, specs.MediaTypeImageManifest:
 			p, err := content.ReadBlob(ctx, provider, desc)
 			if err != nil {
 				return nil, err
@@ -86,19 +88,19 @@ func childrenConfigHandler(provider content.Provider, platform string) images.Ha
 
 			// TODO(stevvooe): We just assume oci manifest, for now. There may be
 			// subtle differences from the docker version.
-			var manifest ocispec.Manifest
+			var manifest specs.Manifest
 			if err := json.Unmarshal(p, &manifest); err != nil {
 				return nil, err
 			}
 
 			descs = append(descs, manifest.Config)
-		case images.MediaTypeDockerSchema2ManifestList, ocispec.MediaTypeImageIndex:
+		case images.MediaTypeDockerSchema2ManifestList, specs.MediaTypeImageIndex:
 			p, err := content.ReadBlob(ctx, provider, desc)
 			if err != nil {
 				return nil, err
 			}
 
-			var index ocispec.Index
+			var index specs.Index
 			if err := json.Unmarshal(p, &index); err != nil {
 				return nil, err
 			}
@@ -118,7 +120,7 @@ func childrenConfigHandler(provider content.Provider, platform string) images.Ha
 			} else {
 				descs = append(descs, index.Manifests...)
 			}
-		case images.MediaTypeDockerSchema2Config, ocispec.MediaTypeImageConfig:
+		case images.MediaTypeDockerSchema2Config, specs.MediaTypeImageConfig:
 			// childless data types.
 			return nil, nil
 		default:
@@ -129,7 +131,7 @@ func childrenConfigHandler(provider content.Provider, platform string) images.Ha
 	}
 }
 
-// ocispec.MediaTypeImageManifest, // TODO: detect schema1/manifest-list
+// specs.MediaTypeImageManifest, // TODO: detect schema1/manifest-list
 func DetectManifestMediaType(ra content.ReaderAt) (string, error) {
 	// TODO: schema1
 

+ 1 - 1
vendor/github.com/moby/buildkit/vendor.conf

@@ -6,7 +6,7 @@ github.com/davecgh/go-spew v1.1.0
 github.com/pmezard/go-difflib v1.0.0
 golang.org/x/sys 314a259e304ff91bd6985da2a7149bbf91237993
 
-github.com/containerd/containerd 63522d9eaa5a0443d225642c4b6f4f5fdedf932b
+github.com/containerd/containerd 08f7ee9828af1783dc98cc5cc1739e915697c667
 github.com/containerd/typeurl f6943554a7e7e88b3c14aad190bf05932da84788
 golang.org/x/sync 450f422ab23cf9881c94e2db30cac0eb1b7cf80c
 github.com/sirupsen/logrus v1.0.0

+ 3 - 3
vendor/github.com/moby/buildkit/worker/worker.go

@@ -11,16 +11,18 @@ import (
 	"github.com/moby/buildkit/frontend"
 	"github.com/moby/buildkit/solver"
 	digest "github.com/opencontainers/go-digest"
+	specs "github.com/opencontainers/image-spec/specs-go/v1"
 )
 
 type Worker interface {
 	// ID needs to be unique in the cluster
 	ID() string
 	Labels() map[string]string
+	Platforms() []specs.Platform
 	LoadRef(id string) (cache.ImmutableRef, error)
 	// ResolveOp resolves Vertex.Sys() to Op implementation.
 	ResolveOp(v solver.Vertex, s frontend.FrontendLLBBridge) (solver.Op, error)
-	ResolveImageConfig(ctx context.Context, ref string) (digest.Digest, []byte, error)
+	ResolveImageConfig(ctx context.Context, ref string, platform *specs.Platform) (digest.Digest, []byte, error)
 	// Exec is similar to executor.Exec but without []mount.Mount
 	Exec(ctx context.Context, meta executor.Meta, rootFS cache.ImmutableRef, stdin io.ReadCloser, stdout, stderr io.WriteCloser) error
 	DiskUsage(ctx context.Context, opt client.DiskUsageInfo) ([]*client.UsageInfo, error)
@@ -33,8 +35,6 @@ type Worker interface {
 // Pre-defined label keys
 const (
 	labelPrefix      = "org.mobyproject.buildkit.worker."
-	LabelOS          = labelPrefix + "os"          // GOOS
-	LabelArch        = labelPrefix + "arch"        // GOARCH
 	LabelExecutor    = labelPrefix + "executor"    // "oci" or "containerd"
 	LabelSnapshotter = labelPrefix + "snapshotter" // containerd snapshotter name ("overlay", "native", ...)
 	LabelHostname    = labelPrefix + "hostname"

Some files were not shown because too many files changed in this diff