Compress layers on push to a v2 registry

When buffering to file add support for compressing the tar contents. Since digest should be computed while writing buffer, include digest creation during buffer.

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
(cherry picked from commit 851c64725d)

Docker-DCO-1.1-Signed-off-by: Jessie Frazelle <hugs@docker.com> (github: jfrazelle)
This commit is contained in:
Derek McGowan
2015-03-30 15:42:14 -07:00
committed by Jessica Frazelle
parent f72b2c02b8
commit 4ddbc7a62f
2 changed files with 19 additions and 14 deletions
+1 -8
View File
@@ -1,7 +1,6 @@
package graph
import (
"crypto/sha256"
"encoding/json"
"errors"
"fmt"
@@ -13,7 +12,6 @@ import (
"sync"
log "github.com/Sirupsen/logrus"
"github.com/docker/distribution/digest"
"github.com/docker/docker/engine"
"github.com/docker/docker/image"
"github.com/docker/docker/pkg/common"
@@ -464,12 +462,7 @@ func (s *TagStore) pushV2Image(r *registry.Session, img *image.Image, endpoint *
os.Remove(tf.Name())
}()
h := sha256.New()
size, err := bufferToFile(tf, io.TeeReader(arch, h))
if err != nil {
return "", err
}
dgst := digest.NewDigest("sha256", h)
size, dgst, err := bufferToFile(tf, arch)
// Send the layer
log.Debugf("rendered layer for %s of [%d] size", img.ID, size)