Skip to content

deepaksorthiya/spring-boot-graalvm-native

Repository files navigation

Java Maven Build Test
Docker Pulls


** Spring Boot GraalVM Native Image **


Getting Started

Requirements:

Git: 2.49.0
Spring Boot: 3.5.0
Maven: 3.9+
Java GraalVM: 24
Docker Desktop: Tested on 4.42.0

Install GraalVM JDK 24

Using SDKMAN (Recommended)

sdk install java 24.0.2-graal

Install GraalVM JDK 24
Set GRAALVM_HOME as environment path.

Clone this repository:

git clone https://github.com/deepaksorthiya/spring-boot-graalvm-native.git
cd spring-boot-graalvm-native

Build Project Using Native Profile:

./mvnw -Pnative native:compile

It will generate a spring-boot-graalvm-native in target folder.

Run Project:

./target/spring-boot-graalvm-native

Build Docker Image(docker should be running):

Check pom.xml for native container image config

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <image>
            <name>deepaksorthiya/${project.artifactId}:latest</name>
            <publish>false</publish>
            <createdDate>${maven.build.timestamp}</createdDate>
            <builder>bellsoft/buildpacks.builder:musl</builder>
            <env>
                <BP_NATIVE_IMAGE>true</BP_NATIVE_IMAGE>
                <BP_JVM_VERSION>24</BP_JVM_VERSION>
            </env>
        </image>
        <layers>
            <enabled>true</enabled>
        </layers>
    </configuration>
</plugin>
./mvnw clean -Pnative spring-boot:build-image -DskipTests
docker build --progress=plain -f Dockerfile.native -t deepaksorthiya/spring-boot-graalvm-native .

Running On Docker

docker run -p 8080:8080 --name spring-boot-graalvm-native deepaksorthiya/spring-boot-graalvm-native

Testing

./mvnw -PnativeTest test

http://localhost:8080

http://localhost:8080/h2-console

Reference Documentation

For further reference, please consider the following sections:

Guides

The following guides illustrate how to use some features concretely:

About

spring boot graal native image and docker container image example

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors 2

  •  
  •