tools400 opened a new pull request, #27617: URL: https://github.com/apache/camel/pull/27617
# Description JIRA: [CAMEL-25495](https://issues.apache.org/jira/browse/CAMEL-25495) ## What is wrong `camel export --runtime=quarkus` writes `src/main/docker/Dockerfile` and `Dockerfile.jvm` with a fixed base image, `registry.access.redhat.com/ubi9/openjdk-21-runtime:1.24`, whatever `--java-version` says. With `--java-version=25` the exported project is compiled for Java 25 (`maven.compiler.release` is 25), but the image runs it on a Java 21 runtime, so the container cannot start (`UnsupportedClassVersionError`). Camel Main and Spring Boot pick their Dockerfile template by `--java-version` (`Dockerfile21.ftl` / `Dockerfile25.ftl`, `Dockerfile-spring-boot21.ftl` / `Dockerfile-spring-boot25.ftl`, CAMEL-23088). The Quarkus fast-jar Dockerfile, `quarkus-docker/Dockerfile.jvm` (CAMEL-23192), is copied verbatim by `ExportQuarkus.copyDockerFiles` and never got a Java 25 variant. The `uber-jar` package type is not affected: it uses the Camel Main template. 4.22.1, `camel-4.22.x` and `main` are affected. ## Steps to reproduce ```shell camel init cheese.yaml camel export cheese.yaml --runtime=quarkus --java-version=25 --gav=org.example:cheese:1.0.0 --dir=cheese grep '^FROM' cheese/src/main/docker/Dockerfile cheese/src/main/docker/Dockerfile.jvm # cheese/src/main/docker/Dockerfile:FROM registry.access.redhat.com/ubi9/openjdk-21-runtime:1.24 # cheese/src/main/docker/Dockerfile.jvm:FROM registry.access.redhat.com/ubi9/openjdk-21-runtime:1.24 ``` ## Fix - `quarkus-docker/Dockerfile.jvm` becomes the FreeMarker templates `Dockerfile-quarkus21.ftl` and `Dockerfile-quarkus25.ftl`, like the Camel Main and Spring Boot ones. Their content is the former file plus the `<#-- -->` license header the templates carry; the Java 25 one differs only in `FROM ubi9/openjdk-25-runtime:1.24`. - `Export.copyDockerFiles` keeps its behaviour; the selection by Java version, with the fallback to the Java 21 template and its message, moves into `Export.processDockerfileTemplate(templateName, model)`. - `ExportQuarkus.copyDockerFiles` uses it for the fast-jar Dockerfile. `Dockerfile.jvm` is still a copy of `Dockerfile`; the native Dockerfiles are unchanged. ## Tests | Test | Asserts | |---|---| | `ExportTest.shouldUseJavaVersionInDockerFiles` (Quarkus, Spring Boot, Camel Main × Java 21, 25) | every exported Dockerfile that uses a `ubi9/openjdk-` image uses the requested Java version and not the other one | | `TemplateHelperTest.testDockerfileQuarkus21Template`, `testDockerfileQuarkus25Template` | the templates render without license header or unresolved interpolation, with the expected base image | The new export test fails against `main` for Quarkus with Java 25 only; the other five cases pass. In `dsl/camel-jbang/camel-jbang-core`, `ExportTest` (138 tests) and `TemplateHelperTest` (33 tests) are green. `mvn clean install -DskipTests` in the module leaves no uncommitted changes. With the fix, the reproducer above run with the locally built Camel CLI 4.23.0-SNAPSHOT exports both Dockerfiles with `ubi9/openjdk-25-runtime:1.24`; with Camel CLI 4.22.1 it prints the output shown. I did not run a root `mvn clean install -DskipTests`. _Changes prepared with Claude Code on behalf of @tools400._ # Target - [x] I checked that the commit is targeting the correct branch (Camel 4 uses the `main` branch) # Tracking - [x] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it). <!-- # *Note*: trivial changes like, typos, minor documentation fixes and other small items do not require a JIRA issue. In this case your pull request should address just this issue, without pulling in other changes. --> # Apache Camel coding standards and style - [x] I checked that each commit in the pull request has a meaningful subject line and body. <!-- If you're unsure, you can format the pull request title like `[CAMEL-XXX] Fixes bug in camel-file component`, where you replace `CAMEL-XXX` with the appropriate JIRA issue. --> - [ ] I have run `mvn clean install -DskipTests` locally from root folder and I have committed all auto-generated changes. <!-- You can run the aforementioned command in your module so that the build auto-formats your code. This will also be verified as part of the checks and your PR may be rejected if if there are uncommited changes after running `mvn clean install -DskipTests`. You can learn more about the contribution guidelines at https://github.com/apache/camel/blob/main/CONTRIBUTING.md --> # AI-assisted contributions - [x] If this PR includes AI-generated code, commits have proper co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR description identifies the AI tool used. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
