Repository navigation
Fix forge dockerBuildNative by using a Java 21 GraalVM base image - #15579
Merged
Merged
Conversation
The Forge prev-snapshot GCP deploy workflow compiles the application with Java 21 but the dockerfileNative task pinned baseImage to ghcr.io/graalvm/jdk:ol8-java17-22.3.3, whose native-image tool only accepts class file version 61.0 (Java 17). The build failed with UnsupportedClassVersionError for both grails-forge-web-netty and grails-forge-analytics-postgres. Switch the baseImage to ghcr.io/graalvm/native-image-community:21, the canonical GraalVM Community image for Java 21 that bundles the native-image tool, matching the project's javaVersion=21 baseline and the workflow's setup-java configuration. Assisted-by: Claude Code <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Grails Forge native-image Docker build configuration to align the dockerBuildNative container image with the project’s Java 21 compilation baseline, avoiding native-image failures caused by running on a Java 17 GraalVM image.
Changes:
- Update
dockerfileNativebase image in Forge Netty web module to a Java 21 GraalVM Native Image community image. - Update
dockerfileNativebase image in Forge analytics-postgres module to the same Java 21 GraalVM Native Image community image.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| grails-forge/grails-forge-web-netty/build.gradle | Switches native-image Docker base image to a Java 21 GraalVM Native Image community image. |
| grails-forge/grails-forge-analytics-postgres/build.gradle | Switches native-image Docker base image to a Java 21 GraalVM Native Image community image. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
jdaugherty
approved these changes
Apr 16, 2026
Address Copilot review feedback on PR #15579: replace the floating major tag ghcr.io/graalvm/native-image-community:21 with the fully pinned 21.0.2-ol9 tag, restoring the patch-level pinning that the previous ghcr.io/graalvm/jdk:ol8-java17-22.3.3 reference provided. 21.0.2 is the final GraalVM Community release for JDK 21 (verified against ghcr.io/graalvm/native-image-community); later GraalVM Community releases target JDK 22+. Assisted-by: Claude Code <[email protected]>
Contributor
Author
jamesfredley
added a commit
that referenced
this pull request
Apr 16, 2026
PR #15579 updated the `dockerfileNative` baseImage to `ghcr.io/graalvm/native-image-community:21.0.2-ol9`, but the Forge prev-snapshot GCP deploy workflow still fails with `UnsupportedClassVersionError: class file version 65.0` because the generated Dockerfile's builder stage continues to emit: Step 1/13 : FROM ghcr.io/graalvm/native-image:ol7-java17-22.3.2 AS graalvm On Micronaut Gradle Plugin 3.7.10 (our pinned micronautApplicationPluginVersion), `baseImage(...)` on the `dockerfileNative` task only affects the final runtime stage of the multi-stage Dockerfile. The builder stage (`FROM ... AS graalvm`), where the `native-image` tool actually runs against our Java 21 bytecode, is controlled by the separate `graalImage` property. `graalImage`'s convention is derived from `jdkVersion` via `toGraalVMBaseImageName(graalVersion, jdkVersion)` -> `ghcr.io/graalvm/native-image:ol7-${jdkVersion}-${graalVersion}`, and `jdkVersion` is clamped by `NativeImageDockerfile.toSupportedJavaVersion` against `SUPPORTED_JAVA_VERSIONS = [17, 11]`. That silently rounds Java 21 down to Java 17, so even with the toolchain set to 21 the builder image still resolves to a Java 17 container that rejects class file version 65.0. Explicitly set `graalImage` to the same Java 21 community image we use for the runtime stage so both stages of the generated Dockerfile run on Java 21. This unblocks the failing job `grails-forge-web-netty:dockerBuildNative` (and the analytics module) on 8.0.x: https://github.com/apache/grails-core/actions/runs/24518601227 A longer-term fix is to upgrade `micronautApplicationPluginVersion` from 3.7.10 to 4.x, which adds first-class Java 21 and `native-image-community` support, but that is a larger change; this two-line override unblocks CI now. Assisted-by: claude-code:claude-opus-4-7
2 tasks done
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.
Summary
actions/setup-java+javaVersion=21ingradle.properties), but thedockerfileNativetask pinnedbaseImage('ghcr.io/graalvm/jdk:ol8-java17-22.3.3'). That GraalVM image runsnative-imageon Java 17, so it rejects the Java 21 bytecode and aborts withUnsupportedClassVersionError(class file version 65.0).grails-forge-web-netty:dockerBuildNativeandgrails-forge-analytics-postgres:dockerBuildNativefailed for the same reason.baseImagein both modules toghcr.io/graalvm/native-image-community:21, the canonical GraalVM Community image for Java 21 that ships with thenative-imagetool, matching the project's Java baseline.Failure excerpt
Verification
dockerBuildNativecannot be exercised in this environment (no Docker runtime), but the new image is the standard GraalVM Community Java 21 image used by the upstream Micronaut Starter project for the same task.Notes for reviewers
8.0.xbecause that is the branch where the deploy workflow runs and where the failure was observed.fix/branch prefix should auto-label this PR as a bug per.github/release-drafter.yml.