-
Notifications
You must be signed in to change notification settings - Fork 862
Open
Description
Is your feature request related to a problem?
When using RUN --mount=type=cache, buildah stores cache mounts at $TMPDIR/buildah-cache-<uid>/. The only way to control this location is via TMPDIR or image_copy_tmp_dir in containers.conf.
Both settings affect all buildah temporary operations (SSH agent sockets, heredoc files, build contexts, downloaded URLs, container bundles), not just cache mounts.
In CI/CD environments this forces a choice:
- Redirect all temp operations to persistent storage (wasteful, stores ephemeral data)
- Keep default TMPDIR and lose cache mount persistence between jobs
Describe the solution you'd like
A dedicated environment variable (e.g. BUILDAH_CACHE_DIR) that controls only the location of --mount=type=cache mounts, independent of TMPDIR.
Priority order:
BUILDAH_CACHE_DIR(new, cache-specific)TMPDIR(existing behavior)image_copy_tmp_dirfrom containers.conf/var/tmp(default)
Describe alternatives you've considered
- Setting TMPDIR globally in runner config - affects all applications in all CI jobs, not just buildah. Node.js, Python, Java, and other tools would write temp files to persistent storage, causing unnecessary I/O and storage bloat. Also risks breaking tools that expect TMPDIR to be ephemeral.
- Using
image_copy_tmp_dir- still affects all buildah temp operations, not just cache mounts - Per-job TMPDIR in CI - requires job authors to know infrastructure details and remember to set it
Additional context
Use case: GitLab CI with Kubernetes runner
- Jobs run in ephemeral pods
- Shared PVC at
/buildah-cachefor cache persistence - Want ephemeral temp files to stay on local/tmpfs storage
Proposed implementation in internal/volumes/volumes.go:
func CacheParent() string {
if cacheDir, ok := os.LookupEnv("BUILDAH_CACHE_DIR"); ok {
return filepath.Join(cacheDir, buildahCacheDir+"-"+strconv.Itoa(unshare.GetRootlessUID()))
}
return filepath.Join(tmpdir.GetTempDir(), buildahCacheDir+"-"+strconv.Itoa(unshare.GetRootlessUID()))
}Metadata
Metadata
Assignees
Labels
No labels