Skip to content

rimerosolutions/graalvm-experiments

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Graalvm experiments with spring boot and docker

This project is unpolished, it’s not ready for copy-paste and pushing to PROD blindly…

  • Depending on how the code is written you may also run into GraalVM limitations by extending this program.
  • The main source of information that I found is the GraalVM Github issue tracker and some isolated articles online.

About the spring app

I just did some experiments with Spring Boot and GraalVM based on a existing Github project. This required some “”exploration” to run on Docker successfully.

./screenshot.png

Requirements

  • A Linux desktop or server or virtualized environment.
  • A recent version of Docker with support for multi-stage builds.

Building

dockerbuild.sh will trigger the docker build and create a `springdemo` image.

  • The spring boot application employs Gradle instead of Maven for speeding up the multi-stage build and not downloading the entire internet itself
  • More details can be found in the Dockerfile which is rather small

Resulting docker image

Image size

While the build process to native code takes a bit of time, the resulting image runs on top of a minimal busybox+glibc layer (about 45MB). I wasn’t able to use scratch, other users run into similar problems.

Traditionally, most Java docker images will be usually share similar characteristics:

  • At least 30MB+ (Just for a JRE)
  • Couple of MBs for the base Linux system (Alpine, Busybox) unless using moderately bloated Linux images (Fedora, Debian, etc.)
  • Few MBs for dealing with GLibc required libraries, especially for apps that require networking (cryptic crashes)
  • The Spring application size would mainly depend on dependencies you have and how complex the program is
[mrcheeks@localhost docker-graalvm]$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
springdemo          latest              980375e9d972        About a minute ago   45.4MB
<none>              <none>              c5b69e95b047        2 hours ago          47.1MB
<none>              <none>              735802906281        2 hours ago          1.99GB
<none>              <none>              2cb7f615546d        2 hours ago          1.68GB
fedora              27                  7a2e85963474        9 days ago           236MB
busybox             1.29.2-glibc        c041448940c8        6 weeks ago          4.42MB
[mrcheeks@localhost docker-graalvm]$

Speed

While I haven’t measured or benchmarked anything, it feels faster, especially the startup time. Memory usage would have to also be checked over time with samples.

Signal handling

The final image has a small init system (Tini) for handling signals (control-c on the terminal, etc.).

Releases

No releases published

Packages

No packages published