feat(server): Reintroduce manifest caching to GCS

The new builder now caches and reads cached manifests to/from GCS. The
in-memory cache is disabled, as manifests are no longer written to
local file and the caching of file paths does not work (unless we
reintroduce reading/writing from temp files as part of the local
cache).
This commit is contained in:
Vincent Ambo 2019-10-03 11:23:04 +01:00 committed by Vincent Ambo
parent 1308a6e1fd
commit 355fe3f5ec
2 changed files with 29 additions and 29 deletions

View file

@ -366,7 +366,14 @@ func uploadHashLayer(ctx context.Context, s *State, key string, data io.Reader)
}
func BuildImage(ctx context.Context, s *State, image *Image) (*BuildResult, error) {
// TODO(tazjin): Use the build cache
key := s.Cfg.Pkgs.CacheKey(image.Packages, image.Tag)
if key != "" {
if m, c := manifestFromCache(ctx, s, key); c {
return &BuildResult{
Manifest: m,
}, nil
}
}
imageResult, err := prepareImage(s, image)
if err != nil {
@ -410,10 +417,12 @@ func BuildImage(ctx context.Context, s *State, image *Image) (*BuildResult, erro
return nil, err
}
if key != "" {
go cacheManifest(ctx, s, key, m)
}
result := BuildResult{
Manifest: m,
}
// TODO: cache manifest
return &result, nil
}