/Create-JRE-using-Docker

Create a minimal JRE around a Maven project and ship it as Docker images

Primary LanguageJavaMIT LicenseMIT

Create-JRE-using-Docker-Example

Create a minimal JRE around a Maven project and ship it as lightweight Docker image

Docker Images Snapshot

Repository content

  • /server folder contains a lazy Hello-World webserver based on Javalin. The code is packaged as single Jar using the maven-assembly-plugin

    • run.sh is the entrypoint for the dockerized application
  • Dockerfile describes 4 images based on the blazing fast GraalVM CE JDK artifact:

    1. base_image: Ubuntu 22.04 docker image + GraalVM CE JDK

    2. server_builder: builds the maven project and creates the minimal JRE. Base modules are discovered using jdeps and exported as JRE distribution by jlink

    Docker Minimal JRE Image Snapshot

    1. minimal_jre_image: ships the minimal JRE for the server application

    2. jdk_image: contains the whole GraalVM JDK

Size reduction

Image Size vs JDK vs JRE
JDK 835MB - 618%
JRE 135MB 16% -

The jre based image is 84% smaller than the optimized-jre one

Start-up time reduction

Image Time vs JDK vs JRE
JDK 502ms - 127%
JRE 395ms 78% -

The jre based image is 22% faster to start-up than the optimized-jre one