Skip to content

Latest commit

 

History

History
60 lines (36 loc) · 1.93 KB

02-ce.md

File metadata and controls

60 lines (36 loc) · 1.93 KB

App Native Executable

Build the app native executable with GraalVM Community Edition

You can use GraalVM Community Native Image to generate a native executable for this app. We have a shell script that uses multistage Docker build to build the app JAR, generate the app native executable and ship the native executable in a separate runtime docker image.

./scripts/build-native-exec-ce.sh

Run this command to see the new docker image:

docker images -a

The output is similar to:

REPOSITORY                TAG     IMAGE ID       CREATED          SIZE
jibber-ni-gvmce22-jdk17   0.0.1   4334c3b5185c   24 seconds ago   91.1MB

Troubleshoot Native Image Build Errors

You may see this error while generating the native executable.

Image build request failed with exit status 137

Exit status 137 indicates an out of memory error. Try increasing the memory for Docker resource. On Mac, go to Docker Desktop >> Settings >> Resources. Increase the memory to 8 GB or higher.

Credits: https://stackoverflow.com/questions/68148868/micronaut-cannot-build-native-image-graalvm

Docker Memory Settings

Run the App Native Executable

A Docker Compose file has ben provided that will start the container. Most sections have been commented out. Feel free to uncomment sections, as needed.

Go to docker-compose.yml, comment the jibber-jar-gvmee-jdk17: section. Uncomment the jibber-ni-gvmce-jdk17: section and run the following command to run the app native executable.

docker compose up --remove-orphans

This will start the app native executable on port 8083. Go to http://localhost:8083/jibber in a browser and you should see a nonsense verse.

Stop the App Native Executable

From another terminal window, run the following command:

docker compose stop

Back to Table of Contents