Hello-
I want to build a docker image for spring boot with tomcat enabled and JRE 21. I would run it later in Azure DevOps pipeline Agent based on RHEL 8.
I am creating the docker file but confused with the base image. i have created this docker file. Can anyone verify if this docker file i am missing anything ?
</>
Use Red Hat Universal Base Image (UBI) 8 as the base image
FROM registry.access.redhat.com/ubi8/ubi
Set environment variables
ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk
ENV PATH=$PATH:$JAVA_HOME/bin
Install OpenJDK 11 (replace with JDK 21 if available)
RUN yum install -y java-11-openjdk-devel &&
yum clean all
Copy the Spring Boot application JAR file into the container
COPY target/your-application.jar /app/your-application.jar
Expose port 8080 for Tomcat
EXPOSE 8080
Command to run the Spring Boot application
CMD [“java”, “-jar”, “/app/your-application.jar”]
</>
################################
if i have JDK 21 on my self hosted agent VM, do i need below in docker file
Install OpenJDK 11 (replace with JDK 21 if available)
RUN yum install -y java-11-openjdk-devel &&
yum clean all