ARG DOCKER_NOTEBOOK_IMAGE FROM $DOCKER_NOTEBOOK_IMAGE ARG JUPYTERHUB_VERSION # Install vim in case someone wants to use the terminal USER root RUN apt-get update && \ apt-get install -y vim && \ apt-get install -y gcc && \ rm -rf /var/lib/apt/lists/* RUN python3 -m pip install --no-cache jupyterhub==$JUPYTERHUB_VERSION nbresuse #any additional installations go here. LABEL maintainer="Jupyter Project " ARG NB_USER="student" ARG NB_UID="1001" ARG NB_GID="100" USER root # Install all OS dependencies for notebook server that starts but lacks all # features (e.g., download as all possible file formats) ENV DEBIAN_FRONTEND noninteractive RUN apt-get update && apt-get -yq dist-upgrade \ && apt-get install -yq --no-install-recommends \ wget \ bzip2 \ ca-certificates \ sudo \ locales \ fonts-liberation \ && rm -rf /var/lib/apt/lists/* RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \ locale-gen # Configure environment ENV CONDA_DIR=/opt/conda \ SHELL=/bin/bash \ NB_USER=$NB_USER \ NB_UID=$NB_UID \ NB_GID=$NB_GID \ LC_ALL=en_US.UTF-8 \ LANG=en_US.UTF-8 \ LANGUAGE=en_US.UTF-8 ENV PATH=$CONDA_DIR/bin:$PATH \ HOME=/home/$NB_USER ADD fix-permissions /usr/local/bin/fix-permissions # Create jovyan user with UID=1000 and in the 'users' group # and make sure these dirs are writable by the `users` group. RUN groupadd wheel -g 11 && \ echo "auth required pam_wheel.so use_uid" >> /etc/pam.d/su && \ useradd -m -s /bin/bash -N -u $NB_UID $NB_USER && \ mkdir -p $CONDA_DIR && \ chown $NB_USER:$NB_GID $CONDA_DIR && \ chmod g+w /etc/passwd && \ fix-permissions $HOME && \ fix-permissions $CONDA_DIR USER $NB_UID # Setup work directory for backward-compatibility RUN mkdir /home/$NB_USER/work && \ fix-permissions /home/$NB_USER # Install conda as jovyan and check the md5 sum provided on the download site ENV MINICONDA_VERSION 4.5.11 RUN cd /tmp && \ wget --quiet https://repo.continuum.io/miniconda/Miniconda3-${MINICONDA_VERSION}-Linux-x86_64.sh && \ echo "e1045ee415162f944b6aebfe560b8fee *Miniconda3-${MINICONDA_VERSION}-Linux-x86_64.sh" | md5sum -c - && \ /bin/bash Miniconda3-${MINICONDA_VERSION}-Linux-x86_64.sh -f -b -p $CONDA_DIR && \ rm Miniconda3-${MINICONDA_VERSION}-Linux-x86_64.sh && \ $CONDA_DIR/bin/conda config --system --prepend channels conda-forge && \ $CONDA_DIR/bin/conda config --system --set auto_update_conda false && \ $CONDA_DIR/bin/conda config --system --set show_channel_urls true && \ $CONDA_DIR/bin/conda install --quiet --yes conda="${MINICONDA_VERSION%.*}.*" && \ $CONDA_DIR/bin/conda update --all --quiet --yes && \ conda clean -tipsy && \ rm -rf /home/$NB_USER/.cache/yarn && \ fix-permissions $CONDA_DIR && \ fix-permissions /home/$NB_USER USER root RUN ln -s /usr/bin/python3 /usr/bin/python && \ mkdir /.symlinks && \ cd /.symlinks && ln -s $CONDA_DIR/conda conda && \ ln -s $CONDA_DIR/activate activate && \ ln -s $CONDA_DIR/deactivate deactivate && \ export PATH=/.symlinks:$PATH USER $NB_UID # Install Tini RUN conda install --quiet --yes 'tini=0.18.0' && \ conda list tini | grep tini | tr -s ' ' | cut -d ' ' -f 1,2 >> $CONDA_DIR/conda-meta/pinned && \ conda clean -tipsy && \ fix-permissions $CONDA_DIR && \ fix-permissions /home/$NB_USER # Install Jupyter Notebook, Lab, and Hub # Generate a notebook server config # Cleanup temporary files # Correct permissions # Do all this in a single RUN command to avoid duplicating all of the # files across image layers when the permissions change RUN conda install --quiet --yes \ 'notebook=5.7.2' \ 'jupyterhub=0.9.4' \ 'jupyterlab=0.35.4' && \ conda clean -tipsy && \ jupyter labextension install @jupyterlab/hub-extension@^0.12.0 && \ npm cache clean --force && \ jupyter notebook --generate-config && \ rm -rf $CONDA_DIR/share/jupyter/lab/staging && \ rm -rf /home/$NB_USER/.cache/yarn && \ fix-permissions $CONDA_DIR && \ fix-permissions /home/$NB_USER USER root EXPOSE 8888 WORKDIR $HOME # Configure container startup ENTRYPOINT ["tini", "-g", "--"] CMD ["start-notebook.sh"] ### Minimal Notebook: USER root # Install all OS dependencies for fully functional notebook server RUN apt-get update && apt-get install -yq --no-install-recommends \ build-essential \ emacs \ git \ inkscape \ jed \ libsm6 \ libxext-dev \ libxrender1 \ lmodern \ netcat \ pandoc \ python-dev \ texlive-fonts-extra \ texlive-fonts-recommended \ texlive-generic-recommended \ texlive-latex-base \ texlive-latex-extra \ texlive-xetex \ unzip \ nano \ && rm -rf /var/lib/apt/lists/* ### Now onto scipy-notebook # ffmpeg for matplotlib anim RUN apt-get update && \ apt-get install -y --no-install-recommends ffmpeg && \ rm -rf /var/lib/apt/lists/* USER $NB_UID # Install Python 3 packages # Remove pyqt and qt pulled in for matplotlib since we're only ever going to # use notebook-friendly backends in these images RUN conda install --quiet --yes \ 'conda-forge::blas=*=openblas' \ 'ipywidgets=7.2*' \ 'pandas=0.23*' \ 'numexpr=2.6*' \ 'matplotlib=2.2*' \ 'scipy=1.1*' \ 'seaborn=0.9*' \ 'scikit-learn=0.20*' \ 'scikit-image=0.14*' \ 'sympy=1.1*' \ 'cython=0.28*' \ 'patsy=0.5*' \ 'statsmodels=0.9*' \ 'cloudpickle=0.5*' \ 'dill=0.2*' \ 'numba=0.38*' \ 'bokeh=0.13*' \ 'sqlalchemy=1.2*' \ 'hdf5=1.10*' \ 'h5py=2.7*' \ 'vincent=0.4.*' \ 'beautifulsoup4=4.6.*' \ 'protobuf=3.*' \ 'xlrd' && \ conda remove --quiet --yes --force qt pyqt && \ conda clean -tipsy && \ # Activate ipywidgets extension in the environment that runs the notebook server jupyter nbextension enable --py widgetsnbextension --sys-prefix && \ # Also activate ipywidgets extension for JupyterLab # Check this URL for most recent compatibilities # https://github.com/jupyter-widgets/ipywidgets/tree/master/packages/jupyterlab-manager jupyter labextension install @jupyter-widgets/jupyterlab-manager@^0.38.1 && \ jupyter labextension install jupyterlab_bokeh@0.6.3 && \ npm cache clean --force && \ rm -rf $CONDA_DIR/share/jupyter/lab/staging && \ rm -rf /home/$NB_USER/.cache/yarn && \ rm -rf /home/$NB_USER/.node-gyp && \ fix-permissions $CONDA_DIR && \ fix-permissions /home/$NB_USER # Install facets which does not have a pip or conda package at the moment RUN cd /tmp && \ git clone https://github.com/PAIR-code/facets.git && \ cd facets && \ jupyter nbextension install facets-dist/ --sys-prefix && \ cd && \ rm -rf /tmp/facets && \ fix-permissions $CONDA_DIR && \ fix-permissions /home/$NB_USER # Import matplotlib the first time to build the font cache. ENV XDG_CACHE_HOME /home/$NB_USER/.cache/ RUN MPLBACKEND=Agg python -c "import matplotlib.pyplot" && \ fix-permissions /home/$NB_USER USER $NB_UID # Add local files as late as possible to avoid cache busting COPY start.sh /usr/local/bin/ COPY start-notebook.sh /usr/local/bin/ COPY start-singleuser.sh /usr/local/bin/ COPY jupyter_notebook_config.py /etc/jupyter/ RUN fix-permissions /etc/jupyter/