Repository navigation
Spring Boot 4.0.9 + GraalVM native image on GHCR - #1
Merged
Merged
Conversation
- Boot 3.2.2 -> 4.0.9, Kotlin 2.2.21, Gradle 9.1.0, JDK/GraalVM 25 (bytecode 17) - starters: web -> webmvc, aop -> aspectj; Jackson 3 kotlin module; drop unused thymeleaf extras - spring-view-component 0.7.2 -> 0.9.1; remove unreferenced PersonActionViewComponent (@PutViewAction no longer exists) - fix toast template variable (toastContext -> toastCtx) - native: Dockerfile (GraalVM 25 nativeCompile -> distroless), runtime hints for templates and ViewContext binding - GitHub Actions: build on PRs, push ghcr.io/<repo>:<sha> and :latest on master/main
There was a problem hiding this comment.
🟡 Changes recommended
Manual workflow runs on feature branches can publish images as :latest, so publication must also be restricted to master/main to prevent overwriting the default-branch image.
1 open issue
What changed in this PR
Upgrades the Spring demo to Spring Boot 4 and adds GraalVM native container builds with GitHub Container Registry publication.
Changes:
- Updates Spring Boot, Kotlin, Gradle, and the JDK toolchain, with compatible dependencies.
- Adds native-image configuration and reflection/resource hints, fixes template expressions, and removes the unused person action component.
- Adds a multi-stage Docker build and CI for building and publishing native images.
| File | Description |
|---|---|
| src/main/kotlin/de/tschuehly/fullstackdemo/web/page/layout/LayoutViewComponent.kt | Removes an unused import. |
| src/main/kotlin/de/tschuehly/fullstackdemo/web/component/util/toast/ToastViewComponent.html | Corrects toast context references. |
| src/main/kotlin/de/tschuehly/fullstackdemo/web/component/util/advancedTable/AdvancedTableViewComponent.html | Uses native-compatible list indexing. |
| src/main/kotlin/de/tschuehly/fullstackdemo/web/component/person/action/PersonActionViewComponent.kt | Removes the unused legacy action component. |
| src/main/kotlin/de/tschuehly/fullstackdemo/web/component/person/action/PersonActionViewComponent.html | Removes its unused template. |
| src/main/kotlin/de/tschuehly/fullstackdemo/common/NativeHints.kt | Registers native template resources and reflection hints. |
| gradlew.bat | Refreshes the Windows Gradle launcher. |
| gradlew | Refreshes the Unix Gradle launcher. |
| gradle/wrapper/gradle-wrapper.properties | Selects Gradle 9.1.0. |
| Dockerfile | Builds a native executable and packages it in a nonroot runtime. |
| build.gradle.kts | Updates dependencies and toolchain; configures native compilation. |
| .github/workflows/native-image.yml | Adds native container builds and registry publication. |
| .dockerignore | Excludes local artifacts and slides from the build context. |
Review effort: Balanced
| with: | ||
| context: . | ||
| platforms: linux/amd64 | ||
| push: ${{ github.event_name != 'pull_request' }} |
…ges:write job - image label service=<kamal service> (Kamal deploy --skip-push checks it); CI asserts it - push trigger and publish guard: master only (default branch), so no other branch overwrites :latest - build/test job is read-only (contents: read, no persisted checkout token); publish job gets packages:write, runs only on push to master, loads the built image artifact and runs no repo code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Upgrades the demo from Spring Boot 3.2.2 to 4.0.9 and ships it as a GraalVM native image.
Upgrade
web→webmvc,aop→aspectj;tools.jackson.module:jackson-module-kotlin(Jackson 3)thymeleaf-extras-java8time/-springsecurity6@PutViewActionis gone, so the never-renderedPersonActionViewComponentwas removed; no page referenced ittoastContext→toastCtx); the save toast returned 500 beforeNative
Dockerfile:ghcr.io/graalvm/native-image-community:25runsnativeCompile, runtimegcr.io/distroless/base-debian12:nonroot(mostly-static binary)common/NativeHints.kt: resource hint for co-located templates, binding hints for allViewContextclasses +PersonFormDTOAdvancedTableViewComponent.html:tableRow.get(0)→tableRow[0](no reflection onArrays$ArrayList)CI
.github/workflows/native-image.yml: builds on PRs (no push); on push tomaster/mainpushesghcr.io/tschuehly/fullstack-with-spring:<sha>and:latest.Verified locally (arm64 native container):
/,/tables,/forms,/tabbed,/component/person/table,/component/person/modal/1,/lineChartComponent,PUT /api/person, webjars, static CSS,/actuator/healthall 200; startup 0.21 s; ~108 MiB container memory after ~95 requests.No DB and no env vars needed (all data in-memory). Not deployed.