GoogleContainerTools / GoogleContainerTools/jib

Base image layers cache directory gets created even with scratch base image

Open
#4,508 0 comments 0 reactions 0 assignees View on GitHub
priority: p3 question
Dominant language
Java
Stars
14.5k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

**Environment**:

- *Jib version:* jib-core 0.28.1
- *Build tool:* Gradle 8, Gradle 9, Gradle 9.5.1
- *OS:* MacOS Tahoe 26.3.1

**Description of the issue**:
With a scratch base image, Jib still creates the base image layers cache directory, which stays empty since scratch has no layers to cache. BuildContext.Builder.build() calls Cache.withDirectory(...) unconditionally, which eagerly creates the directory.

**Expected behavior**:
No base image layers cache directory is created for a scratch base image.

**Steps to reproduce**:

1. Set base image to scratch.
2. Run a build.
3. The base image layers cache directory is created but empty.

**Additional Information**:
I've prepared a fix for this issue and would be happy to open a PR if you'd accept it. Thanks!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.