Skip to content

Commit

Permalink
Update to UBI9 builder images and UBI9 Quarkus Micro (runtime) image
Browse files Browse the repository at this point in the history
  • Loading branch information
cescoffier committed Feb 4, 2025
1 parent 2c8858a commit 8721003
Show file tree
Hide file tree
Showing 19 changed files with 131 additions and 61 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/native-cron-build.yml.disabled
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
run: sudo systemctl stop mysql

- name: Pull docker image
run: docker pull quay.io/quarkus/ubi-quarkus-graalvmce-builder-image:22.3-java${{ matrix.java }}
run: docker pull quay.io/quarkus/ubi9-quarkus-graalvmce-builder-image:22.3-java${{ matrix.java }}

- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v2
Expand Down Expand Up @@ -55,7 +55,7 @@ jobs:
run: ./mvnw -B install -DskipTests -DskipITs -Dformat.skip

- name: Run integration tests in native
run: ./mvnw -B --settings .github/mvn-settings.xml verify -f integration-tests/pom.xml --fail-at-end -Dno-format -Dtest-containers -Dstart-containers -Dnative -Dquarkus.native.container-build=true -Dquarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-graalvmce-builder-image:22.3-java${{ matrix.java }} -pl '!io.quarkus:quarkus-integration-test-google-cloud-functions-http,!io.quarkus:quarkus-integration-test-google-cloud-functions,!io.quarkus:quarkus-integration-test-funqy-google-cloud-functions'
run: ./mvnw -B --settings .github/mvn-settings.xml verify -f integration-tests/pom.xml --fail-at-end -Dno-format -Dtest-containers -Dstart-containers -Dnative -Dquarkus.native.container-build=true -Dquarkus.native.builder-image=quay.io/quarkus/ubi9-quarkus-graalvmce-builder-image:22.3-java${{ matrix.java }} -pl '!io.quarkus:quarkus-integration-test-google-cloud-functions-http,!io.quarkus:quarkus-integration-test-google-cloud-functions,!io.quarkus:quarkus-integration-test-funqy-google-cloud-functions'

