jib icon indicating copy to clipboard operation
jib copied to clipboard

Jib cannot load images created by bazel rules_oci 2.x

Open Sineaggi opened this issue 9 months ago • 2 comments

Environment:

  • Jib Gradle plugin 3.4.5
  • Gradle 8.13
  • macos

Description of the issue: Jib fails to load images produced with bazel's rules_oci 2.x

https://github.com/bazel-contrib/rules_oci/releases/tag/v2.0.0

This seems to be due to the following change

Uncompressed archives in the tars attribute is no longer compressed when creating the image, this might make images bigger compared to 1.x. Use pkg_tar#extension or tar#compress attribute to compress the layers beforehand.

When loading an image in from rules_oci, I see the exception

* What went wrong:
Execution failed for task ':app:jibBuildTar'.
> com.google.cloud.tools.jib.plugins.common.BuildStepsExecutionException: org.apache.commons.compress.compressors.CompressorException: No Compressor found for the stream signature.

That tracks, as there is no longer any compression.

Expected behavior:

Build succeeds.

Steps to reproduce:

  1. start a local registry (docker run -d -p 5000:5000 --name registry registry)
  2. use bazel and rules_oci to produce a docker image (targeting a local registry, using rules_oci's oci_load)
  3. push to the local registry (docker push localhost:5000/distroless/java21:nonroot, required as jib can't load registry images)
  4. Try to build an image using that registry image (see gradle config below)

jib-gradle-plugin Configuration:

jib {
    from {
        setAllowInsecureRegistries(true)
        image = "localhost:5000/distroless/java21:nonroot"

Log output:

* What went wrong:
Execution failed for task ':app:jibBuildTar'.
> com.google.cloud.tools.jib.plugins.common.BuildStepsExecutionException: org.apache.commons.compress.compressors.CompressorException: No Compressor found for the stream signature.

Additional Information:

Can be worked around by re-enabling compression as the rules_oci changelog points out.

    pkg_tar(
        name = "tar_java" + version + "_" + arch,
        extension = "tar.gz",

Sineaggi avatar Apr 11 '25 15:04 Sineaggi

Possible duplicate of https://github.com/GoogleContainerTools/jib/issues/4389.

diegomarquezp avatar Sep 15 '25 15:09 diegomarquezp

FWIW we've just been using the work-around for our distroless images for months, tho the bug itself has not been fixed.

Sineaggi avatar Sep 15 '25 19:09 Sineaggi