Merge pull request #137 from dagger/local-cache
Fix caching issues with Local
This commit is contained in:
commit
4a4c0da0aa
@ -253,14 +253,33 @@ func (p *Pipeline) Local(ctx context.Context, op *compiler.Value) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// FIXME: Remove the `Copy` and use `Local` directly.
|
||||||
|
//
|
||||||
|
// Copy'ing is a costly operation which should be unnecessary.
|
||||||
|
// However, for a mysterious reason, `llb.Local` is returning a different
|
||||||
|
// digest at every run, therefore invalidating the cache.
|
||||||
|
//
|
||||||
|
// By wrapping `llb.Local` inside `llb.Copy`, we get the same digest for
|
||||||
|
// the same content.
|
||||||
|
p.fs = p.fs.Change(func(st llb.State) llb.State {
|
||||||
|
return st.File(
|
||||||
|
llb.Copy(
|
||||||
|
llb.Local(
|
||||||
|
dir,
|
||||||
|
llb.FollowPaths(include),
|
||||||
|
llb.WithCustomName(p.vertexNamef("Local %s", dir)),
|
||||||
|
|
||||||
|
// Without hint, multiple `llb.Local` operations on the
|
||||||
|
// same path get a different digest.
|
||||||
|
llb.SessionID(p.s.SessionID()),
|
||||||
|
llb.SharedKeyHint(dir),
|
||||||
|
),
|
||||||
|
"/",
|
||||||
|
"/",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
p.fs = p.fs.Set(
|
|
||||||
llb.Local(
|
|
||||||
dir,
|
|
||||||
llb.FollowPaths(include),
|
|
||||||
llb.WithCustomName(p.vertexNamef("Local %s", dir)),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,10 @@ func (s Solver) Scratch() FS {
|
|||||||
return s.FS(llb.Scratch())
|
return s.FS(llb.Scratch())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s Solver) SessionID() string {
|
||||||
|
return s.c.BuildOpts().SessionID
|
||||||
|
}
|
||||||
|
|
||||||
// Solve will block until the state is solved and returns a Reference.
|
// Solve will block until the state is solved and returns a Reference.
|
||||||
func (s Solver) SolveRequest(ctx context.Context, req bkgw.SolveRequest) (bkgw.Reference, error) {
|
func (s Solver) SolveRequest(ctx context.Context, req bkgw.SolveRequest) (bkgw.Reference, error) {
|
||||||
// call solve
|
// call solve
|
||||||
|
Reference in New Issue
Block a user