DEV Community

Mitz
Mitz

Posted on

Micronaut PetClinic with GraalVM > 19

Now you can run Micronaut PetClinic with the (kinda) latest GraalVM Native Image. I will explain the meaning later.

Build & Run

$ git clone https://github.com/bufferings/micronaut-petclinic.git
$ cd micronaut-petclinic

# Build Native Image. Please wait for 10-15 minutes.
$ ./mvnw package && docker build -t micronaut-petclinic .

# Start Database
$ docker-compose up -d db

# Run separately to see the log easily
$ docker-compose up app
Enter fullscreen mode Exit fullscreen mode

Start up time

It starts in a few hundreds of millis.

Docker Information

The image size is 130MB.

❯ docker images micronaut-petclinic
REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
micronaut-petclinic   latest              40834e227e19        About an hour ago   130MB
Enter fullscreen mode Exit fullscreen mode

and the memory usage is 125MB after using for a while

❯ docker ps -f name=micronaut-petclinic_app* -q | xargs docker stats --no-stream
CONTAINER ID        NAME                                     CPU %               MEM USAGE / LIMIT    MEM %               NET I/O             BLOCK I/O           PIDS
5c4c627ee81d        micronaut-petclinic_app_1_1350df269f2b   0.07%               124.3MiB / 15.4GiB   0.79%               158kB / 121kB       0B / 0B             11

Enter fullscreen mode Exit fullscreen mode

Background

I created Micronaut PetClinic last month and it worked as Native Image with GraalVM 1.0 RC16 to start surprisingly fast speed in a few hundreds of millis.

A few days later, GraalVM released a production version 19.0.0.
https://medium.com/graalvm/announcing-graalvm-19-4590cf354df8

But unfortunately, my PetClinic doesn't work with GraalVM 19 Native Image. (´・ω・`)

The cause is this issue:
https://github.com/oracle/graal/issues/1295

and we need this commit:
https://github.com/oracle/graal/commit/c6237d219a91c82b1954dfbfa0898ed917db09eb

The commit hasn't been included in the latest version 19.0.2 released yesterday.

Docker Image with the latest GraalVM

Then I found it works when I build GraalVM from its master branch. So I created a Docker image with the master branch:
https://hub.docker.com/r/bufferings/build-graalvm-docker

I would like to use it for a while until the commit is included in the GraalVM official release.

With Micronaut, it's so easy to create an application for Native Image, but I would like to talk about it another time (๑•̀ㅂ•́)و✧

Top comments (0)