From e9dbd950e84117083c3294f398002130969085ed Mon Sep 17 00:00:00 2001 From: Fortune Iriaye <firiaye@uab.edu> Date: Mon, 24 Feb 2025 10:28:02 -0600 Subject: [PATCH] Update Dockerfile to implement multi-stage build --- docker/Dockerfile | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index f2f6849..694fd1a 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:22.04 +FROM tensorflow/tensorflow:1.15.0 AS tensorflow # Set noninteractive mode to prevent prompts during installation ENV DEBIAN_FRONTEND=noninteractive @@ -10,7 +10,7 @@ RUN apt-get update && apt-get install -y \ curl \ git \ build-essential \ - libcurl4-openssl-dev \ + libcurl4-openssl-dev || apt-get install -y libcurl4-gnutls-dev \ libssl-dev \ libxml2-dev \ libxt-dev \ @@ -22,13 +22,6 @@ RUN apt-get update && apt-get install -y \ psmisc \ && rm -rf /var/lib/apt/lists/* -# Create an RStudio user with sudo access -RUN useradd -m -s /bin/bash rstudio && echo "rstudio:rstudio" | chpasswd && \ - usermod -aG sudo rstudio - -# Set working directory -WORKDIR /root - # Install Miniconda RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh && \ bash miniconda.sh -b -p /opt/miniconda && \ @@ -42,7 +35,6 @@ RUN echo "channels:\n - conda-forge\n - bioconda\n - defaults\n - r" > /root # Create Conda environment and install dependencies RUN conda create --name neuroestimator -y \ - r-essentials \ tensorflow=1.15.0 \ tensorflow-estimator=1.15.1 \ r-keras=2.3.0.0 \ @@ -54,10 +46,23 @@ RUN conda create --name neuroestimator -y \ r-remotes \ 'r-reticulate<=1.24' -# Install RStudio Server -RUN wget https://download2.rstudio.org/server/jammy/amd64/rstudio-server-2024.12.1-563-amd64.deb -O rstudio-server.deb && \ - dpkg -i rstudio-server.deb || apt-get -f install -y && \ - rm rstudio-server.deb +# Rstudio setup +FROM rocker/rstudio:4.3.3 AS rstudio + +# Set environment variables + +ENV DEBIAN_FRONTEND=noninteractive +ENV PATH="/opt/miniconda/bin:$PATH" + +# Copy Tensorflow and Miniconda environment +COPY --from=tensorflow /opt/miniconda /opt/miniconda +COPY --from=tensorflow /root/.condarc /root/.condarc + +# Create an Rstudio User + +RUN id -u rstudio >/dev/null 2>&1 || useradd -m -s /bin/bash rstudio && \ + echo "rstudio:rstudio" | chpasswd && \ + usermod -aG sudo rstudio # Ensure RStudio uses Conda's R RUN echo 'export RSTUDIO_WHICH_R="/opt/miniconda/envs/neuroestimator/bin/R"' >> /etc/profile.d/rstudio.sh -- GitLab