GoogleContainerTools / jib

🏗 Build container images for your Java applications.
Apache License 2.0
13.71k stars 1.44k forks source link

Align containerizingMode with Spring's Class Data Sharing (CDS) approach #4271

Open wleese opened 5 months ago

wleese commented 5 months ago

Environment:

Description of the issue:

While getting CDS to work with containerizingMode packaged & jib works, I'm left wondering if CDS is set up as good as can be. I'm in doubt, because there's still wildcard usage on the classpath.

I'm wondering if this plugin shouldn't align with what Spring describes. https://docs.spring.io/spring-boot/reference/deployment/efficient.html#deployment.efficient

java -Djarmode=tools -jar my-app.jar extract

# app startup, no classpath specified
java -jar my-app/my-app.jar

This results in a directory/file layout like so:

./cdstestng-app-1.jar
./lib
./lib/exporter-trace-0.29.0.jar
./lib/opentelemetry-api-incubator-1.37.0-alpha.jar
[more libs]

Expected behavior:

I'd expect jib-maven-plugin to offer a containerizingMode that aligns with the way Spring recommends containerizing applications when using CDS. If for whatever reason such a mode shall not be provided, I'd expect some kind of documentation acknowledging the situation and explaining jib-maven-plugin's preferred to support CDS usage.

I read https://github.com/GoogleContainerTools/jib/blob/master/docs/faq.md#i-want-to-containerize-a-jar ->

The intention of Jib is to add individual class files, resources, and dependency JARs into the container instead of putting a JAR. This lets Jib choose an opinionated, optimal layout for the application on the container image, which also allows it to skip the extra JAR-packaging step.

.. which I /think/ does not conflict with what Spring is advising.