cache: allow pushing exported cache

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
docker-18.09
Tonis Tiigi 2017-10-13 11:54:26 -07:00
parent 451be0e504
commit 56e1f71e6b
10 changed files with 498 additions and 125 deletions

View File

@ -1,5 +1,6 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// Code generated by protoc-gen-gogo.
// source: control.proto
// DO NOT EDIT!
/*
Package moby_buildkit_v1 is a generated protocol buffer package.
@ -12,6 +13,7 @@
DiskUsageResponse
UsageRecord
SolveRequest
CacheOptions
SolveResponse
StatusRequest
StatusResponse
@ -173,6 +175,7 @@ type SolveRequest struct {
Session string `protobuf:"bytes,5,opt,name=Session,proto3" json:"Session,omitempty"`
Frontend string `protobuf:"bytes,6,opt,name=Frontend,proto3" json:"Frontend,omitempty"`
FrontendAttrs map[string]string `protobuf:"bytes,7,rep,name=FrontendAttrs" json:"FrontendAttrs,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
Cache CacheOptions `protobuf:"bytes,8,opt,name=Cache" json:"Cache"`
}
func (m *SolveRequest) Reset() { *m = SolveRequest{} }
@ -229,6 +232,37 @@ func (m *SolveRequest) GetFrontendAttrs() map[string]string {
return nil
}
func (m *SolveRequest) GetCache() CacheOptions {
if m != nil {
return m.Cache
}
return CacheOptions{}
}
type CacheOptions struct {
ExportRef string `protobuf:"bytes,1,opt,name=ExportRef,proto3" json:"ExportRef,omitempty"`
ImportRef string `protobuf:"bytes,2,opt,name=ImportRef,proto3" json:"ImportRef,omitempty"`
}
func (m *CacheOptions) Reset() { *m = CacheOptions{} }
func (m *CacheOptions) String() string { return proto.CompactTextString(m) }
func (*CacheOptions) ProtoMessage() {}
func (*CacheOptions) Descriptor() ([]byte, []int) { return fileDescriptorControl, []int{4} }
func (m *CacheOptions) GetExportRef() string {
if m != nil {
return m.ExportRef
}
return ""
}
func (m *CacheOptions) GetImportRef() string {
if m != nil {
return m.ImportRef
}
return ""
}
type SolveResponse struct {
Vtx []*Vertex `protobuf:"bytes,1,rep,name=vtx" json:"vtx,omitempty"`
}
@ -236,7 +270,7 @@ type SolveResponse struct {
func (m *SolveResponse) Reset() { *m = SolveResponse{} }
func (m *SolveResponse) String() string { return proto.CompactTextString(m) }
func (*SolveResponse) ProtoMessage() {}
func (*SolveResponse) Descriptor() ([]byte, []int) { return fileDescriptorControl, []int{4} }
func (*SolveResponse) Descriptor() ([]byte, []int) { return fileDescriptorControl, []int{5} }
func (m *SolveResponse) GetVtx() []*Vertex {
if m != nil {
@ -252,7 +286,7 @@ type StatusRequest struct {
func (m *StatusRequest) Reset() { *m = StatusRequest{} }
func (m *StatusRequest) String() string { return proto.CompactTextString(m) }
func (*StatusRequest) ProtoMessage() {}
func (*StatusRequest) Descriptor() ([]byte, []int) { return fileDescriptorControl, []int{5} }
func (*StatusRequest) Descriptor() ([]byte, []int) { return fileDescriptorControl, []int{6} }
func (m *StatusRequest) GetRef() string {
if m != nil {
@ -270,7 +304,7 @@ type StatusResponse struct {
func (m *StatusResponse) Reset() { *m = StatusResponse{} }
func (m *StatusResponse) String() string { return proto.CompactTextString(m) }
func (*StatusResponse) ProtoMessage() {}
func (*StatusResponse) Descriptor() ([]byte, []int) { return fileDescriptorControl, []int{6} }
func (*StatusResponse) Descriptor() ([]byte, []int) { return fileDescriptorControl, []int{7} }
func (m *StatusResponse) GetVertexes() []*Vertex {
if m != nil {
@ -306,7 +340,7 @@ type Vertex struct {
func (m *Vertex) Reset() { *m = Vertex{} }
func (m *Vertex) String() string { return proto.CompactTextString(m) }
func (*Vertex) ProtoMessage() {}
func (*Vertex) Descriptor() ([]byte, []int) { return fileDescriptorControl, []int{7} }
func (*Vertex) Descriptor() ([]byte, []int) { return fileDescriptorControl, []int{8} }
func (m *Vertex) GetName() string {
if m != nil {
@ -358,7 +392,7 @@ type VertexStatus struct {
func (m *VertexStatus) Reset() { *m = VertexStatus{} }
func (m *VertexStatus) String() string { return proto.CompactTextString(m) }
func (*VertexStatus) ProtoMessage() {}
func (*VertexStatus) Descriptor() ([]byte, []int) { return fileDescriptorControl, []int{8} }
func (*VertexStatus) Descriptor() ([]byte, []int) { return fileDescriptorControl, []int{9} }
func (m *VertexStatus) GetID() string {
if m != nil {
@ -419,7 +453,7 @@ type VertexLog struct {
func (m *VertexLog) Reset() { *m = VertexLog{} }
func (m *VertexLog) String() string { return proto.CompactTextString(m) }
func (*VertexLog) ProtoMessage() {}
func (*VertexLog) Descriptor() ([]byte, []int) { return fileDescriptorControl, []int{9} }
func (*VertexLog) Descriptor() ([]byte, []int) { return fileDescriptorControl, []int{10} }
func (m *VertexLog) GetTimestamp() time.Time {
if m != nil {
@ -449,7 +483,7 @@ type BytesMessage struct {
func (m *BytesMessage) Reset() { *m = BytesMessage{} }
func (m *BytesMessage) String() string { return proto.CompactTextString(m) }
func (*BytesMessage) ProtoMessage() {}
func (*BytesMessage) Descriptor() ([]byte, []int) { return fileDescriptorControl, []int{10} }
func (*BytesMessage) Descriptor() ([]byte, []int) { return fileDescriptorControl, []int{11} }
func (m *BytesMessage) GetData() []byte {
if m != nil {
@ -463,6 +497,7 @@ func init() {
proto.RegisterType((*DiskUsageResponse)(nil), "moby.buildkit.v1.DiskUsageResponse")
proto.RegisterType((*UsageRecord)(nil), "moby.buildkit.v1.UsageRecord")
proto.RegisterType((*SolveRequest)(nil), "moby.buildkit.v1.SolveRequest")
proto.RegisterType((*CacheOptions)(nil), "moby.buildkit.v1.CacheOptions")
proto.RegisterType((*SolveResponse)(nil), "moby.buildkit.v1.SolveResponse")
proto.RegisterType((*StatusRequest)(nil), "moby.buildkit.v1.StatusRequest")
proto.RegisterType((*StatusResponse)(nil), "moby.buildkit.v1.StatusResponse")
@ -924,6 +959,44 @@ func (m *SolveRequest) MarshalTo(dAtA []byte) (int, error) {
i += copy(dAtA[i:], v)
}
}
dAtA[i] = 0x42
i++
i = encodeVarintControl(dAtA, i, uint64(m.Cache.Size()))
n4, err := m.Cache.MarshalTo(dAtA[i:])
if err != nil {
return 0, err
}
i += n4
return i, nil
}
func (m *CacheOptions) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *CacheOptions) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if len(m.ExportRef) > 0 {
dAtA[i] = 0xa
i++
i = encodeVarintControl(dAtA, i, uint64(len(m.ExportRef)))
i += copy(dAtA[i:], m.ExportRef)
}
if len(m.ImportRef) > 0 {
dAtA[i] = 0x12
i++
i = encodeVarintControl(dAtA, i, uint64(len(m.ImportRef)))
i += copy(dAtA[i:], m.ImportRef)
}
return i, nil
}
@ -1091,21 +1164,21 @@ func (m *Vertex) MarshalTo(dAtA []byte) (int, error) {
dAtA[i] = 0x2a
i++
i = encodeVarintControl(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdTime(*m.Started)))
n4, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(*m.Started, dAtA[i:])
n5, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(*m.Started, dAtA[i:])
if err != nil {
return 0, err
}
i += n4
i += n5
}
if m.Completed != nil {
dAtA[i] = 0x32
i++
i = encodeVarintControl(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdTime(*m.Completed)))
n5, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(*m.Completed, dAtA[i:])
n6, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(*m.Completed, dAtA[i:])
if err != nil {
return 0, err
}
i += n5
i += n6
}
if len(m.Error) > 0 {
dAtA[i] = 0x3a
@ -1162,30 +1235,30 @@ func (m *VertexStatus) MarshalTo(dAtA []byte) (int, error) {
dAtA[i] = 0x32
i++
i = encodeVarintControl(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdTime(m.Timestamp)))
n6, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Timestamp, dAtA[i:])
n7, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Timestamp, dAtA[i:])
if err != nil {
return 0, err
}
i += n6
i += n7
if m.Started != nil {
dAtA[i] = 0x3a
i++
i = encodeVarintControl(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdTime(*m.Started)))
n7, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(*m.Started, dAtA[i:])
n8, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(*m.Started, dAtA[i:])
if err != nil {
return 0, err
}
i += n7
i += n8
}
if m.Completed != nil {
dAtA[i] = 0x42
i++
i = encodeVarintControl(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdTime(*m.Completed)))
n8, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(*m.Completed, dAtA[i:])
n9, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(*m.Completed, dAtA[i:])
if err != nil {
return 0, err
}
i += n8
i += n9
}
return i, nil
}
@ -1214,11 +1287,11 @@ func (m *VertexLog) MarshalTo(dAtA []byte) (int, error) {
dAtA[i] = 0x12
i++
i = encodeVarintControl(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdTime(m.Timestamp)))
n9, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Timestamp, dAtA[i:])
n10, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Timestamp, dAtA[i:])
if err != nil {
return 0, err
}
i += n9
i += n10
if m.Stream != 0 {
dAtA[i] = 0x18
i++
@ -1381,6 +1454,22 @@ func (m *SolveRequest) Size() (n int) {
n += mapEntrySize + 1 + sovControl(uint64(mapEntrySize))
}
}
l = m.Cache.Size()
n += 1 + l + sovControl(uint64(l))
return n
}
func (m *CacheOptions) Size() (n int) {
var l int
_ = l
l = len(m.ExportRef)
if l > 0 {
n += 1 + l + sovControl(uint64(l))
}
l = len(m.ImportRef)
if l > 0 {
n += 1 + l + sovControl(uint64(l))
}
return n
}
@ -2389,6 +2478,144 @@ func (m *SolveRequest) Unmarshal(dAtA []byte) error {
m.FrontendAttrs[mapkey] = mapvalue
}
iNdEx = postIndex
case 8:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Cache", 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
}
if err := m.Cache.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipControl(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthControl
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *CacheOptions) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowControl
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: CacheOptions: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: CacheOptions: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field ExportRef", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowControl
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthControl
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.ExportRef = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field ImportRef", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowControl
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthControl
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.ImportRef = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipControl(dAtA[iNdEx:])
@ -3584,67 +3811,70 @@ var (
func init() { proto.RegisterFile("control.proto", fileDescriptorControl) }
var fileDescriptorControl = []byte{
// 978 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0xdf, 0x6e, 0xe3, 0xc4,
0x17, 0xfe, 0xd9, 0x4e, 0x9d, 0xe4, 0x34, 0xad, 0xfa, 0x1b, 0xa1, 0x95, 0x15, 0x44, 0x12, 0xcc,
0x4d, 0x54, 0xb1, 0xce, 0x6e, 0x01, 0x09, 0x15, 0x09, 0xed, 0xa6, 0x59, 0x44, 0xab, 0xad, 0x84,
0xa6, 0x5b, 0xb8, 0x76, 0x92, 0xa9, 0xd7, 0xaa, 0xe3, 0x31, 0x33, 0xe3, 0xa8, 0xe1, 0x29, 0x78,
0x17, 0x9e, 0x80, 0x0b, 0xc4, 0x5e, 0x72, 0x89, 0xb8, 0x28, 0xa8, 0x0f,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94, 0x57, 0xba, 0x6b, 0xbd, 0x77, 0x77, 0x97, 0x3a, 0x63, 0x3f, 0xac, 0x33, 0x8f, 0xc0,
0xe5, 0x82, 0x91, 0x70, 0xa6, 0x34, 0x72, 0xb0, 0x89, 0xa4, 0x9f, 0xcc, 0x78, 0xa4, 0x14, 0x6a,
0x61, 0x39, 0xf4, 0x7d, 0x68, 0x0d, 0x17, 0x82, 0xf0, 0x63, 0xc2, 0xe5, 0x0b, 0x26, 0xb5, 0x9d,
0x86, 0x22, 0x54, 0xfb, 0x68, 0x61, 0x35, 0xde, 0xfb, 0xdd, 0x86, 0xfa, 0x81, 0xfe, 0x18, 0x42,
0xaf, 0xa0, 0x59, 0x7e, 0x4a, 0x20, 0x7f, 0xf5, 0xe6, 0xbf, 0xfd, 0x4d, 0xd2, 0xfe, 0xe4, 0x9d,
0x18, 0x63, 0x61, 0xdf, 0xc2, 0x86, 0x72, 0x4d, 0xd4, 0x79, 0xf7, 0x23, 0xd0, 0xee, 0xae, 0xfd,
0xdf, 0x30, 0x1d, 0x83, 0x6b, 0x6e, 0xc0, 0x4d, 0xd0, 0xaa, 0xb9, 0xb6, 0x7b, 0xeb, 0x01, 0x9a,
0xec, 0x89, 0x85, 0x8e, 0xcb, 0x17, 0xee, 0xa6, 0xd2, 0xaa, 0x9d, 0x6b, 0xdf, 0xf2, 0x7f, 0xdf,
0x7a, 0x62, 0x0d, 0x5b, 0x6f, 0xae, 0x3a, 0xd6, 0x1f, 0x57, 0x1d, 0xeb, 0x9f, 0xab, 0x8e, 0x35,
0x76, 0x95, 0x9c, 0x9f, 0xfd, 0x17, 0x00, 0x00, 0xff, 0xff, 0xbc, 0x66, 0x46, 0xe5, 0x6a, 0x0a,
0x00, 0x00,
// 1027 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xa4, 0x56, 0x5f, 0x6f, 0xe3, 0x44,
0x10, 0xc7, 0x4e, 0x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b,
0x6d, 0x4c, 0x0b, 0xfb, 0x0e, 0x36, 0x54, 0xd7, 0x44, 0xad, 0xb7, 0x0f, 0xa3, 0xe6, 0xee, 0xda,
0x7d, 0x83, 0x74, 0x0c, 0x8e, 0x79, 0x01, 0xd7, 0x99, 0x96, 0x9b, 0x6b, 0xb3, 0xbd, 0xde, 0x40,
0x83, 0x3d, 0xb2, 0xd0, 0xf1, 0x7c, 0xd2, 0x5e, 0x17, 0x5a, 0x39, 0x73, 0xcd, 0x1b, 0xf6, 0x3b,
0xd6, 0x23, 0xab, 0xdf, 0x78, 0x75, 0xd5, 0xb2, 0xfe, 0xbe, 0x6a, 0x59, 0xff, 0x5d, 0xb5, 0xac,
0xa1, 0xa3, 0xe8, 0xfc, 0xfc, 0x75, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe9, 0xaa, 0xee, 0xfc, 0xf2,
0x0a, 0x00, 0x00,
}

View File

@ -45,6 +45,12 @@ message SolveRequest {
string Session = 5;
string Frontend = 6;
map<string, string> FrontendAttrs = 7;
CacheOptions Cache = 8 [(gogoproto.nullable) = false];
}
message CacheOptions {
string ExportRef = 1;
string ImportRef = 2;
}
message SolveResponse {

View File

@ -6,10 +6,14 @@ import (
"encoding/json"
"github.com/containerd/containerd/content"
"github.com/containerd/containerd/images"
"github.com/containerd/containerd/rootfs"
"github.com/docker/distribution/manifest"
"github.com/docker/distribution/manifest/schema2"
"github.com/moby/buildkit/cache"
"github.com/moby/buildkit/cache/blobs"
"github.com/moby/buildkit/snapshot"
"github.com/moby/buildkit/util/push"
digest "github.com/opencontainers/go-digest"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
@ -17,6 +21,8 @@ import (
"golang.org/x/net/context"
)
const mediaTypeConfig = "application/vnd.buildkit.buildcache.v0"
type blobmapper interface {
GetBlob(ctx gocontext.Context, key string) (digest.Digest, error)
SetBlob(ctx gocontext.Context, key string, blob digest.Digest) error
@ -42,7 +48,7 @@ type CacheExporter struct {
opt ExporterOpt
}
func (ce *CacheExporter) Export(ctx context.Context, rec []CacheRecord) error {
func (ce *CacheExporter) Export(ctx context.Context, rec []CacheRecord, target string) error {
allBlobs := map[digest.Digest][]blobs.DiffPair{}
currentBlobs := map[digest.Digest]struct{}{}
type cr struct {
@ -79,13 +85,22 @@ func (ce *CacheExporter) Export(ctx context.Context, rec []CacheRecord) error {
}
}
var mfst ocispec.Index
// own type because oci type can't be pushed and docker type doesn't have annotations
type manifestList struct {
manifest.Versioned
// Manifests references platform specific manifests.
Manifests []ocispec.Descriptor `json:"manifests"`
}
var mfst manifestList
mfst.SchemaVersion = 2
mfst.MediaType = images.MediaTypeDockerSchema2ManifestList
for _, l := range list {
var size int64
parent := ""
diffID := ""
var parent digest.Digest
var diffID digest.Digest
if l.dgst != "" {
info, err := ce.opt.ContentStore.Info(ctx, l.dgst)
if err != nil {
@ -94,30 +109,49 @@ func (ce *CacheExporter) Export(ctx context.Context, rec []CacheRecord) error {
size = info.Size
chain := allBlobs[l.dgst]
if len(chain) > 1 {
parent = chain[len(chain)-2].Blobsum.String()
parent = chain[len(chain)-2].Blobsum
}
diffID = chain[len(chain)-1].DiffID.String()
diffID = chain[len(chain)-1].DiffID
mfst.Manifests = append(mfst.Manifests, ocispec.Descriptor{
MediaType: schema2.MediaTypeLayer,
Size: size,
Digest: l.dgst,
})
}
mfst.Manifests = append(mfst.Manifests, ocispec.Descriptor{
MediaType: ocispec.MediaTypeImageLayerGzip,
Size: size,
Digest: l.dgst,
Annotations: map[string]string{
"buildkit.cachekey": l.CacheKey.String(),
"buildkit.contentkey": l.ContentKey.String(),
"buildkit.parent": parent,
"buildkit.diffid": diffID,
},
config.Items = append(config.Items, configItem{
Blobsum: l.dgst,
CacheKey: l.CacheKey,
ContentKey: l.ContentKey,
Parent: parent,
DiffID: diffID,
})
}
dt, err := json.Marshal(mfst)
dt, err := json.Marshal(config)
if err != nil {
return err
}
dgst := digest.FromBytes(dt)
if err := content.WriteBlob(ctx, ce.opt.ContentStore, dgst.String(), bytes.NewReader(dt), int64(len(dt)), dgst); err != nil {
return errors.Wrap(err, "error writing config blob")
}
mfst.Manifests = append(mfst.Manifests, ocispec.Descriptor{
MediaType: mediaTypeConfig,
Size: int64(len(dt)),
Digest: dgst,
})
dt, err = json.Marshal(mfst)
if err != nil {
return errors.Wrap(err, "failed to marshal manifest")
}
dgst := digest.FromBytes(dt)
dgst = digest.FromBytes(dt)
if err := content.WriteBlob(ctx, ce.opt.ContentStore, dgst.String(), bytes.NewReader(dt), int64(len(dt)), dgst); err != nil {
return errors.Wrap(err, "error writing manifest blob")
@ -125,5 +159,17 @@ func (ce *CacheExporter) Export(ctx context.Context, rec []CacheRecord) error {
logrus.Debugf("cache-manifest: %s", dgst)
return nil
return push.Push(ctx, ce.opt.ContentStore, dgst, target)
}
type configItem struct {
Blobsum digest.Digest
CacheKey digest.Digest
ContentKey digest.Digest
Parent digest.Digest
DiffID digest.Digest
}
var config struct {
Items []configItem
}

View File

@ -27,6 +27,8 @@ type SolveOpt struct {
SharedKey string
Frontend string
FrontendAttrs map[string]string
ExportCache string
ImportCache string
// Session string
}
@ -99,6 +101,10 @@ func (c *Client) Solve(ctx context.Context, def *llb.Definition, opt SolveOpt, s
Session: s.ID(),
Frontend: opt.Frontend,
FrontendAttrs: opt.FrontendAttrs,
Cache: controlapi.CacheOptions{
ExportRef: opt.ExportCache,
ImportRef: opt.ImportCache,
},
})
if err != nil {
return errors.Wrap(err, "failed to solve")

View File

@ -57,6 +57,14 @@ var buildCommand = cli.Command{
Name: "no-cache",
Usage: "Disable cache for all the vertices. (Not yet implemented.) Frontend is not supported.",
},
cli.StringFlag{
Name: "export-cache",
Usage: "Reference to export build cache to",
},
cli.StringFlag{
Name: "import-cache",
Usage: "Reference to import build cache from",
},
},
}
@ -143,6 +151,8 @@ func build(clicontext *cli.Context) error {
LocalDirs: localDirs,
Frontend: clicontext.String("frontend"),
FrontendAttrs: frontendAttrs,
ExportCache: clicontext.String("export-cache"),
ImportCache: clicontext.String("import-cache"),
}, ch)
})

View File

@ -2,6 +2,7 @@ package control
import (
"github.com/containerd/containerd/snapshot"
"github.com/docker/distribution/reference"
controlapi "github.com/moby/buildkit/api/services/control"
"github.com/moby/buildkit/cache"
"github.com/moby/buildkit/cache/cacheimport"
@ -111,11 +112,31 @@ func (c *Controller) Solve(ctx context.Context, req *controlapi.SolveRequest) (*
}
}
exportCacheRef := ""
if ref := req.Cache.ExportRef; ref != "" {
parsed, err := reference.ParseNormalizedNamed(ref)
if err != nil {
return nil, err
}
exportCacheRef = reference.TagNameOnly(parsed).String()
}
importCacheRef := ""
if ref := req.Cache.ImportRef; ref != "" {
parsed, err := reference.ParseNormalizedNamed(ref)
if err != nil {
return nil, err
}
importCacheRef = reference.TagNameOnly(parsed).String()
}
if err := c.solver.Solve(ctx, req.Ref, solver.SolveRequest{
Frontend: frontend,
Definition: req.Definition,
Exporter: expi,
FrontendOpt: req.FrontendAttrs,
Frontend: frontend,
Definition: req.Definition,
Exporter: expi,
FrontendOpt: req.FrontendAttrs,
ExportCacheRef: exportCacheRef,
ImportCacheRef: importCacheRef,
}); err != nil {
return nil, err
}

View File

@ -1,3 +1,3 @@
package moby_buildkit_v1_frontend
//go:generate protoc -I=. -I=../../../vendor/ -I=/Users/tonistiigi/gocode/src --gogo_out=plugins=grpc:. gateway.proto
//go:generate protoc -I=. -I=../../../vendor/ --gogo_out=plugins=grpc:. gateway.proto

View File

@ -98,10 +98,12 @@ func New(resolve ResolveOpFunc, cache InstructionCache, imageSource source.Sourc
}
type SolveRequest struct {
Definition *pb.Definition
Frontend frontend.Frontend
Exporter exporter.ExporterInstance
FrontendOpt map[string]string
Definition *pb.Definition
Frontend frontend.Frontend
Exporter exporter.ExporterInstance
FrontendOpt map[string]string
ExportCacheRef string
ImportCacheRef string
}
func (s *Solver) solve(ctx context.Context, j *job, req SolveRequest) (Reference, map[string][]byte, error) {
@ -163,20 +165,22 @@ func (s *Solver) Solve(ctx context.Context, id string, req SolveRequest) error {
}
}
if err := inVertexContext(ctx, "exporting build cache", func(ctx context.Context) error {
cache, err := j.cacheExporter(ref)
if err != nil {
if exportName := req.ExportCacheRef; exportName != "" {
if err := inVertexContext(ctx, "exporting build cache", func(ctx context.Context) error {
cache, err := j.cacheExporter(ref)
if err != nil {
return err
}
records, err := cache.Export(ctx)
if err != nil {
return err
}
return s.ce.Export(ctx, records, exportName)
}); err != nil {
return err
}
records, err := cache.Export(ctx)
if err != nil {
return err
}
return s.ce.Export(ctx, records)
}); err != nil {
return err
}
return err

View File

@ -135,5 +135,5 @@ func DetectManifestMediaType(ra content.ReaderAt) (string, error) {
if mfst.Config != nil {
return images.MediaTypeDockerSchema2Manifest, nil
}
return ocispec.MediaTypeImageIndex, nil
return images.MediaTypeDockerSchema2ManifestList, nil
}

View File

@ -2,6 +2,7 @@ package push
import (
"context"
"encoding/json"
"fmt"
"net/http"
"sync"
@ -15,6 +16,7 @@ import (
"github.com/moby/buildkit/util/progress"
digest "github.com/opencontainers/go-digest"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/sirupsen/logrus"
)
func Push(ctx context.Context, cs content.Store, dgst digest.Digest, ref string) error {
@ -46,7 +48,7 @@ func Push(ctx context.Context, cs content.Store, dgst digest.Digest, ref string)
pushHandler := remotes.PushHandler(cs, pusher)
handlers := append([]images.Handler{},
images.ChildrenHandler(cs),
childrenHandler(cs),
filterHandler,
pushHandler,
)
@ -105,3 +107,51 @@ func oneOffProgress(ctx context.Context, id string) func(err error) error {
return err
}
}
func childrenHandler(provider content.Provider) images.HandlerFunc {
return func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
var descs []ocispec.Descriptor
switch desc.MediaType {
case images.MediaTypeDockerSchema2Manifest, ocispec.MediaTypeImageManifest:
p, err := content.ReadBlob(ctx, provider, desc.Digest)
if err != nil {
return nil, err
}
// TODO(stevvooe): We just assume oci manifest, for now. There may be
// subtle differences from the docker version.
var manifest ocispec.Manifest
if err := json.Unmarshal(p, &manifest); err != nil {
return nil, err
}
descs = append(descs, manifest.Config)
descs = append(descs, manifest.Layers...)
case images.MediaTypeDockerSchema2ManifestList, ocispec.MediaTypeImageIndex:
p, err := content.ReadBlob(ctx, provider, desc.Digest)
if err != nil {
return nil, err
}
var index ocispec.Index
if err := json.Unmarshal(p, &index); err != nil {
return nil, err
}
for _, m := range index.Manifests {
if m.Digest != "" {
descs = append(descs, m)
}
}
case images.MediaTypeDockerSchema2Layer, images.MediaTypeDockerSchema2LayerGzip,
images.MediaTypeDockerSchema2Config, ocispec.MediaTypeImageConfig,
ocispec.MediaTypeImageLayer, ocispec.MediaTypeImageLayerGzip:
// childless data types.
return nil, nil
default:
logrus.Warnf("encountered unknown type %v; children may not be fetched", desc.MediaType)
}
return descs, nil
}
}