# Start with a basic RHEL 9 Docker image
FROM <hostname>:<port>/ubi9:latest

# Update repo based on the current environment and conditions/constraints
# Uncomment the next three lines if using a custom repo
#RUN rm /etc/yum.repos.d/*
#COPY *.repo /etc/yum.repos.d/
#COPY dnf.conf /etc/dnf/
RUN yum update -y
RUN yum install unzip java-21-openjdk-devel -y
RUN yum groupinstall "Development Tools" -y
# Uncomment the next line if using a custom repo
#RUN rm -f /etc/yum.repos.d/redhat.repo

# Define all java home env variables
ENV JAVA_HOME=/lib/jvm/java-21-openjdk
ENV JAVAHOME=${JAVA_HOME}

# Install, configure, and run the Gradle tool
WORKDIR /opt
COPY gradle-8.14-bin.zip ./
RUN unzip -q gradle-8.14-bin.zip
RUN rm -f gradle-8.14-bin.zip
RUN ln mv gradle-* gradle
ENV GRADLE_HOME=/opt/gradle
RUN chmod +x ${GRADLE_HOME}/bin/gradle
ENV PATH=$PATH:${GRADLE_HOME}/bin
ENV JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8
RUN gradle

# Setup additional gradle/ssl settings as needed
WORKDIR /root
COPY gradle.properties .gradle/
# Add additional ssl settings as needed
