Skip to content

Commit

Permalink
Merge pull request #54 from 2i2c-org/server-fix
Browse files Browse the repository at this point in the history
Simplify image vastly, get rid of R
  • Loading branch information
yuvipanda authored Dec 21, 2023
2 parents 7360728 + 403d614 commit 178819e
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 432 deletions.
182 changes: 4 additions & 178 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,61 +1,6 @@
FROM buildpack-deps:focal-scm
FROM quay.io/jupyter/scipy-notebook:2023-12-08

ENV LC_ALL en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US.UTF-8
ENV DEBIAN_FRONTEND=noninteractive
ENV NB_USER jovyan
ENV NB_UID 1000
ENV SHELL /bin/bash

ENV CONDA_DIR /opt/conda
ENV R_LIBS_USER /opt/r

# Explicitly add littler to PATH
# See https://github.com/conda-forge/r-littler-feedstock/issues/6
ENV PATH ${CONDA_DIR}/lib/R/library/littler/bin:${CONDA_DIR}/bin:$PATH

RUN adduser --disabled-password --gecos "Default Jupyter user" ${NB_USER}

# Create user owned R libs dir
# This lets users temporarily install packages
RUN mkdir -p ${R_LIBS_USER} && chown ${NB_USER}:${NB_USER} ${R_LIBS_USER}

# Install these without 'recommended' packages to keep image smaller.
# Useful utils that folks sort of take for granted
RUN apt-get update -qq --yes && \
apt-get install --yes --no-install-recommends -qq \
htop \
less \
man \
nano \
screen \
tar \
tmux \
wget \
vim \
locales > /dev/null

RUN echo "${LC_ALL} UTF-8" > /etc/locale.gen && \
locale-gen

# Install R packages
# Our pre-built R packages from rspm are built against system libs in focal
# rstan takes forever to compile from source, and needs libnodejs
# We don't want R 4.1 yet - the graphics protocol version it has is incompatible
# with the version of RStudio we use. So we pin R to 4.0.5
# littler, r-cran-mgcv, r-cran-survival, r-cran-matrix are specific packages needed
# for apt to actually install the correct version of R 4.0.5
ENV R_VERSION=4.0.5-1.2004.0
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
RUN echo "deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/" > /etc/apt/sources.list.d/cran.list
RUN apt-get update -qq --yes > /dev/null && \
apt-get install --yes --no-install-recommends \
r-base-core=${R_VERSION} \
r-base-dev=${R_VERSION} \
r-cran-littler=0.3.11-1.2004.0 \
nodejs \
npm
USER root

# Install desktop packages
RUN apt-get update -qq --yes > /dev/null && \
Expand All @@ -72,135 +17,16 @@ RUN apt-get update -qq --yes > /dev/null && \
openjdk-8-jre \
libreoffice > /dev/null

# for nbconvert & notebook-to-pdf
# See https://github.com/utoronto-2i2c/jupyterhub-deploy/issues/35 as well
RUN apt-get update -qq --yes && \
apt-get install --yes -qq \
pandoc \
texlive-xetex \
texlive-fonts-recommended \
texlive-science \
dvipng \
ghostscript \
cm-super \
libx11-xcb1 \
libxtst6 \
libxrandr2 \
libasound2 \
libpangocairo-1.0-0 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libgtk-3-0 \
libnss3 \
libxss1 \
> /dev/null

# for kableExtra & partitions & prettydoc & RSelenium & scholar & showtext & stopwords & copula
# See https://github.com/utoronto-2i2c/jupyterhub-deploy/issues/25
RUN apt-get update -qq --yes && \
apt-get install --yes -qq \
libcurl4-openssl-dev \
libxml2-dev \
imagemagick \
libmagick++-dev \
libgmp3-dev \
libglpk-dev \
libfreetype6-dev \
libgit2-dev \
libgsl0-dev \
> /dev/null

WORKDIR /home/jovyan

COPY install-mambaforge.bash /tmp/install-mambaforge.bash
RUN /tmp/install-mambaforge.bash

# Needed by RStudio
RUN apt-get update -qq --yes && \
apt-get install --yes --no-install-recommends -qq \
psmisc \
sudo \
libapparmor1 \
lsb-release \
libclang-dev > /dev/null

