no

How to Compile a Quarkus Project Natively using GraalVM Docker as Builder

It's such a pain to build the same Quarkus project natively on different OSs . For instance, I'm working on both MacOS and Windo...

It's such a pain to build the same Quarkus project natively on different OSs. For instance, I'm working on both MacOS and Windows. In Windows I have to install a different set of dependencies plus the Visual studio redistributable library, which is a pain to setup as well, as it may cause multiple missing libraries if not configured correctly.

The solution is to build the project using a dockerized GraalVM image.

Here's the steps to follow:

1. Create a new Dockerfile with the following content.

FROM ghcr.io/graalvm/graalvm-ce:latest AS build
RUN gu install native-image
WORKDIR /project
VOLUME ["/project"]
ENTRYPOINT ["native-image"]

2. Build the image. In the folder where you create the Dockerfile, execute.

docker build -t graalvm-base . 

3. Use the local image from #2 to build your Quarkus project.

mvn clean package -DskipTests -Pnative -Dquarkus.native.container-build=true -Dquarkus.native.builder-image=graalvm-base

OR

quarkus build --native --no-tests -Dquarkus.native.container-build=true -Dquarkus.native.builder-image=graalvm-base

If you encountered an out of memory exception just add the "quarkus.native.native-image-xmx" parameter when running the build.

Related

quarkus 6128351618782230283

Post a Comment Default Comments

item