From bf624abeaf1a7749a196d9eec147083a62e0d5a6 Mon Sep 17 00:00:00 2001 From: YuviPanda Date: Wed, 1 Nov 2023 23:21:34 +0530 Subject: [PATCH 1/2] Switch base to rocker/binder image - Matches what we do in other images - Simplifies this image *a lot* - Knitting still takes time the *first time* even if we just switch to new base image. But https://github.com/rocker-org/rocker-versioned2/pull/714 installs some of the texlive packages that are being installed the first time, and should speed things up. Ref https://github.com/2i2c-org/infrastructure/issues/3178 --- Dockerfile | 48 +++--------------------------------------------- environment.yml | 23 ----------------------- requirements.txt | 9 +++++++++ 3 files changed, 12 insertions(+), 68 deletions(-) delete mode 100644 environment.yml create mode 100644 requirements.txt diff --git a/Dockerfile b/Dockerfile index c5ea039..466bad3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,47 +1,7 @@ -FROM rocker/geospatial:4.3.1 +FROM rocker/binder:4.3.1 -# Install conda here, to match what repo2docker does -ENV CONDA_DIR=/srv/conda - -# Add our conda environment to PATH, so python, mamba and other tools are found in $PATH -ENV PATH ${CONDA_DIR}/bin:${PATH} - -# RStudio doesn't actually inherit the ENV set in Dockerfiles, so we -# have to explicitly set it in Renviron.site -RUN echo "PATH=${PATH}" >> /usr/local/lib/R/etc/Renviron.site - -# The terminal inside RStudio doesn't read from Renviron.site, but does read -# from /etc/profile - so we rexport here. -RUN echo "export PATH=${PATH}" >> /etc/profile - -# Install shiny-server -RUN /rocker_scripts/install_shiny_server.sh - -# Install a specific version of mambaforge in ${CONDA_DIR} -# Pick latest version from https://github.com/conda-forge/miniforge/releases -ENV MAMBAFORGE_VERSION=22.9.0-2 -RUN echo "Installing Mambaforge..." \ - && curl -sSL "https://github.com/conda-forge/miniforge/releases/download/${MAMBAFORGE_VERSION}/Mambaforge-${MAMBAFORGE_VERSION}-Linux-$(uname -m).sh" > installer.sh \ - && /bin/bash installer.sh -u -b -p ${CONDA_DIR} \ - && rm installer.sh \ - && mamba clean -afy \ - # After installing the packages, we cleanup some unnecessary files - # to try reduce image size - see https://jcristharif.com/conda-docker-tips.html - && find ${CONDA_DIR} -follow -type f -name '*.a' -delete \ - && find ${CONDA_DIR} -follow -type f -name '*.pyc' -delete - -COPY environment.yml /tmp/environment.yml - -RUN mamba env update -p ${CONDA_DIR} -f /tmp/environment.yml \ - && mamba clean -afy \ - && find ${CONDA_DIR} -follow -type f -name '*.a' -delete \ - && find ${CONDA_DIR} -follow -type f -name '*.pyc' -delete - -# Install IRKernel -RUN install2.r --skipinstalled \ - IRkernel \ - rstan \ - && rm -rf /tmp/downloaded_packages +COPY requirements.txt /tmp/requirements.txt +RUN pip install --no-cache -r /tmp/requirements.txt # Install learnr and other requested packages in https://2i2c.freshdesk.com/a/tickets/741 # mosaic installed per https://2i2c.freshdesk.com/a/tickets/973 @@ -64,8 +24,6 @@ RUN install2.r --skipinstalled \ mosaic \ && rm -rf /tmp/downloaded_packages -RUN r -e "IRkernel::installspec(prefix='${CONDA_DIR}')" - # Set working directory so Jupyter knows where to start WORKDIR /home/rstudio diff --git a/environment.yml b/environment.yml deleted file mode 100644 index 61c5469..0000000 --- a/environment.yml +++ /dev/null @@ -1,23 +0,0 @@ -channels: - - conda-forge - - nodefaults - -dependencies: - # Required to work with JupyterHub - - jupyterhub-singleuser>=3.0 - # Required to work with RStudio - - jupyter-rsession-proxy>=2 - # Let's provide Jupyter Interfaces too - - jupyterlab>=3.0 - - retrolab - # Provide info on memory usage in JupyterLab & RetroLab - - jupyter-resource-usage - # People still wanna pull stuff, even if into RStudio - - nbgitpuller==1.1.1 - - - pip - - - pip: - - jupyter-shiny-proxy==1.1 - # Based on request from Nathan Taback - - otter-grader==4.3.4 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..2d54ab9 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,9 @@ +retrolab +# Provide info on memory usage in JupyterLab & RetroLab +jupyter-resource-usage +# People still wanna pull stuff, even if into RStudio +nbgitpuller==1.2.0 + +jupyter-shiny-proxy==1.1 +# Based on request from Nathan Taback +otter-grader==4.3.4 From dd5c5d66360a724a44b34bc4b80305104ef67f3f Mon Sep 17 00:00:00 2001 From: YuviPanda Date: Thu, 2 Nov 2023 14:31:26 +0530 Subject: [PATCH 2/2] Install python packages as root --- Dockerfile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Dockerfile b/Dockerfile index 466bad3..0a63236 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,14 @@ FROM rocker/binder:4.3.1 +USER root + +# Install python packages as root, since that's what is done upstream +# This may change soon https://github.com/rocker-org/rocker-versioned2/issues/670 COPY requirements.txt /tmp/requirements.txt RUN pip install --no-cache -r /tmp/requirements.txt +USER ${NB_USER} + # Install learnr and other requested packages in https://2i2c.freshdesk.com/a/tickets/741 # mosaic installed per https://2i2c.freshdesk.com/a/tickets/973 RUN install2.r --skipinstalled \