# 1.3.959 is latest version that works with jupyter-rsession-proxy
# See https://github.com/jupyterhub/jupyter-rsession-proxy/issues/93#issuecomment-725874693
ENV RSTUDIO_URL https://download2.rstudio.org/server/bionic/amd64/rstudio-server-1.3.959-amd64.deb
RUN curl --silent --location --fail ${RSTUDIO_URL} > /tmp/rstudio.deb && \
dpkg -i /tmp/rstudio.deb && \
rm /tmp/rstudio.deb

ENV SHINY_SERVER_URL https://download3.rstudio.org/ubuntu-14.04/x86_64/shiny-server-1.5.15.953-amd64.deb
RUN curl --silent --location --fail ${SHINY_SERVER_URL} > /tmp/shiny-server.deb && \
dpkg -i /tmp/shiny-server.deb && \
rm /tmp/shiny-server.deb

# Needed by many R libraries
# Picked up from https://github.com/rocker-org/rocker/blob/9dc3e458d4e92a8f41ccd75687cd7e316e657cc0/r-rspm/focal/Dockerfile
# libglpk40 for igraph
# libzmq3-dev for IRKernel
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libgdal26 \
libgdal-dev \
gdal-bin \
libgeos-3.8.0 \
libproj15 \
libudunits2-0 \
libxml2 \
libzmq3-dev \
libglpk40 > /dev/null

# Needed by staplr R library
RUN apt-get update && \
apt-get install -y --no-install-recommends \
default-jdk > /dev/null && \
R CMD javareconf


# R_LIBS_USER is set by default in /etc/R/Renviron, which RStudio loads.
# We uncomment the default, and set what we wanna - so it picks up
# the packages we install. Without this, RStudio doesn't see the packages
# that R does.
# Stolen from https://github.com/jupyterhub/repo2docker/blob/6a07a48b2df48168685bb0f993d2a12bd86e23bf/repo2docker/buildpacks/r.py
# To try fight https://community.rstudio.com/t/timedatectl-had-status-1/72060/5 ,
# which shows up sometimes when trying to install packages that want the TZ
# timedatectl expects systemd running, which isn't true in our containers
ENV TZ America/Toronto
RUN sed -i -e '/^R_LIBS_USER=/s/^/#/' /etc/R/Renviron && \
echo "R_LIBS_USER=${R_LIBS_USER}" >> /etc/R/Renviron && \
echo "TZ=${TZ}" >> /etc/R/Renviron

USER ${NB_USER}

# Set CRAN mirror to rspm before we install anything
COPY Rprofile.site /usr/lib/R/etc/Rprofile.site
# RStudio needs its own config
COPY rsession.conf /etc/rstudio/rsession.conf


