Hi, do you have recommendation for docker image to...
# server
t
Hi, do you have recommendation for docker image to run Kotlin backend services (JVM)? OpenJDK images are deprecated.
h
They changed the name, that’s why its deprecated. The new name is temurin (Eclipse Temurin by Adoptium). But I usually use the image from the hosting provider, like corretto when targeting AWS.
👍 4
j
https://github.com/docker-library/openjdk/issues/505
Now with projects like Eclipse Adoptium which produce Eclipse Temurin builds […] there is a natural replacement for a vendor neutral OpenJDK build […]
t
Thank you! I am going to try it.
j
Use jlink to build a minimal JRE that contains only the necessary components to run your app
👍 1
a
> Use jlink to build a minimal JRE that contains only the necessary components to run your app Not required, but doing so will build a much smaller image, which can speed up deployment/scaling times. Docker images don't really ship with a JRE-only release any more, so
jlink
is necessary to strip out the unnecessary JDK. But if you're going to go even further, you can strip out unnecessary modules of the JRE itself, but watch out, because any reflection you have might cause issues with this! jlink works even better if you choose the
slim
or
alpine
variant of an image, which is built on an even smaller OS than the standard
debian
base, leading to an even smaller docker image.
This is my standard Dockerfile. I don't strip the actual JRE, but maybe someday. Others can feel free to poke holes if they wish 😅 .
🙏 2
🙏🏾 1
d
Jib makes it very simple to make a docker image, it's just running a gradle task. Maybe jlink can be used with it too?
h
Yes, you can specify a custom docker image for jib, and you can use the one from Andrew and just keep the first copy step, copying the minified jdk.
d
How would that be automated in a CI?
Doesn't jlink need my source code?
j
No. If you want to automate the use of jlink then you invoke jdeps on your output class files or jar
🙏 1
h
How can you type so fast?…
😂 1
y
@jw do you happen to have an example illustrating this automation process?
Not much should have changed since then
y
Perfect! Thanks! Is there a way to get it executed as a part of gradle?
j
there might be plugins for it. otherwise both tools are in the JDK so you can use two custom
JavaExec
tasks for each operation
y
Thanks for the pointers!