Re-enable build caching for local s2i builds

Signed-off-by: Matej Vašek <mvasek@redhat.com>
This commit is contained in:
Matej Vašek 2025-04-04 13:31:22 +02:00
parent 3e75e25506
commit d7d45ba71a
No known key found for this signature in database
GPG Key ID: 72036E3FC07BF8F1
1 changed files with 10 additions and 0 deletions

View File

@ -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"
}