# Install R packages, cleanup temp package download location
COPY install.R /tmp/install.R
RUN /tmp/install.R && \
rm -rf /tmp/downloaded_packages/ /tmp/*.rds

# Install bioconductor separately, as it seems to fail often
COPY install-bioconductor.R /tmp/install-bioconductor.R
RUN /tmp/install-bioconductor.R && \
rm -rf /tmp/downloaded_packages/ /tmp/*.rds

COPY environment.yml /tmp/

RUN mamba env update -p ${CONDA_DIR} -f /tmp/environment.yml && mamba clean -afy

# For https://2i2c.freshdesk.com/a/tickets/187
# If we don't set `NLTK_DATA`, the data gets downloaded onto $HOME, which
# isn't available when the image is loaded onto JupyterHub.
# So we download alongside our packages.
# Note that textblob.download_corpora just calls nltk to download corpora
ENV NLTK_DATA ${CONDA_DIR}/nltk_data
RUN mkdir -p ${NLTK_DATA} && python -m textblob.download_corpora

# Install IRKernel
RUN r -e "install.packages('IRkernel', version='1.1.1')" && \
r -e "IRkernel::installspec(prefix='${CONDA_DIR}')"
RUN mkdir -p ${NLTK_DATA} && python -m textblob.download_corpora
12 changes: 0 additions & 12 deletions Rprofile.site

This file was deleted.

80 changes: 32 additions & 48 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,30 @@ dependencies:
# for jupyter-desktop-server
- websockify

# language runtimes
- python=3.10.*

- numpy==1.24.*
- scipy==1.10.*
- matplotlib==3.6.*
- pandas==1.5.*
- seaborn==0.12.*
- sympy==1.11.*
- networkx==2.8.*
- scikit-learn==1.2.*
- beautifulsoup4==4.11.*
- statsmodels==0.13.*
- networkx==3.2.*
- nltk==3.8.*
- spacy==3.4.*
- geopandas==0.12.*
- geopy==2.3.0
- spacy==3.7.*
- geopandas==0.14.*
- geopy==2.4.*
# From https://github.com/utoronto-2i2c/jupyterhub-deploy/issues/29
- astroquery==0.4.*
- astropy==5.2
- galpy==1.8.*
- astropy==5.3.*
- galpy==1.9.*
- libgfortran==3.0.0
- tensorflow==2.10.0


# Infrastructure things
- jupyterlab==3.5.* # Pinned to <3.6, until https://github.com/2i2c-org/infrastructure/issues/2244 is fixed
# Pinned until https://github.com/Jupyter-contrib/jupyter_nbextensions_configurator/pull/152 can land
# See https://github.com/2i2c-org/infrastructure/issues/2380
- nbclassic<0.5
- retrolab==0.3.*
- voila==0.3.*
- nbgitpuller==1.1.*
- jupyter-resource-usage==0.5.1
- jupytext==1.13.*
- RISE==5.7.1
- jupyter_contrib_nbextensions==0.7.0
- notebook==6.5.*
- jupyterhub==3.1.0
- jupyter-server-proxy==3.2.*
- nbgitpuller==1.2.*
- jupyter-resource-usage==0.7.*
- jupytext==1.15.*
- jupyter-server-proxy==4.*

- ipywidgets==8.0.4
# From https://2i2c.freshdesk.com/a/tickets/497
- contextily==1.4.*
- libpysal==4.9.*
- esda==2.5.*
- splot==1.1.*
- xlrd==2.0.*
- numba==0.57.*

# python-graphviz installed on request by Scott Schwartz in
# https://2i2c.freshdesk.com/a/tickets/697?note=80283596987
Expand All @@ -55,14 +38,15 @@ dependencies:

- pip:
# Infrastructure things that don't exist in conda-forge
- jupyter-desktop-server==0.1.3
- jupyter-remote-desktop-proxy==1.*
- git-credential-helpers==0.2
- jupyter-rsession-proxy==1.4
- jupyter-shiny-proxy==1.1
- jupyter-tree-download==1.0.1

- datascience==0.17.5
- otter-grader==4.3.4
# Infrastructure thing that doesn't support notebook 7
- jupyter_contrib_nbextensions==0.7.0

- datascience==0.17.*
- otter-grader==5.*

# nbextensions
- jupyterthemes==0.20.0
Expand All @@ -72,12 +56,12 @@ dependencies:
- jax[cpu]

# From https://2i2c.freshdesk.com/a/tickets/187
- textblob==0.17.1
- textblob==0.17.*

# Install this from pip because installing from conda conflicts with geopy / geopandas
# Re-evaluate once https://github.com/conda-forge/tensorflow-feedstock/pull/353 lands
- tensorflow==2.15.*

# From https://2i2c.freshdesk.com/a/tickets/497
- contextily==1.3.*
- libpysal==4.7.*
- esda==2.4.*
- splot==1.1.*
- xlrd==2.0.*
- numba==0.56.*
# Install from pip because it does not work from conda-forge atm
# https://github.com/conda-forge/rise-feedstock/issues/43 has information
- RISE==5.7.*
Binary file removed images/action.png
Binary file not shown.
Binary file removed images/coessing-image-quay.png
Binary file not shown.
Binary file removed images/configurator.png
Binary file not shown.
Binary file removed images/secrets.png
Binary file not shown.
11 changes: 0 additions & 11 deletions install-bioconductor.R

This file was deleted.

42 changes: 0 additions & 42 deletions install-mambaforge.bash

This file was deleted.

Loading

0 comments on commit 178819e

Please sign in to comment.