Quarkus: Provide ubi-minimal with java installed

Created on 8 Jul 2020  路  11Comments  路  Source: quarkusio/quarkus

Description
The current standard Quarkus JVM Dockerfile (as of provided by code.quarkus.io) is based on the registry.access.redhat.com/ubi8/ubi-minimal:8.1 image. Since this image does not include java and an updated microdnf, it always takes quite a while to build the first layers of this image. This is especially true for our CI builds, as they don't always have the previous layers cached (mutliple machines) and thus we have longer build times than needed.

Therefore, I would like to propose to provide something like a ubi-minimal-java:8.1-java11 or even a ubi-minimal-quarkus:8.1-quarkus1.5.2 image that includes everything of the standard JVM Dockerfile up until the actual application libraries are copied into the container.

Implementation ideas
Automatically build a regularly updated version with the main part of the standard quarkus jvm Dockerfile (see below) and publish it on a docker repository.

FROM registry.access.redhat.com/ubi8/ubi-minimal:8.1

ARG JAVA_PACKAGE=java-11-openjdk-headless
ARG RUN_JAVA_VERSION=1.3.8

ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'

# Install java and the run-java script
# Also set up permissions for user `1001`
RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \
    && microdnf update \
    && microdnf clean all \
    && mkdir /deployments \
    && chown 1001 /deployments \
    && chmod "g+rwX" /deployments \
    && chown 1001:root /deployments \
    && curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION}-sh.sh -o /deployments/run-java.sh \
    && chown 1001 /deployments/run-java.sh \
    && chmod 540 /deployments/run-java.sh \
    && echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/lib/security/java.security

# Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size.
ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
kinenhancement

Most helpful comment

Furthermore, it would be interesting to have a Java 14 version as well. If I understand correctly, Quarkus should run on Java 14, am I right? Unfortunately, I wasn't able to figure out how to install Java 14 with microdnf. Simply updating the java-11-openjdk-headless to java-14-openjdk-headless does not work.

All 11 comments

@maxandersen @tqvarnst AFAIK this is planned, right?

AFAIK, this is something that RHEL/OpenJDK is planing. In theory, we could potentially package and publish a Quarkus Runtime Java image on Quay, but it would be a huge maintenance effort. So we might be better of waiting for RHEL to publish such an image.

I will follow-up with the OpenJDK team to see what the status of a UBI-minimal-java image provided and maintained by Red Hat is.

ubi8/openjdk-11 maintainer here: it is based on ubi-minimal but contains the -devel rpm package (javac etc) as well as mvn so it's not a pure runtime image. I got @tqvarnst's email and have followed up internally, hopefully we'll have more to write publically soon!

Furthermore, it would be interesting to have a Java 14 version as well. If I understand correctly, Quarkus should run on Java 14, am I right? Unfortunately, I wasn't able to figure out how to install Java 14 with microdnf. Simply updating the java-11-openjdk-headless to java-14-openjdk-headless does not work.

The JDK 14 packages are called java-latest-openjdk-* e.g. java-latest-openjdk-headless etc

Not sure if this solves the initial issue, but we're running Quarkus on Java 14 on a ubi-minimal (8.2) based image by Eclipse Adoptium (AdoptOpenJDK), adoptopenjdk/openjdk14:jre-14.0.2_12-ubi-minimal.

Here's our slightly modified Dockerfile

FROM adoptopenjdk/openjdk14:jre-14.0.2_12-ubi-minimal

ARG RUN_JAVA_VERSION=1.3.8

ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'

# Install java and the run-java script
# Also set up permissions for user `1001`
RUN microdnf install curl ca-certificates \
    && microdnf update \
    && microdnf clean all \
    && mkdir /deployments \
    && chown 1001 /deployments \
    && chmod "g+rwX" /deployments \
    && chown 1001:root /deployments \
    && curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION}-sh.sh -o /deployments/run-java.sh \
    && chown 1001 /deployments/run-java.sh \
    && chmod 540 /deployments/run-java.sh \
    && echo "securerandom.source=file:/dev/urandom" >> $JAVA_HOME/lib/security/java.security

# Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size.
ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"

COPY target/lib/* /deployments/lib/
COPY target/*-runner.jar /deployments/app.jar

EXPOSE 8080
USER 1001

ENTRYPOINT [ "/deployments/run-java.sh" ]

@jmtd there is no java-latest-openjdk-headles package available for ubi-minimal

error: No package matches 'java-latest-openjdk-headless'

Is there an easy way to update the default Quarkus Dockerfile to use Java 14 or should I move out of ubi-minimal ?

Hi @loicmathieu, oh, that's interesting. I'm afraid it's not in the full-fat UBI, either, it must not be in the set of RHEL8 packages that are distributed in UBI. That might be a mistake, though, I'll see if (and how) we can get it included.

Hi: Further, actually that package is not in RHEL8 at all. It is in the EPEL repositories, however. Does that help?

Was this page helpful?
0 / 5 - 0 ratings