fabric8io-images / java

Java Base Images
Apache License 2.0
176 stars 99 forks source link

Support to OpenJDK 17? #70

Open aldoborrero opened 2 years ago

aldoborrero commented 2 years ago

Is it possible to add support to OpenJDK 17 LTS?

mzellho commented 2 years ago

@aldoborrero: Using Quarkus, I'd love to have a OpenJDK 17 version too. For experimental purposes, I cloned the repo and did an ubi 8.4 / OpenJDK 17 image myself, but presumably there is some more work to do:

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

USER root

RUN mkdir -p /deployments

# JAVA_APP_DIR is used by run-java.sh for finding the binaries
ENV JAVA_APP_DIR=/deployments \
    JAVA_MAJOR_VERSION=17

# /dev/urandom is used as random source, which is prefectly safe
# according to http://www.2uo.de/myths-about-urandom/
RUN microdnf install java-17-openjdk-headless-17.0.1.0.12-2.el8_5.x86_64 \
      openssl curl ca-certificates \
    && echo "securerandom.source=file:/dev/urandom" >> /usr/lib/jvm/jre/lib/security/java.security \
    && microdnf clean all

ENV JAVA_HOME /etc/alternatives/jre

# Agent bond including Jolokia and jmx_exporter
ADD agent-bond-opts /opt/run-java-options
RUN mkdir -p /opt/agent-bond \
 && curl https://repo.maven.apache.org/maven2/io/fabric8/agent-bond-agent/1.2.0/agent-bond-agent-1.2.0.jar \
          -o /opt/agent-bond/agent-bond.jar \
 && chmod 444 /opt/agent-bond/agent-bond.jar \
 && chmod 755 /opt/run-java-options
ADD jmx_exporter_config.yml /opt/agent-bond/
EXPOSE 8778 9779

# Add run script as /deployments/run-java.sh and make it executable
COPY run-java.sh /deployments/
RUN chmod 755 /deployments/run-java.sh

# Run under user "1001" and prepare for be running
# under OpenShift, too
RUN chown 1001 /deployments \
    && chmod "g+rwX" /deployments \
    && chown 1001:root /deployments \
    && chmod g+rw /etc/passwd \
    && mkdir -p /deployments/data \
    && chown 1001 /deployments/run-java.sh

# Gives uid
USER 1001

CMD [ "/deployments/run-java.sh" ]
aldoborrero commented 2 years ago

Hi @mzellho thanks for sharing! I forget to mention that I forked the repository and added preliminary support to Centos8 / JDK17. Unfortunately Centos8 will finish support on December (which is now).

Maybe we can integrate your work on ubi in that repository as well.

mzellho commented 2 years ago

@aldoborrero Oh, that is good news! I've got the feeling that it would be a good idea to go to ubi 8.5 as well (as the OpenJDK package seems like it's meant to be used in an 8.5 context, too). I have not made any tests here, just few very tiny steps, and unfortunately there is not too much time for more testing. But if you think that it would be a good add-on to your repository already, I'll happily contribute.

aldoborrero commented 2 years ago

@mzellho feel free to take a look to the repository as I added support to UBI 8.5 and also to Alpine and Ubuntu 20.04.

Would you mind to test it? I'll do my part on Ubuntu as I need that particular image for what I'm currently working on. As this is still a much WIP I haven't uploaded any of the images to Docker Hub.