- name: Report
if: always()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,24 @@ public class ContainerImages {
// === Native Builder images

// Mandrel Builder Image - https://quay.io/repository/quarkus/ubi-quarkus-mandrel-builder-image?tab=tags
public static final String MANDREL_BUILDER_IMAGE_NAME = "quay.io/quarkus/ubi-quarkus-mandrel-builder-image";
public static final String MANDREL_BUILDER_VERSION = NATIVE_BUILDER_VERSION;
public static final String MANDREL_BUILDER = MANDREL_BUILDER_IMAGE_NAME + ":" + MANDREL_BUILDER_VERSION;
public static final String UBI8_MANDREL_BUILDER_IMAGE_NAME = "quay.io/quarkus/ubi-quarkus-mandrel-builder-image";
public static final String UBI8_MANDREL_BUILDER_VERSION = NATIVE_BUILDER_VERSION;
public static final String UBI8_MANDREL_BUILDER = UBI8_MANDREL_BUILDER_IMAGE_NAME + ":" + UBI8_MANDREL_BUILDER_VERSION;

// Mandrel Builder Image - https://quay.io/repository/quarkus/ubi9-quarkus-mandrel-builder-image?tab=tags
public static final String UBI9_MANDREL_BUILDER_IMAGE_NAME = "quay.io/quarkus/ubi9-quarkus-mandrel-builder-image";
public static final String UBI9_MANDREL_BUILDER_VERSION = NATIVE_BUILDER_VERSION;
public static final String UBI9_MANDREL_BUILDER = UBI9_MANDREL_BUILDER_IMAGE_NAME + ":" + UBI9_MANDREL_BUILDER_VERSION;

// GraalVM CE Builder Image - https://quay.io/repository/quarkus/ubi-quarkus-graalvmce-builder-image?tab=tags
public static final String GRAALVM_BUILDER_IMAGE_NAME = "quay.io/quarkus/ubi-quarkus-graalvmce-builder-image";
public static final String GRAALVM_BUILDER_VERSION = NATIVE_BUILDER_VERSION;
public static final String GRAALVM_BUILDER = GRAALVM_BUILDER_IMAGE_NAME + ":" + GRAALVM_BUILDER_VERSION;
public static final String UBI8_GRAALVM_BUILDER_IMAGE_NAME = "quay.io/quarkus/ubi-quarkus-graalvmce-builder-image";
public static final String UBI8_GRAALVM_BUILDER_VERSION = NATIVE_BUILDER_VERSION;
public static final String UBI8_GRAALVM_BUILDER = UBI8_GRAALVM_BUILDER_IMAGE_NAME + ":" + UBI8_GRAALVM_BUILDER_VERSION;

// GraalVM CE Builder Image - https://quay.io/repository/quarkus/ubi9-quarkus-graalvmce-builder-image?tab=tags
public static final String UBI9_GRAALVM_BUILDER_IMAGE_NAME = "quay.io/quarkus/ubi9-quarkus-graalvmce-builder-image";
public static final String UBI9_GRAALVM_BUILDER_VERSION = NATIVE_BUILDER_VERSION;
public static final String UBI9_GRAALVM_BUILDER = UBI9_GRAALVM_BUILDER_IMAGE_NAME + ":" + UBI9_GRAALVM_BUILDER_VERSION;

public static String getDefaultJvmImage(CompiledJavaVersionBuildItem.JavaVersion version) {
switch (version.isJava21OrHigher()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public interface NativeConfig {

/**
* Defines the file encoding as in {@code -Dfile.encoding=...}.
*
* <p>
* Native image runtime uses the host's (i.e. build time) value of {@code file.encoding}
* system property. We intentionally default this to UTF-8 to avoid platform specific
* defaults to be picked up which can then result in inconsistent behavior in the
Expand Down Expand Up @@ -253,7 +253,16 @@ default boolean isExplicitContainerBuild() {
interface BuilderImageConfig {
/**
* The docker image to use to do the image build. It can be one of `graalvm`, `mandrel`, or the full image path, e.g.
* {@code quay.io/quarkus/ubi-quarkus-mandrel-builder-image:jdk-21}.
* {@code quay.io/quarkus/ubi9-quarkus-mandrel-builder-image:jdk-21}.
* <p>
* <strong>Note:</strong> Builder images are available using UBI 8 and UBI 9 base images, for example:
* <ul>
* <li>UBI 8: {@code quay.io/quarkus/ubi-quarkus-mandrel-builder-image:jdk-21} (UBI 8)</li>
* <li>UBI 9: {@code quay.io/quarkus/ubi9-quarkus-mandrel-builder-image:jdk-21} (UBI 9)</li>
* </ul>
* <p>
* You need to be aware that if you use a builder image using UBI9 and you plan to build a container, you must
* ensure that the base image used in the container is also UBI9.
*/
@WithParentName
@WithDefault("${platform.quarkus.native.builder-image}")
Expand All @@ -278,9 +287,9 @@ interface BuilderImageConfig {
default String getEffectiveImage() {
final String builderImageName = this.image().toUpperCase();
if (builderImageName.equals(BuilderImageProvider.GRAALVM.name())) {
return ContainerImages.GRAALVM_BUILDER;
return ContainerImages.UBI9_GRAALVM_BUILDER;
} else if (builderImageName.equals(BuilderImageProvider.MANDREL.name())) {
return ContainerImages.MANDREL_BUILDER;
return ContainerImages.UBI9_MANDREL_BUILDER;
} else {
return this.image();
}
Expand Down Expand Up @@ -346,7 +355,7 @@ default String getEffectiveImage() {
* If errors should be reported at runtime. This is a more relaxed setting, however it is not recommended as it
* means
* your application may fail at runtime if an unsupported feature is used by accident.
*
* <p>
* Note that the use of this flag may result in build time failures due to {@code ClassNotFoundException}s.
* Reason most likely being that the Quarkus extension already optimized it away or do not actually need it.
* In such cases you should explicitly add the corresponding dependency providing the missing classes as a
Expand All @@ -357,9 +366,9 @@ default String getEffectiveImage() {

/**
* Don't build a native image if it already exists.
*
* <p>
* This is useful if you have already built an image and you want to use Quarkus to deploy it somewhere.
*
* <p>
* Note that this is not able to detect if the existing image is outdated, if you have modified source
* or config and want a new image you must not use this flag.
*/
Expand Down Expand Up @@ -387,7 +396,7 @@ interface ResourcesConfig {
* <pre>
* quarkus.native.resources.includes = foo/**,bar/**&#47;*.txt
* </pre>
*
* <p>
* the files {@code src/main/resources/foo/selected.png} and {@code bar/some.txt} will be included in the native
* image, while {@code src/main/resources/ignored.png} will not be included.
* <p>
Expand Down Expand Up @@ -467,7 +476,7 @@ interface ResourcesConfig {
* quarkus.native.resources.includes = **&#47;*.png
* quarkus.native.resources.excludes = foo/**,**&#47;green.png
* </pre>
*
* <p>
* the resource {@code red.png} will be available in the native image while the resources {@code foo/green.png}
* and {@code bar/blue.png} will not be available in the native image.
*/
Expand Down Expand Up @@ -532,7 +541,7 @@ interface Compression {
/**
* Allows passing extra arguments to the UPX command line (like --brute).
* The arguments are comma-separated.
*
* <p>
* The exhaustive list of parameters can be found in
* <a href="https://github.com/upx/upx/blob/devel/doc/upx.pod">https://github.com/upx/upx/blob/devel/doc/upx.pod</a>.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ class NativeConfigTest {

@Test
public void testBuilderImageProperlyDetected() {
assertThat(createConfig("graalvm").builderImage().getEffectiveImage()).contains("ubi-quarkus-graalvmce-builder-image")
assertThat(createConfig("graalvm").builderImage().getEffectiveImage()).contains("ubi9-quarkus-graalvmce-builder-image")
.contains("jdk-21");
assertThat(createConfig("GraalVM").builderImage().getEffectiveImage()).contains("ubi-quarkus-graalvmce-builder-image")
assertThat(createConfig("GraalVM").builderImage().getEffectiveImage()).contains("ubi9-quarkus-graalvmce-builder-image")
.contains("jdk-21");
assertThat(createConfig("GraalVM").builderImage().getEffectiveImage()).contains("ubi-quarkus-graalvmce-builder-image")
assertThat(createConfig("GraalVM").builderImage().getEffectiveImage()).contains("ubi9-quarkus-graalvmce-builder-image")
.contains("jdk-21");
assertThat(createConfig("GRAALVM").builderImage().getEffectiveImage()).contains("ubi-quarkus-graalvmce-builder-image")
assertThat(createConfig("GRAALVM").builderImage().getEffectiveImage()).contains("ubi9-quarkus-graalvmce-builder-image")
.contains("jdk-21");

assertThat(createConfig("mandrel").builderImage().getEffectiveImage()).contains("ubi-quarkus-mandrel-builder-image")
assertThat(createConfig("mandrel").builderImage().getEffectiveImage()).contains("ubi9-quarkus-mandrel-builder-image")
.contains("jdk-21");
assertThat(createConfig("Mandrel").builderImage().getEffectiveImage()).contains("ubi-quarkus-mandrel-builder-image")
assertThat(createConfig("Mandrel").builderImage().getEffectiveImage()).contains("ubi9-quarkus-mandrel-builder-image")
.contains("jdk-21");
assertThat(createConfig("MANDREL").builderImage().getEffectiveImage()).contains("ubi-quarkus-mandrel-builder-image")
assertThat(createConfig("MANDREL").builderImage().getEffectiveImage()).contains("ubi9-quarkus-mandrel-builder-image")
.contains("jdk-21");

assertThat(createConfig("aRandomString").builderImage().getEffectiveImage()).isEqualTo("aRandomString");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void testBuilderImageBeingPickedUp() {
Collections.emptyList());
found = false;
for (String part : command) {
if (part.contains("ubi-quarkus-graalvmce-builder-image")) {
if (part.contains("ubi9-quarkus-graalvmce-builder-image")) {
found = true;
break;
}
Expand All @@ -42,7 +42,7 @@ void testBuilderImageBeingPickedUp() {
Collections.emptyList());
found = false;
for (String part : command) {
if (part.contains("ubi-quarkus-mandrel-builder-image")) {
if (part.contains("ubi9-quarkus-mandrel-builder-image")) {
found = true;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/asciidoc/aws-lambda.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ To extract the required ssl, you must start up a Docker container in the backgro
First, let's start the GraalVM container, noting the container id output.
[source,bash,subs=attributes+]
----
docker run -it -d --entrypoint bash quay.io/quarkus/ubi-quarkus-mandrel-builder-image:{mandrel-flavor}
docker run -it -d --entrypoint bash quay.io/quarkus/ubi9-quarkus-mandrel-builder-image:{mandrel-flavor}
# This will output a container id, like 6304eea6179522aff69acb38eca90bedfd4b970a5475aa37ccda3585bc2abdde
# Note this value as we will need it for the commands below
Expand Down
39 changes: 30 additions & 9 deletions docs/src/main/asciidoc/building-native-image.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ To see the `GreetingResourceIT` run against the native executable, use `./mvnw v
$ ./mvnw verify -Dnative
...
Finished generating 'getting-started-1.0.0-SNAPSHOT-runner' in 22.0s.
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildRunner] docker run --env LANG=C --rm --user 1000:1000 -v /home/zakkak/code/quarkus-quickstarts/getting-started/target/getting-started-1.0.0-SNAPSHOT-native-image-source-jar:/project:z --entrypoint /bin/bash quay.io/quarkus/ubi-quarkus-mandrel-builder-image:{mandrel-flavor} -c objcopy --strip-debug getting-started-1.0.0-SNAPSHOT-runner
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildRunner] docker run --env LANG=C --rm --user 1000:1000 -v /home/zakkak/code/quarkus-quickstarts/getting-started/target/getting-started-1.0.0-SNAPSHOT-native-image-source-jar:/project:z --entrypoint /bin/bash quay.io/quarkus/ubi9-quarkus-mandrel-builder-image:{mandrel-flavor} -c objcopy --strip-debug getting-started-1.0.0-SNAPSHOT-runner
[INFO] [io.quarkus.deployment.QuarkusAugmentor] Quarkus augmentation completed in 70686ms
[INFO]
[INFO] --- maven-failsafe-plugin:3.0.0-M7:integration-test (default) @ getting-started ---
Expand Down Expand Up @@ -421,6 +421,25 @@ These are regular Quarkus config properties, so if you always want to build in a
it is recommended you add these to your `application.properties` in order to avoid specifying them every time.
====

Executable built that way with the container runtime will be a 64-bit Linux executable, so depending on your operating system it may no longer be runnable.

[IMPORTANT]
====
Starting with Quarkus 3.19+, the _builder_ image used to build the native executable is based on UBI 9.
It means that the native executable produced by the container build will be based on UBI 9 as well.
So, if you plan to build a container, make sure that the base image in your `Dockerfile` is compatible with UBI 9.
The native executable will not run on UBI 8 base images.
You can configure the builder image used for the container build by setting the `quarkus.native.builder-image` property.
For example to switch back to an UBI8 _builder image_ you can use:
`quarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-mandrel-builder-image:{mandrel-flavor}`
You can see the available tags for UBI8 https://quay.io/repository/quarkus/ubi-quarkus-mandrel-builder-image?tab=tags[here]
and for UBI9 https://quay.io/repository/quarkus/ubi9-quarkus-mandrel-builder-image?tab=tags[here (UBI 9)])
====

[[tip-quarkus-native-remote-container-build]]
[TIP]
====
Expand All @@ -434,6 +453,7 @@ In this case, use the parameter `-Dquarkus.native.remote-container-build=true` i
The reason for this is that the local build driver invoked through `-Dquarkus.native.container-build=true` uses volume mounts to make the JAR available in the build container, but volume mounts do not work with remote daemons. The remote container build driver copies the necessary files instead of mounting them. Note that even though the remote driver also works with local daemons, the local driver should be preferred in the local case because mounting is usually more performant than copying.
====


[TIP]
====
Building with GraalVM instead of Mandrel requires a custom builder image parameter to be passed additionally:
Expand All @@ -446,7 +466,8 @@ Please note that the above command points to a floating tag.
It is highly recommended to use the floating tag,
so that your builder image remains up-to-date and secure.
If you absolutely must, you may hard-code to a specific tag
(see https://quay.io/repository/quarkus/ubi-quarkus-mandrel-builder-image?tab=tags[here] for available tags),
(see https://quay.io/repository/quarkus/ubi-quarkus-mandrel-builder-image?tab=tags[here (UBI 8)]
and https://quay.io/repository/quarkus/ubi9-quarkus-mandrel-builder-image?tab=tags[here (UBI 9)] for available tags),
but be aware that you won't get security updates that way and it's unsupported.
====

Expand Down Expand Up @@ -493,7 +514,7 @@ The project generation has provided a `Dockerfile.native-micro` in the `src/main

[source,dockerfile]
----
FROM quay.io/quarkus/quarkus-micro-image:2.0
FROM quay.io/quarkus/ubi9-quarkus-micro-image:2.0
WORKDIR /work/
COPY target/*-runner /work/application
RUN chmod 775 /work
Expand Down Expand Up @@ -578,7 +599,7 @@ Sample Dockerfile for building with Maven:
[source,dockerfile,subs=attributes+]
----
## Stage 1 : build with maven builder image with native capabilities
FROM quay.io/quarkus/ubi-quarkus-mandrel-builder-image:{mandrel-flavor} AS build
FROM quay.io/quarkus/ubi9-quarkus-mandrel-builder-image:{mandrel-flavor} AS build
COPY --chown=quarkus:quarkus --chmod=0755 mvnw /code/mvnw
COPY --chown=quarkus:quarkus .mvn /code/.mvn
COPY --chown=quarkus:quarkus pom.xml /code/
Expand All @@ -589,7 +610,7 @@ COPY src /code/src
RUN ./mvnw package -Dnative
## Stage 2 : create the docker final image
FROM quay.io/quarkus/quarkus-micro-image:2.0
FROM quay.io/quarkus/ubi9-quarkus-micro-image:2.0
WORKDIR /work/
COPY --from=build /code/target/*-runner /work/application
Expand All @@ -616,7 +637,7 @@ Sample Dockerfile for building with Gradle:
[source,dockerfile,subs=attributes+]
----
## Stage 1 : build with maven builder image with native capabilities
FROM quay.io/quarkus/ubi-quarkus-mandrel-builder-image:{mandrel-flavor} AS build
FROM quay.io/quarkus/ubi9-quarkus-mandrel-builder-image:{mandrel-flavor} AS build
USER root
RUN microdnf install findutils
COPY --chown=quarkus:quarkus gradlew /code/gradlew
Expand All @@ -630,7 +651,7 @@ COPY src /code/src
RUN ./gradlew build -Dquarkus.native.enabled=true
## Stage 2 : create the docker final image
FROM quay.io/quarkus/quarkus-micro-image:2.0
FROM quay.io/quarkus/ubi9-quarkus-micro-image:2.0
WORKDIR /work/
COPY --from=build /code/build/*-runner /work/application
RUN chmod 775 /work
Expand Down Expand Up @@ -661,7 +682,7 @@ Please see xref:native-and-ssl.adoc#working-with-containers[our Using SSL With N

[NOTE,subs=attributes+]
====
To use GraalVM CE instead of Mandrel, update the `FROM` clause to: `FROM quay.io/quarkus/ubi-quarkus-graalvmce-builder-image:{graalvm-flavor} AS build`.
To use GraalVM CE instead of Mandrel, update the `FROM` clause to: `FROM quay.io/quarkus/ubi9-quarkus-graalvmce-builder-image:{graalvm-flavor} AS build`.
====

=== Using a Distroless base image
Expand Down Expand Up @@ -702,7 +723,7 @@ Sample multistage Dockerfile for building an image from `scratch`:
[source,dockerfile,subs=attributes+]
----
## Stage 1 : build with maven builder image with native capabilities
FROM quay.io/quarkus/ubi-quarkus-graalvmce-builder-image:{graalvm-flavor} AS build
FROM quay.io/quarkus/ubi9-quarkus-graalvmce-builder-image:{graalvm-flavor} AS build
USER root
RUN microdnf install make gcc
COPY --chown=quarkus:quarkus mvnw /code/mvnw
Expand Down
Loading

0 comments on commit 8721003

Please sign in to comment.