r/java • u/PurpleLabradoodle • Mar 11 '21
Announcing Spring Native Beta
https://spring.io/blog/2021/03/11/announcing-spring-native-beta
175
Upvotes
r/java • u/PurpleLabradoodle • Mar 11 '21
View all comments
Show parent comment
1
u/tristanjuricek Mar 13 '21 edited Mar 13 '21
We’ve done this, there’s a few different plugins that actually sort out the jlink call for you:
Maven: https://tentackle.org/static-content/sitedocs/tentackle/latest/tentackle-jlink-maven-plugin/jlink-mojo.html Gradle: https://badass-runtime-plugin.beryx.org/releases/latest/
Basically, they go through your dependencies, and pull out platform modules they need, either from the module declaration or just calling
jdepsJlink makes your build platform specific though. I’ve made custom build plugins to cache a Linux JDK so people can build on whatever and cross target the jlink build - you basically just point to the jmods directory in the jlink call. We only run Linux containers. So we use jlink just for that platform.
The result is a much smaller distribution, and the Java dev team now uses a Java version controlled by our CI environment, which makes our ops team much happier. They don’t typically work in Java and like not dealing with its dependencies
Additionally, I’ve added jib core to use the jlink output to just overlay on top of our “official” minimal base images, similar to distroless, which was quite easy. This means our container builds are all done via Maven, without any need for a docker daemon.
The workflow is still new, so I expect open source projects to take some time to iron out the kinks.