1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #11000 from anandkumarpatel/invalidate-probe

Improve build speed
This commit is contained in:
Alexander Morozov 2015-03-04 11:35:00 -08:00
commit e0823b09ec
2 changed files with 20 additions and 14 deletions

View file

@ -91,6 +91,7 @@ type Builder struct {
Verbose bool Verbose bool
UtilizeCache bool UtilizeCache bool
cacheBusted bool
// controls how images and containers are handled between steps. // controls how images and containers are handled between steps.
Remove bool Remove bool

View file

@ -187,8 +187,8 @@ func (b *Builder) runContextCommand(args []string, allowRemote bool, allowDecomp
if err != nil { if err != nil {
return err return err
} }
// If we do not have at least one hash, never use the cache
if hit && b.UtilizeCache { if hit {
return nil return nil
} }
@ -502,19 +502,24 @@ func (b *Builder) processImageFrom(img *imagepkg.Image) error {
// `(true, nil)`. If no image is found, it returns `(false, nil)`. If there // `(true, nil)`. If no image is found, it returns `(false, nil)`. If there
// is any error, it returns `(false, err)`. // is any error, it returns `(false, err)`.
func (b *Builder) probeCache() (bool, error) { func (b *Builder) probeCache() (bool, error) {
if b.UtilizeCache { if !b.UtilizeCache || b.cacheBusted {
if cache, err := b.Daemon.ImageGetCached(b.image, b.Config); err != nil { return false, nil
}
cache, err := b.Daemon.ImageGetCached(b.image, b.Config)
if err != nil {
return false, err return false, err
} else if cache != nil { }
if cache == nil {
log.Debugf("[BUILDER] Cache miss")
b.cacheBusted = true
return false, nil
}
fmt.Fprintf(b.OutStream, " ---> Using cache\n") fmt.Fprintf(b.OutStream, " ---> Using cache\n")
log.Debugf("[BUILDER] Use cached version") log.Debugf("[BUILDER] Use cached version")
b.image = cache.ID b.image = cache.ID
return true, nil return true, nil
} else {
log.Debugf("[BUILDER] Cache miss")
}
}
return false, nil
} }
func (b *Builder) create() (*daemon.Container, error) { func (b *Builder) create() (*daemon.Container, error) {