no

How to Compile a Quarkus Project Natively using Docker Builder

It's 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 set up 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 are the steps to follow:

1. Create a new Dockerfile with the following content. Make sure that the GraalVM version that you use matches the Java version in your project.

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 encounter 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