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 Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more →

Top comments (0)

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site