diff --git a/base-notebook/Dockerfile b/base-notebook/Dockerfile index 1982ecc..68ddf69 100644 --- a/base-notebook/Dockerfile +++ b/base-notebook/Dockerfile @@ -1,71 +1,57 @@ ARG BASE_IMAGE=jupyter/datascience-notebook:76402a27fd13 FROM $BASE_IMAGE -ARG JHUB_HASH_COMMIT=fd28e224f2de5e7b525483330150988ec3e295c6 +ARG NBGRADER_VERSION=0.6.1 -ENV JHUB_HASH_COMMIT=$JHUB_HASH_COMMIT -ENV DEBIAN_FRONTEND=noninteractive - -ENV DEBIAN_FRONTEND=noninteractive +ENV JHUB_CONFIG=$JHUB_CONFIG USER root RUN apt-get update \ - && apt-get install --no-install-recommends -y \ - apt-transport-https \ - curl \ - dumb-init \ + && apt-get install -y \ + at-spi2-core \ ffmpeg \ - gradle \ - htop \ - libssl-dev \ - lsb-release \ - maven \ + libgl1-mesa-glx \ + libgtk-3-dev \ + libqt5widgets5 \ + libxrender1 \ + libxext6 \ + libxt6 \ nano \ - openjdk-11-jdk \ - procps \ - ssh \ - sudo \ - vim \ + xauth \ + xvfb \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -# add nbgrader exchange directory -RUN mkdir -p /srv/nbgrader/exchange \ - && fix-permissions /srv/nbgrader/exchange +USER $NB_UID # Install packages from requirements file -WORKDIR $HOME - -USER $NB_USER - -WORKDIR /tmp - -# Unpack and install the Java kernel -RUN curl -L https://github.com/SpencerPark/IJava/releases/download/v1.3.0/ijava-1.3.0.zip > ijava-kernel.zip -RUN unzip ijava-kernel.zip -d ijava-kernel -WORKDIR /tmp/ijava-kernel -RUN python3 install.py --sys-prefix \ - && rm ../ijava-kernel.zip +COPY requirements.txt /tmp/jupyternb/requirements.txt +RUN python3 -m pip install --no-cache -r /tmp/jupyternb/requirements.txt WORKDIR /tmp -# Update JupyterHub version, so that its consistent with version returned -# by JupyterHub API +# Update JupyterHub version, so that its consistent with JupyterHub RUN git clone https://github.com/jupyterhub/jupyterhub + WORKDIR /tmp/jupyterhub -RUN git checkout -b build $JHUB_HASH_COMMIT \ + +RUN git checkout -b build fd28e224f2de5e7b525483330150988ec3e295c6 \ && npm install \ && npm install tslib \ && python3 -m pip install . -WORKDIR $HOME +# nbgrader +RUN python3 -m pip install nbgrader=="${NBGRADER_VERSION}" && \ + fix-permissions "${CONDA_DIR}" && \ + fix-permissions "/home/${NB_USER}" + +# copy global nbgrader config +COPY global_nbgrader_config.py /etc/jupyter/nbgrader_config.py -COPY requirements.txt requirements.txt -RUN python3 -m pip install -r requirements.txt \ - && rm requirements.txt \ - && fix-permissions "${CONDA_DIR}" \ - && fix-permissions "/home/${NB_USER}" +# support iframes with jupyter notebooks, copy to local config scope to override +# global notebook configs if they are present +COPY jupyter_notebook_config.py /etc/jupyterhub/jupyter_notebook_config.py # enable classic notebook extensions # https://jupyter-contrib-nbextensions.readthedocs.io/en/latest/install.html @@ -76,9 +62,17 @@ RUN jupyter contrib nbextension install --sys-prefix && \ # install plotly-orca with npm globally RUN npm install -g electron@6.1.4 orca +# with nbgrader installed, add scripts/configs and update permissions +USER root + +RUN mkdir -p /srv/nbgrader/exchange \ + && fix-permissions /srv/nbgrader/exchange + +RUN chmod +x /usr/local/bin/start-singleuser.sh + # set container to run with $NB_USER by default # enable/disable nbgrader extensions -USER $NB_USER +USER $NB_UID # set up log file location RUN mkdir -p "/home/${NB_USER}/.local/share/" \ @@ -93,16 +87,12 @@ RUN jupyter nbextension install --symlink --sys-prefix --py nbgrader --overwrite && jupyter serverextension disable --sys-prefix --py nbgrader # Everybody gets the validate extension, however. -RUN jupyter nbextension enable --sys-prefix validate_assignment/main --section=notebook \ - && jupyter serverextension enable --sys-prefix nbgrader.server_extensions.validate_assignment - -# nbgitpuller -RUN jupyter serverextension enable nbgitpuller --sys-prefix +RUN jupyter nbextension enable --sys-prefix validate_assignment/main --section=notebook && \ + jupyter serverextension enable --sys-prefix nbgrader.server_extensions.validate_assignment -EXPOSE 8888 +WORKDIR /tmp +COPY install.jl /tmp/install.jl +RUN julia install.jl \ + && fix-permissions "${JULIA_PKGDIR}" "${CONDA_DIR}/share/jupyter" WORKDIR /home/$NB_USER - -# copy config files -COPY global_nbgrader_config.py /etc/jupyter/nbgrader_config.py -COPY jupyter_notebook_config.py /etc/jupyterhub/jupyter_notebook_config.py diff --git a/base-notebook/install.jl b/base-notebook/install.jl new file mode 100644 index 0000000..8782f16 --- /dev/null +++ b/base-notebook/install.jl @@ -0,0 +1,24 @@ +# This mechanism allows us to import a package list. +# Source: https://discourse.julialang.org/t/building-a-dockerfile-with-packages/37272/2 + +using Pkg +pkg"add Colors" +pkg"add CSV" +pkg"add GR" +pkg"add IJulia" +pkg"add ImageView" +pkg"add ImageInTerminal" +pkg"add FileIO" +pkg"add ImageFiltering" +pkg"add Images" +pkg"add ImageFeatures" +pkg"add LinearAlgebra" +pkg"add Plots" +pkg"add PyPlot" +pkg"add Random" +pkg"add GtkReactive" +pkg"add Roots" +pkg"add SymEngine" +pkg"add Statistics" +pkg"add TestImages" +pkg"precompile" diff --git a/base-notebook/jupyter_notebook_config.py b/base-notebook/jupyter_notebook_config.py index 8587bf8..7b4c4d9 100644 --- a/base-notebook/jupyter_notebook_config.py +++ b/base-notebook/jupyter_notebook_config.py @@ -7,6 +7,7 @@ c = get_config() + c.NotebookApp.iopub_data_rate_limit = 1.0e10 c.NotebookApp.ip = '0.0.0.0' c.NotebookApp.open_browser = False