diff --git a/docker/Dockerfile b/docker/Dockerfile index ec8c68c4a07e038b3417402ee68dba77bb0ccf1a..e9e10859da0b500fbed4dcd58f26ae90c905d147 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,20 +1,31 @@ -# Ubuntu image as base -FROM ubuntu:18.04 +FROM ubuntu:22.04 -# Set environment variables +# Set noninteractive mode to prevent prompts during installation ENV DEBIAN_FRONTEND=noninteractive -# Install system dependencies +# Install required system dependencies RUN apt-get update && apt-get install -y \ wget \ + sudo \ + curl \ git \ - libssl-dev \ + build-essential \ libcurl4-openssl-dev \ + libssl-dev \ libxml2-dev \ libxt-dev \ + pandoc \ + libclang-dev \ + libpq-dev \ + libgit2-dev \ gdebi-core \ + 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 @@ -31,6 +42,7 @@ 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 \ @@ -42,9 +54,22 @@ RUN conda create --name neuroestimator -y \ r-remotes \ 'r-reticulate<=1.24' -# Activate environment and install NEUROeSTIMator -RUN /bin/bash -c "source activate neuroestimator && \ - R -e 'remotes::install_git(\"https://research-git.uiowa.edu/michaelson-lab-public/neuroestimator\")'" +# 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 + +# Ensure RStudio uses Conda's R +RUN echo 'export RSTUDIO_WHICH_R="/opt/miniconda/envs/neuroestimator/bin/R"' >> /etc/profile.d/rstudio.sh + +# Install NEUROeSTIMator in the Conda environment +RUN conda run -n neuroestimator R -e "remotes::install_git('https://research-git.uiowa.edu/michaelson-lab-public/neuroestimator')" + +# Ensure Conda environment is activated on container start +SHELL ["/bin/bash", "-c"] + +# Expose RStudio Server port +EXPOSE 8787 -# Set entrypoint to bash -ENTRYPOINT ["/bin/bash"] +# Set the entrypoint to start RStudio Server +ENTRYPOINT ["/bin/bash", "-c", "source activate neuroestimator && /usr/lib/rstudio-server/bin/rserver --server-daemonize=0"]