Skip to content

Commit

Permalink
2 stage Docker build to reduce size for singularity
Browse files Browse the repository at this point in the history
  • Loading branch information
jcschaff committed Jul 30, 2024
1 parent 8aacbd8 commit 9694197
Showing 1 changed file with 27 additions and 19 deletions.
46 changes: 27 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

0 comments on commit 9694197

Please sign in to comment.