Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smaller JDK base image using Java 11 modularity (jlink) #181

Open
vorburger opened this issue Nov 5, 2018 · 6 comments
Open

Smaller JDK base image using Java 11 modularity (jlink) #181

vorburger opened this issue Nov 5, 2018 · 6 comments

Comments

@vorburger
Copy link
Collaborator

once and after we'll have #160, then I think the idea also in raised #180 by @gunnarmorling re. a modular small JDK base image (jlink) is worth a dedicated issue ... let's discuss this further and some day implement under this issue? -- One of the points to IMHO clarify is:

  1. Could we just settle on a suitable list of JDK modules to hard code into the Java S2I base image (e.g. like what @gunnarmorling has done over here) ? Like obviously no UI stuff, and ditch really old and in practice un-used modules in modern server side containerized Java apps.

  2. Or is this an illusion and there would have to have some (complicated...) mechanism to chose modules, and have a multi-stage build, for JDK and application? (Urgh, with S2I.)

  3. May be a middle way and a (hopefully small) set of pre-baked S2I Java 11 image types with different JDK modules?

@gunnarmorling
Copy link

I think it'll be hard to define meaningful ready-made subsets, likely it will always be too little or too much for chosen applications. The modules to include should be determined by the specific build itself. In the example I built I used a hard-coded list I head determined upfront, but this can easily be automated by running the jdeps tool against all the JARs to be included:

jdeps --print-module-deps --class-path ...

The reason why I didn't do it is that jdeps works with JARs as input, i.e. it can only be run after the application JAR has been created. So this won't benefit from caching, if the application changes, also if the change doesn't lead to the inclusion of more modules.

@vorburger
Copy link
Collaborator Author

From @gunnarmorling comment over in #160 (which I want to keep focused on Java 11 itself):

Btw. the current OpenJDK 11 package on Fedora gives very bad results with jlink modular runtime images (huge size due to debug symbols), so I'd advise against using it).

This could be looked more into here and discussed with our OpenJDK friends when this gets picked up.

This was referenced Nov 7, 2018
vorburger added a commit to vorburger/s2i that referenced this issue Nov 21, 2018
@vorburger
Copy link
Collaborator Author

@gunnarmorling following up on a possible first step in the direction of this issue, and based on your comments on the original Java 11 PR over here re. java-11-openjdk-jmods ("I realized that for using jlink another package must be installed: java-11-openjdk-jmods. This brings in the jmod files with the JDK modules that are used by jlink to produce the modular runtime images."), do you think the base image should include this java-11-openjdk-jmods package? I'm proposing this in #198 for review & discussion...

@vorburger
Copy link
Collaborator Author

vorburger added a commit to vorburger/s2i that referenced this issue Dec 7, 2018
but do not install it on Java 8
vorburger added a commit that referenced this issue Dec 7, 2018
but do not install it on Java 8
@vorburger
Copy link
Collaborator Author

#198 just merged, but that's just the basic pre-req, there is more work here how to actually use this...

#198 has a very nice simple standalone example how to use jlink (thanks @gunnarmorling)

Perhaps https://maven.apache.org/plugins/maven-jlink-plugin/ could be of use for this as well?

vorburger added a commit that referenced this issue Dec 7, 2018
This reverts commit b9a5430.

This seemed to very significantly bloat the size of the image:
489 MB on hub.docker.com, 777 MB on local docker; as opposed to
448 MB locally and ca. 160-ish MB (?) on Hub without this.

So let's park this, until we pick up the overall
#181 idea,
and https://bugzilla.redhat.com/show_bug.cgi?id=1652177 is solved.

Until then, users of this image could technically still manually
build their own image FROM this one, and just add this:

    RUN yum -y install java-11-openjdk-jmods
@vorburger
Copy link
Collaborator Author

Actually to prepare #203, I just reverted the #198 again; with this, latest-java11 is down from 489 MB to 166 MB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants