From d7d45ba71abf51b1070a0639a14e327ede70fc0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Va=C5=A1ek?= Date: Fri, 4 Apr 2025 13:31:22 +0200 Subject: [PATCH] Re-enable build caching for local s2i builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Matej VaĊĦek --- pkg/builders/s2i/builder.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/builders/s2i/builder.go b/pkg/builders/s2i/builder.go index e2bc9ffe7..98a14482a 100644 --- a/pkg/builders/s2i/builder.go +++ b/pkg/builders/s2i/builder.go @@ -6,6 +6,7 @@ import ( "fmt" "net/url" "os" + "path" "path/filepath" "runtime" "strings" @@ -184,10 +185,19 @@ func (b *Builder) Build(ctx context.Context, f fn.Function, platforms []fn.Platf cfg.Environment = append(cfg.Environment, api.EnvironmentSpec{Name: k, Value: v}) } + var artifactsMounted bool + for _, m := range f.Build.Mounts { + if path.Clean(m.Destination) == "/tmp/artifacts" { + artifactsMounted = true + } cfg.BuildVolumes = append(cfg.BuildVolumes, fmt.Sprintf("%s:%s:ro,Z", m.Source, m.Destination)) } + if !artifactsMounted { + cfg.BuildVolumes = append(cfg.BuildVolumes, f.Name+"-s2i-build-cache:/tmp/artifacts") + } + if runtime.GOOS == "linux" { cfg.DockerNetworkMode = "host" }