DEV Community

Ed Legaspi
Ed Legaspi

Posted on • Edited on • Originally published at czetsuyatech.com

1

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"]
Enter fullscreen mode Exit fullscreen mode

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

docker build -t graalvm-base . 
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay