Spring Boot GraalVM Native Image
3.5K
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
Set GRAALVM_HOME as environment path.
git clone https://github.com/deepaksorthiya/spring-boot-graalvm-native.git
cd spring-boot-graalvm-native
./mvnw -Pnative native:compile
It will generate a spring-boot-graalvm-native in target folder.
./target/spring-boot-graalvm-native
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 .
docker run -p 8080:8080 --name spring-boot-graalvm-native deepaksorthiya/spring-boot-graalvm-native
./mvnw -PnativeTest test
http://localhost:8080/h2-console
For further reference, please consider the following sections:
The following guides illustrate how to use some features concretely:
Content type
Image
Digest
sha256:bf950f5a0…
Size
48.2 MB
Last updated
about 1 year ago
docker pull deepaksorthiya/spring-boot-graalvm-native