This repository was archived by the owner on Sep 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile.base.j2
90 lines (69 loc) · 2.92 KB
/
Dockerfile.base.j2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
ARG BASE_IMAGE={{docker_notebook_base_image}}
FROM $BASE_IMAGE
ARG NBGRADER_VERSION=0.6.1
ARG JHUB_FILES=/tmp/jupyterhub
ENV JHUB_CONFIG=$JHUB_CONFIG
USER root
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install \
nano -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
USER $NB_UID
# Install packages from requirements file
COPY jupyter-notebook-requirements.txt $JHUB_FILES/requirements.txt
RUN python3 -m pip install --no-cache -r $JHUB_FILES/requirements.txt
# Update JupyterHub version, so that its consistent with JupyterHub
RUN git clone https://github.com/jupyterhub/jupyterhub \
&& cd jupyterhub \
&& git checkout -b build {{git_jhub_hash_commit}} \
&& npm install \
&& npm install tslib \
&& python3 -m pip install .
# nbgrader
RUN python3 -m pip install nbgrader==$NBGRADER_VERSION && \
fix-permissions $CONDA_DIR && \
fix-permissions /home/$NB_USER
# copy global nbgrader config
COPY {{nbgrader_global_config}} /etc/jupyter/nbgrader_config.py
# support iframes with jupyter notebooks, copy to local config scope to override
# global notebook configs if they are present
COPY {{ jupyter_notebook_config_source }} {{ jupyter_notebook_config_destination }}
# install and enable classic notebook extensions
# https://jupyter-contrib-nbextensions.readthedocs.io/en/latest/install.html
RUN python3 -m pip install \
ipywidgets \
jupyter_contrib_nbextensions \
widgetsnbextension \
&& \
jupyter contrib nbextension install --sys-prefix && \
jupyter nbextension enable --py widgetsnbextension --sys-prefix && \
fix-permissions $CONDA_DIR && \
fix-permissions /home/$NB_USER
# with nbgrader installed, add scripts/configs and update permissions
USER root
RUN mkdir -p {{nbgrader_exch_dir}} \
&& fix-permissions {{nbgrader_exch_dir}}
RUN chmod +x /usr/local/bin/start-singleuser.sh
# set container to run with $NB_USER by default
# enable/disable nbgrader extensions
USER $NB_UID
# support iframes with jupyter notebooks, copy to local config scope to override
# global notebook configs if they are present
COPY {{jupyter_notebook_config}} /etc/jupyter/{{jupyter_notebook_config}}
# set up log file location
RUN mkdir -p /home/$NB_USER/.local/share/ \
&& touch /home/$NB_USER/.local/share/nbgrader.logs \
&& chmod +x /home/$NB_USER/.local/share/nbgrader.logs
# nbgrader
# Install global extensions, and disable them globally. We will re-enable
# specific ones for different user accounts using docker-entrypoint.sh
RUN jupyter nbextension install --symlink --sys-prefix --py nbgrader --overwrite && \
jupyter nbextension disable --sys-prefix --py nbgrader && \
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
EXPOSE 8888
WORKDIR /home/$NB_USER