diff --git a/Dockerfile b/Dockerfile index f6e75771..8e850d68 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,4 @@ -# Stage 1: Build the application -FROM maven:3-eclipse-temurin-21 as builder +FROM maven:3-eclipse-temurin-21 as jar_builder # Set the working directory in the Maven image WORKDIR /app @@ -11,15 +10,29 @@ COPY pom.xml . # Build the application RUN mvn clean package -DskipTests -FROM python:3.11 +FROM maven:3-eclipse-temurin-21 + +# download system dependencies first to take advantage of docker caching +RUN apt-get update; apt-get install -y --no-install-recommends \ + build-essential \ + default-mysql-client \ + default-libmysqlclient-dev \ + python3 \ + python3-setuptools \ + python3-dev \ + python3-pip \ + unzip \ + perl \ + && rm -rf /var/lib/apt/lists/* \ + && pip3 install wheel # Install any needed packages specified in requirements.txt COPY requirements.txt ./ RUN pip install --no-cache-dir -r requirements.txt -# Install Perl. Some scripts are written in perl -RUN apt-get update && apt-get install -y perl +RUN ln -s $(which python3) /usr/local/bin/python || true +COPY --from=jar_builder /app/core-*.jar / COPY scripts/ scripts/ RUN chmod -R a+x /scripts/ @@ -28,25 +41,5 @@ WORKDIR /scripts/ ENV PORTAL_HOME=/ -COPY --from=builder /app/core-*.jar / -# Set environment variables for Java version and installation paths -ENV JAVA_VERSION 21 -ENV JAVA_HOME /usr/java/openjre-$JAVA_VERSION - -# Install necessary packages for adding repositories over HTTPS -RUN apt-get update && \ - apt-get install -y --no-install-recommends apt-transport-https ca-certificates wget dirmngr gnupg software-properties-common && \ - rm -rf /var/lib/apt/lists/* - -# Download and install OpenJRE 21 -# Note: The exact URL might change based on the latest available version, so replace it with the correct URL for JRE 21 -RUN mkdir -p "$JAVA_HOME" && \ - wget -O jdk21.tar.gz "https://download.oracle.com/java/21/latest/jdk-21_linux-x64_bin.tar.gz" && \ - tar xvf jdk21.tar.gz --strip-components=1 -C "$JAVA_HOME" && \ - rm jdk21.tar.gz - -# Add java to PATH -ENV PATH $JAVA_HOME/bin:$PATH - # This file is empty. It has to be overriden by bind mounting the actual application.properties RUN touch /application.properties