With https://start.spring.io/ I created Spring Boot 3.x app with support for native image
I can build with gralde bootBuildImage
and run with docker run spring305gradlenativeimage:0.0.1-SNAPSHOT
How to use custom Dockerfile
or extend this docker image with additional packages?
build.gradle :
plugins {
id 'java'
id 'org.springframework.boot' version '3.0.5'
id 'io.spring.dependency-management' version '1.1.0'
id 'org.graalvm.buildtools.native' version '0.9.20'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-graphql'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework:spring-webflux'
testImplementation 'org.springframework.graphql:spring-graphql-test'
}
tasks.named('test') {
useJUnitPlatform()
}
P.S. I have checked https://graalvm.github.io/native-build-tools/latest/gradle-plugin.html and https://graalvm.github.io/native-build-tools/latest/javadocs/native-gradle-plugin/org/graalvm/buildtools/gradle/dsl/NativeImageOptions.html