From 5b1e7eeacf263dd5f9d1fe2d1d7e001808320340 Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Thu, 18 Mar 2021 11:18:06 -0700 Subject: [PATCH] pipeline: FetchGit: make a copy of the content to avoid caching issues Signed-off-by: Andrea Luzzardi --- dagger/pipeline.go | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/dagger/pipeline.go b/dagger/pipeline.go index 1ace8113..e7fe433c 100644 --- a/dagger/pipeline.go +++ b/dagger/pipeline.go @@ -312,11 +312,7 @@ func (p *Pipeline) Local(ctx context.Context, op *compiler.Value, st llb.State) // 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. + // However, using llb.Local directly breaks caching sometimes for unknown reasons. return st.File( llb.Copy( llb.Local( @@ -624,10 +620,22 @@ func (p *Pipeline) FetchGit(ctx context.Context, op *compiler.Value, st llb.Stat if err != nil { return st, err } - return llb.Git( - remote, - ref, - llb.WithCustomName(p.vertexNamef("FetchGit %s@%s", remote, ref)), + + // FIXME: Remove the `Copy` and use `Git` directly. + // + // Copy'ing is a costly operation which should be unnecessary. + // However, using llb.Git directly breaks caching sometimes for unknown reasons. + return st.File( + llb.Copy( + llb.Git( + remote, + ref, + llb.WithCustomName(p.vertexNamef("FetchGit %s@%s", remote, ref)), + ), + "/", + "/", + ), + llb.WithCustomName(p.vertexNamef("FetchGit %s@%s [copy]", remote, ref)), ), nil }