S-Wing
S-Wing

Reputation: 591

Quarkus native container-build

I have write a small quarkus application and I create a native executable with the command:

mvn package -Pnative -Dquarkus.native.container-build=true

The process works fine (I'm able to deploy the app inside a docker container and everything works fine), but I don't understand what the packaging process (with the param -Dquarkus.native.container-build=true) does behind the scene (for example, I haven't GraalVm on my pc; how can the process create a native image? Does the process "start" a container with graal, package the java inside the container and then return the artifact?).
Searching online I find only tutorials to create native images for containers that don't explain how the process works.
Thanks for any explanation or suggestion on where to find useful information.

Upvotes: 1

Views: 2670

Answers (2)

Kobra
Kobra

Reputation: 1350

  1. Quarkus creates a Docker container with the necessary dependencies, including GraalVM, to build the native executable.
  2. The Quarkus build process copies the application's source code and dependencies into the container.
  3. The container builds the native executable using GraalVM.
  4. Once the build is complete, the container copies the native executable back to the host machine.
  5. The native executable is then packaged into a JAR file or a standalone executable, depending on the configuration.
  6. Now that the Linux native application is on the host machine, it can be used to create the docker image with it running

It's not easy to find documentation about this, could only find seeing the command it executes on the console and seeing the source code

Upvotes: 0

Jacouille
Jacouille

Reputation: 1121

Classic way

As stated in Quarkus Documentation, you'll need to install and configure GraalVM in order to be able to compile to native.

Mandrel or GraalVM installed and configured appropriately

You'll also need a working C environment

What does having a working C developer environment mean?

On Linux, you will need GCC, and the glibc and zlib headers.

...

On macOS, XCode provides the required dependencies

...

On Windows, you will need to install the Visual Studio 2017 Visual C++ Build Tools

Without GraalVM on your machine (but Linux only)

You could also tell quarkus that you don't have GraalVM (and don't want to bother installing it). Quarkus will use your container runtime to get what it needs to do its task. Simply add this param :

-Dquarkus.native.container-build=true

If this build should be done using a container runtime. Unless container-runtime is also set, docker will be used by default. If docker is not available or is an alias to podman, podman will be used instead as the default.

See reference for more info

Upvotes: -1

Related Questions