mirror of https://github.com/docker/docs.git
Disable compression for build. More space usage but much faster upload
Docker-DCO-1.0-Signed-off-by: Guillaume J. Charmes <guillaume.charmes@docker.com> (github: creack)
This commit is contained in:
parent
90ea81433f
commit
c6350bcc24
|
@ -604,11 +604,12 @@ func (b *buildFile) Build(context io.Reader) (string, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
b.context = &utils.TarSum{Reader: context}
|
b.context = &utils.TarSum{Reader: context, DisableCompression: true}
|
||||||
if err := archive.Untar(b.context, tmpdirPath, nil); err != nil {
|
if err := archive.Untar(b.context, tmpdirPath, nil); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
defer os.RemoveAll(tmpdirPath)
|
defer os.RemoveAll(tmpdirPath)
|
||||||
|
|
||||||
b.contextPath = tmpdirPath
|
b.contextPath = tmpdirPath
|
||||||
filename := path.Join(tmpdirPath, "Dockerfile")
|
filename := path.Join(tmpdirPath, "Dockerfile")
|
||||||
if _, err := os.Stat(filename); os.IsNotExist(err) {
|
if _, err := os.Stat(filename); os.IsNotExist(err) {
|
||||||
|
|
|
@ -17,7 +17,7 @@ type TarSum struct {
|
||||||
io.Reader
|
io.Reader
|
||||||
tarR *tar.Reader
|
tarR *tar.Reader
|
||||||
tarW *tar.Writer
|
tarW *tar.Writer
|
||||||
gz *gzip.Writer
|
gz writeCloseFlusher
|
||||||
bufTar *bytes.Buffer
|
bufTar *bytes.Buffer
|
||||||
bufGz *bytes.Buffer
|
bufGz *bytes.Buffer
|
||||||
h hash.Hash
|
h hash.Hash
|
||||||
|
@ -25,6 +25,24 @@ type TarSum struct {
|
||||||
currentFile string
|
currentFile string
|
||||||
finished bool
|
finished bool
|
||||||
first bool
|
first bool
|
||||||
|
DisableCompression bool
|
||||||
|
}
|
||||||
|
|
||||||
|
type writeCloseFlusher interface {
|
||||||
|
io.WriteCloser
|
||||||
|
Flush() error
|
||||||
|
}
|
||||||
|
|
||||||
|
type nopCloseFlusher struct {
|
||||||
|
io.Writer
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *nopCloseFlusher) Close() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *nopCloseFlusher) Flush() error {
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ts *TarSum) encodeHeader(h *tar.Header) error {
|
func (ts *TarSum) encodeHeader(h *tar.Header) error {
|
||||||
|
@ -57,7 +75,11 @@ func (ts *TarSum) Read(buf []byte) (int, error) {
|
||||||
ts.bufGz = bytes.NewBuffer([]byte{})
|
ts.bufGz = bytes.NewBuffer([]byte{})
|
||||||
ts.tarR = tar.NewReader(ts.Reader)
|
ts.tarR = tar.NewReader(ts.Reader)
|
||||||
ts.tarW = tar.NewWriter(ts.bufTar)
|
ts.tarW = tar.NewWriter(ts.bufTar)
|
||||||
|
if !ts.DisableCompression {
|
||||||
ts.gz = gzip.NewWriter(ts.bufGz)
|
ts.gz = gzip.NewWriter(ts.bufGz)
|
||||||
|
} else {
|
||||||
|
ts.gz = &nopCloseFlusher{Writer: ts.bufGz}
|
||||||
|
}
|
||||||
ts.h = sha256.New()
|
ts.h = sha256.New()
|
||||||
ts.h.Reset()
|
ts.h.Reset()
|
||||||
ts.first = true
|
ts.first = true
|
||||||
|
|
Loading…
Reference in New Issue