I'm currently doing some research on how to use GraalVM in our project which by now contains an array of Micronaut apps.
I've followed this Micronaut article: https://guides.micronaut.io/latest/micronaut-creating-first-graal-app-maven-kotlin.html using Micronaut 3.5.2, JDK 17 and Kotlin.
Everything is working as expected on localhost (Ubuntu 20.04) when building the Docker image by using
mvn package -Dpackaging=docker-native and running the app using
docker run --publish 8080:8080 graal-test
Now I'm trying to figure out how to build GraalVM Docker images in Azure Pipelines without installing prerequisites for every build. There seems to be very little information about how to do this.
I'm able to run a successful build by adding these two script build steps. task.prependpath is in effect in next build step, hence two separate script steps.
- script: |
curl -Lo graalvm-archive.tar.gz https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.1.0/graalvm-ce-java17-linux-amd64-22.1.0.tar.gz
tar -xzf graalvm-archive.tar.gz
echo '##vso[task.prependpath]$(System.DefaultWorkingDirectory)/graalvm-ce-java17-22.1.0/bin'
- script: |
gu install native-image
sudo apt-get install build-essential libz-dev zlib1g-dev
native-image --version
Docker image build step.
# Build Docker image
- task: Maven@3
displayName: 'Build Docker'
inputs:
goals: 'package'
options: '-Pgraalvm -Dpackaging=docker-native -Djib.to.image=$(yourImageNameVar):$(yourImageTagVar) -DskipTests=true -Dmaven.javadoc.skip=true --batch-mode'
javaHomeOption: 'JDKVersion'
The resulting image has approx. virtual size 30MiB in GCR, and app startup time is less than 40ms in GKE.
Closest so far is this https://github.com/Azure/azure-sdk-for-java/issues/21735#issuecomment-867134666
The azure pipelines ubuntu 20.04 images recently added Graal CE 21.1.0: https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-README.md#graalvm
Unfortunately, the embedded link is broken.
Any hints on how to do this, will be highly appreciated.
Side-note
We managed to build 1 out of 5 Micronaut apps tested so far with GraalVM. There seems to be some issues with Kotlin and GraalVM.