An article by Adam Warski focusing on optimization of deployment images. The JVM ecosystem has a lot of great traits, but small, cloud-deployment-friendly Docker images is not one of them.
Dockerizing even a simple application will result in an image that has hundreds of megabytes, as it needs to contain all dependencies (jars) and the whole JVM. Can we do anything about it?
The article then dives into:
- GraalVM and native-image utility
- Compile the Scala (Java/Kotlin/…) application to .jar files
- Use native-image to generate a native binary
- Create a docker image with the generated native binary
- An example using Scala + sbt
The author reduced the size of the docker image from 647MB to 26.5MB. Example code is also included. Great guide!
[Read More]