Skip to content

Jib cannot load images created by bazel rules_oci 2.x #4382

Open
@Sineaggi

Description

@Sineaggi

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",

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions