GoogleContainerTools / jib

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

Add support for jlink and creating slim JRE #3462

Open Saljack opened 2 years ago

Saljack commented 2 years ago

We found that right now we are not able to use Adoptiom/Temurin docker base image with the new version of Java 17 because they provide only full JDK docker images which is pretty huge. They encourage users to use jlink. I thought about it how to achieve it with jib and I do not see any easy way how to do it. I found that someone do it only with jib-core but I feel this is not much usable. Second option how to do it is create runtime with maven-jlink-plugin and then put it into the base docker image as extraDirectories. I think that JIB should contains an easy solution how to easily do it. For example as an extension (you do similar thing for Quarkus).

chanseokoh commented 2 years ago

Thanks for the feedback.

In the very early days when the Maven JLink Plugin was in alpha or so, I experimented with using jlink for Jib, and I was able to make it work though probably some tricks and hacks. I don't remember much of it, but I guess basically it was about running jlink and copy necessary things with <extraDirectories>. There was another user report where they made it work.

But yeah, all these involve a lot of setup from the user, so it would be really cool if Jib had native support to do this easy. Unfortunately, jlink is not in our roadmap and we haven't looked into this for a very long time. We welcome contributions on this.

reitzmichnicht commented 2 years ago

You can create your own base image based on base tag of distroless image: https://console.cloud.google.com/gcr/images/distroless/GLOBAL/java-debian11 and add your custom jlink runtime there.

elefeint commented 2 years ago

Good to know, thanks!