Dockerfile 5.07 KB
Newer Older
Marco Leoni's avatar
Marco Leoni committed
1 2
FROM jupyter/tensorflow-notebook
# FROM jupyter/scipy-notebook # just commented out
3
#FROM jupyter/minimal-notebook
Marco Leoni's avatar
Marco Leoni committed
4 5

USER root
Nicolas M. Thiéry's avatar
Nicolas M. Thiéry committed
6 7

# Install system utilities with apt
Nicolas Thiéry's avatar
Nicolas Thiéry committed
8
# Also install ocaml and dependency rlwrap for L2 CS course by Kim Nguyen
Marco Leoni's avatar
Marco Leoni committed
9
RUN apt-get update && \
10
    apt-get install -y --no-install-recommends \
11
        openssh-client rsync unison less tree curl gdb libopenjp2-7 \
12
        ocaml rlwrap dune js-of-ocaml libjs-of-ocaml \
13
        net-tools traceroute iputils-ping \
Nicolas M. Thiéry's avatar
Nicolas M. Thiéry committed
14
        time \
15
        dbus-x11 xfce4 xfce4-panel xfce4-session xfce4-settings xorg xubuntu-icon-theme && \
Marco Leoni's avatar
Marco Leoni committed
16 17 18
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

19 20
# Setup default prompt
RUN echo 'export PS1=`echo $JUPYTERHUB_USER| sed s/-at-.*//`"@jupyterhub:\w\$ "' > /etc/profile.d/02-prompt.sh
21 22
# Hack to override the setting of PS1 in the users's bashrc
RUN ln -s /etc/profile.d/02-prompt.sh /etc/bash_completion
23 24
# Enable extended file globs in bash
RUN echo 'shopt -s extglob' > /etc/profile.d/03-extglob.sh
25 26 27 28
# With the current jupyter emage, conda is activated via
# /etc/skels/.bashrc; older accounts may not beneficiate from it.
# Force activation for everyone.
RUN echo 'eval "$(command conda shell.bash hook 2> /dev/null)"' > /etc/profile.d/04-conda-activate.sh
29
# Limit to 10M the size of core dumps
30 31
# Limit to 250M the size of files generated from commands in the shell
RUN echo 'ulimit -c 10000; ulimit -f 250000' > /etc/profile.d/05-ulimit.sh
32
# Force core files to be named 'core'
33
RUN (echo 'kernel.core_uses_pid = 0'; echo 'kernel.core_pattern = core') > /etc/sysctl.d/60-local.conf
Marco Leoni's avatar
Marco Leoni committed
34

Nicolas M. Thiéry's avatar
Nicolas M. Thiéry committed
35 36
USER $NB_UID

Nicolas M. Thiéry's avatar
Nicolas M. Thiéry committed
37 38 39
# Restrict jupytext to only notebook and markdown files (hacky)
RUN echo '{ "ContentsManager": {"notebook_extensions": "ipynb,md" } }' > /opt/conda/etc/jupyter/jupyter_notebook_config.json

40
COPY environment.yml .
41

Nicolas M. Thiéry's avatar
Nicolas M. Thiéry committed
42 43 44
# Install mamba
# Install the base software stack
# Install the software stack for each of the given repositories
45 46
# The repo for the course "Introduction à la science des données"
# is outdated and clashes with other courses (nbgrader configuration).
Nicolas M. Thiéry's avatar
Nicolas M. Thiéry committed
47
# Disabled:
48
#  https://github.com/madclam/info113/                    \
Nicolas M. Thiéry's avatar
Nicolas M. Thiéry committed
49 50
# Workaround: pip installed nbgrader-dev requires pyyaml 5.4
# but pip refuses by default to upgrade conda's pyyaml 5.3
51

52
RUN mamba env update -n base -f environment.yml             && \
Nicolas M. Thiéry's avatar
Nicolas M. Thiéry committed
53 54 55
    rm environment.yml                                      && \
    pip3 install --ignore-installed PyYAML                  && \
    for REPO in                                                \
56
        https://gitlab.u-psud.fr/nthiery/scripts.git    \
Nicolas M. Thiéry's avatar
Nicolas M. Thiéry committed
57
        https://gitlab.dsi.universite-paris-saclay.fr/Info111/ComputerLab.git       \
Nicolas M. Thiéry's avatar
Nicolas M. Thiéry committed
58
        https://gitlab.u-psud.fr/L1Info/IntroScienceDonnees/ComputerLab.git \
Nicolas M. Thiéry's avatar
Nicolas M. Thiéry committed
59
        https://gitlab.u-psud.fr/Info122/Info122.git           \
60
        https://gitlab.u-psud.fr/M1-ISD/AlgorithmiqueAvancee/ComputerLab \
Nicolas M. Thiéry's avatar
Nicolas M. Thiéry committed
61
        https://gitlab.u-psud.fr/nicolas.thiery/ter-jupyter    \
Marco Leoni's avatar
Marco Leoni committed
62 63 64 65 66 67
        ; do                                                   \
        echo =================================================;\
        echo Installing software stack for:                   ;\
        echo   $REPO                                          ;\
        echo =================================================;\
        git clone $REPO repo                        &&         \
68
        (cd repo; test -d binder && cd binder; mamba env update -n base -f environment.yml) &&         \
Marco Leoni's avatar
Marco Leoni committed
69 70
        rm -rf repo                                 ||         \
        break 0;                                               \
Nicolas M. Thiéry's avatar
Nicolas M. Thiéry committed
71 72 73
    done                                                    && \
    mamba clean --all                                       && \
    pip cache purge
Marco Leoni's avatar
Marco Leoni committed
74

75 76
## Install SageMath, for now in a different environment
#RUN mamba create --yes -n sage sage=9.1
77

78 79
# Enable the Visual Studio proxy extension in notebook and lab
# Taken from https://github.com/betatim/vscode-binder/blob/master/postBuild
Nicolas M. Thiéry's avatar
Nicolas M. Thiéry committed
80 81 82
# RUN jupyter serverextension enable --py jupyter_server_proxy
# RUN jupyter labextension install @jupyterlab/server-proxy
# RUN code-server --install-extension ms-python.python
83

84
# Install unpackaged jupyterlab extensions
85 86 87
# run_all_buttons is currently incompatible with latest JupyterLab 3;
# ignoring error message for now
RUN jupyter labextension install @wallneradam/run_all_buttons; exit 0
88

Nicolas M. Thiéry's avatar
Nicolas M. Thiéry committed
89 90 91 92 93
# # Force jupyterlab rebuild (see https://github.com/jupyterlab/jupyterlab/issues/4930)
# RUN jupyter lab build && \
#     jupyter lab clean && \
#     jlpm cache clean && \
#     npm cache clean --force
94 95

# Force nbgrader extension reinstallation to ensure 0.7.dev
96
# Install Min's editor-tabs extension to enable tabs in the jupyter editor
97 98
RUN jupyter nbextension install --sys-prefix --py nbgrader --overwrite && \
    jupyter nbextension enable --sys-prefix --py nbgrader && \
99
    jupyter serverextension enable --sys-prefix --py nbgrader && \
100 101
    jupyter nbextension install --sys-prefix https://raw.githubusercontent.com/minrk/ipython_extensions/master/nbextensions/editor-tabs.js && \
    jupyter nbextension enable --section edit editor-tabs && \
102 103 104
    jupyter lab clean && \
    jlpm cache clean && \
    npm cache clean --force && \
Nicolas M. Thiéry's avatar
Nicolas M. Thiéry committed
105
    exit 0