Merge pull request #1194 from tp-tc/greedy-cache-substitution
Don't generate cache key, if not caching builds.
This commit is contained in:
commit
6c627645ad
|
|
@ -0,0 +1,2 @@
|
||||||
|
FROM docker.io/library/busybox:latest@sha256:afe605d272837ce1732f390966166c2afff5391208ddd57de10942748694049d
|
||||||
|
RUN echo ${s%s}
|
||||||
|
|
@ -339,10 +339,12 @@ func (s *stageBuilder) build() error {
|
||||||
return errors.Wrap(err, "failed to get files used from context")
|
return errors.Wrap(err, "failed to get files used from context")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if s.opts.Cache {
|
||||||
*compositeKey, err = s.populateCompositeKey(command, files, *compositeKey, s.args, s.cf.Config.Env)
|
*compositeKey, err = s.populateCompositeKey(command, files, *compositeKey, s.args, s.cf.Config.Env)
|
||||||
if err != nil {
|
if err != nil && s.opts.Cache {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
logrus.Info(command.String())
|
logrus.Info(command.String())
|
||||||
|
|
||||||
|
|
@ -377,6 +379,7 @@ func (s *stageBuilder) build() error {
|
||||||
return errors.Wrap(err, "failed to take snapshot")
|
return errors.Wrap(err, "failed to take snapshot")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if s.opts.Cache {
|
||||||
logrus.Debugf("build: composite key for command %v %v", command.String(), compositeKey)
|
logrus.Debugf("build: composite key for command %v %v", command.String(), compositeKey)
|
||||||
ck, err := compositeKey.Hash()
|
ck, err := compositeKey.Hash()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -386,11 +389,12 @@ func (s *stageBuilder) build() error {
|
||||||
logrus.Debugf("build: cache key for command %v %v", command.String(), ck)
|
logrus.Debugf("build: cache key for command %v %v", command.String(), ck)
|
||||||
|
|
||||||
// Push layer to cache (in parallel) now along with new config file
|
// Push layer to cache (in parallel) now along with new config file
|
||||||
if s.opts.Cache && command.ShouldCacheOutput() {
|
if command.ShouldCacheOutput() {
|
||||||
cacheGroup.Go(func() error {
|
cacheGroup.Go(func() error {
|
||||||
return s.pushLayerToCache(s.opts, ck, tarPath, command.String())
|
return s.pushLayerToCache(s.opts, ck, tarPath, command.String())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if err := s.saveSnapshotToImage(command.String(), tarPath); err != nil {
|
if err := s.saveSnapshotToImage(command.String(), tarPath); err != nil {
|
||||||
return errors.Wrap(err, "failed to save snapshot to image")
|
return errors.Wrap(err, "failed to save snapshot to image")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue