Skip to content

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

Description

@vjh0107

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!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions