GraalVM is here!

Good news everone, we are all super happy to tell you our JVM image has been updated substantialy. We now support OpenJDK 12 and GraalVM CE!

If you follow what's going on in the JVM space you have seen there is more and more choices available when it comes to running JVM-based applications. And we now support GraalVM CE. If you have no idea what it is, the best, simple explaination can be found on Julien Ponge's medium:

And as he explains that way better than I, I will jump into the how to run a GraalVM application on Clever Cloud.

We first need to find an appropriate Hello world project. Being a Ratpack fan I looked on Github and found this:

This is a gradle project with a script to build a native image, basically a binary with everything needed to run the application. No need for a JVM. So this is what we are going to build.

First to create the application, if you have clever-tools you can run: clever create --type gradle --plan M graalPack Now we need to setup the right environment variables.

clever env set CC_JAVA_VERSION graalvm-ce  # Select GraalVN CE as Java Version
clever env set GRADLE_DEPLOY_GOAL shadowJar # Specify the gradle goal, here we want to build a full jar.
clever env set CC_PRE_RUN_HOOK ./ # run the native image build
clever env set CC_RUN_COMMAND ./ratpack-graalvm-demo # specify the path of the native executable

I have modified a couple of things to make sure it would work smoothly on Clever Cloud. First thing, always define a rootProject name because gradle will pick the containing folder, which in our case the random application id, and generate the jar name with it. So you can't really use it in a script. Here's one liner to do it: echo ' = "ratpack-graalvm-demo"' > settings.gradle

The script already run gradlew shadowJar. I have removed it since this step is already made by Clever Cloud. Of course you could run it locally and only push the executable. This would also work.

Don't forget to add these changes to your git repository: git add settings.gradle && git commit -m"cleverify"

We are building a native image and this can be a super greedy process in terms of memory. To make sure we have some headroom we are going to use a bigger scaler. Run clever scale --flavor L to get the proper size. This might depend on the build you are running. Static analysis is not cheap. Later this week we'll show you how to proceed differently with a new CI project 🙂 But for now we'll stick to a bigger scaler.

Now all you have to do is run clever deploy and you will have your native image running on Clever Cloud. Benefits are mostly a reduced memory footprint and better performances at cold start. You can find more informations about this on the following blog post Ratpack on GraalVM – how to start?.

In the next days you can expect support for cool GraalVM features like the support for TruffelRuby or FastR). Let us know if you have any questions in the comments below!


À lire également

Clever Cloud joins the Eclipse Foundation: a commitment to the future of European open source

Clever Cloud, a French provider of Platform as a Service (PaaS) hosting and deployment solutions, is proud to become a contributing member of the Eclipse Foundation, a leading not-for-profit organisation in the field of open source.

Up to €100,000 in funding to adopt Hyper Open X technologies

The Hyper Open X consortium, made up of sixteen major French cloud players, has launched anambitious call for projects designed to accelerate the adoption of open source technologies for cloud and edge computing.

Clever Cloud announces international growth strategy and the expansion of leadership team

Nantes, France - Clever Cloud, French creator of Platform as a Service (PaaS) hosting and deployment solutions, announced today its intention to expand internationally, with a particular focus on the African and South Asian markets.
Company Press