From 96941976f32284bb1a68b940bc4796f5e4575399 Mon Sep 17 00:00:00 2001 From: jcschaff Date: Mon, 29 Jul 2024 23:48:16 -0400 Subject: [PATCH] 2 stage Docker build to reduce size for singularity --- Dockerfile | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8f36089c..22191083 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,25 +1,10 @@ -FROM eclipse-temurin:17-jdk-jammy +FROM eclipse-temurin:17-jdk-jammy as build RUN apt-get -y update && apt-get install -y apt-utils && \ apt-get install -y -qq -o=Dpkg::Use-Pty=0 build-essential gfortran zlib1g-dev \ - libhdf5-dev libcurl4-openssl-dev libboost-dev cmake wget python3 && \ + libhdf5-dev libcurl4-openssl-dev libboost-dev cmake wget python3 python3-pip && \ apt-get install -q -y --no-install-recommends curl dnsutils -# Create a custom Java runtime -RUN $JAVA_HOME/bin/jlink \ - --add-modules ALL-MODULE-PATH \ - --strip-debug \ - --no-man-pages \ - --no-header-files \ - --compress=2 \ - --output /javaruntime - -ENV JAVA_HOME=/javaruntime -ENV PATH="${JAVA_HOME}/bin:${PATH}" - -ENV DEBIAN_FRONTEND=noninteractive -ENV LANG=en_US.UTF-8 - COPY . /vcellroot RUN mkdir -p /vcellroot/build/bin @@ -40,8 +25,31 @@ RUN /usr/bin/cmake \ -DOPTION_TARGET_HY3S_SOLVERS=OFF \ .. && \ make && \ - ctest -VV && \ - mv /vcellroot/build/bin /vcellbin + ctest -VV + +FROM eclipse-temurin:17-jdk-jammy as runtime + +RUN apt-get -y update && apt-get install -y apt-utils && \ + apt-get install -y -qq -o=Dpkg::Use-Pty=0 build-essential gfortran zlib1g-dev \ + libhdf5-dev libcurl4-openssl-dev libboost-dev cmake wget python3 python3-pip && \ + apt-get install -q -y --no-install-recommends curl dnsutils + +# Create a custom Java runtime +RUN $JAVA_HOME/bin/jlink \ + --add-modules ALL-MODULE-PATH \ + --strip-debug \ + --no-man-pages \ + --no-header-files \ + --compress=2 \ + --output /javaruntime + +ENV JAVA_HOME=/javaruntime +ENV PATH="${JAVA_HOME}/bin:${PATH}" + +ENV DEBIAN_FRONTEND=noninteractive +ENV LANG=en_US.UTF-8 + +COPY --from=build /vcellroot/build/bin /vcellbin WORKDIR /vcellbin ENV PATH=/vcellbin:$PATH