forked from ITISFoundation/jupyter-math
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
93 lines (73 loc) · 2.84 KB
/
Dockerfile
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
91
92
93
ARG JUPYTER_MINIMAL_VERSION=lab-3.3.2@sha256:a4bf48221bfa864759e0f248affec3df1af0a68ee3e43dfc7435d84926ec92e8
FROM jupyter/minimal-notebook:${JUPYTER_MINIMAL_VERSION}
LABEL maintainer="pcrespov"
ENV JUPYTER_ENABLE_LAB="yes"
# autentication is disabled for now
ENV NOTEBOOK_TOKEN=""
ENV NOTEBOOK_BASE_DIR="$HOME/work"
USER root
RUN apt-get update && \
apt-get install -y --no-install-recommends \
gfortran \
ffmpeg \
dvipng \
gosu \
octave \
gnuplot \
bc \
ghostscript \
texlive-xetex \
texlive-fonts-recommended \
texlive-latex-recommended \
texlive-fonts-extra \
zip \
fonts-freefont-otf \
&& \
apt-get clean && rm -rf /var/lib/apt/lists/*
RUN pip --no-cache --quiet install --upgrade \
pip \
setuptools \
wheel
USER $NB_UID
# --------------------------------------------------------------------
# Install kernel in virtual-env
ENV HOME="/home/$NB_USER"
USER root
WORKDIR ${HOME}
RUN python3 -m venv .venv &&\
.venv/bin/pip --no-cache --quiet install --upgrade pip~=21.3 wheel setuptools &&\
.venv/bin/pip --no-cache --quiet install ipykernel &&\
.venv/bin/python -m ipykernel install \
--user \
--name "python-maths" \
--display-name "python (maths)" \
&& \
echo y | .venv/bin/python -m jupyter kernelspec uninstall python3 &&\
.venv/bin/python -m jupyter kernelspec list
# copy and resolve dependecies to be up to date
COPY --chown=$NB_UID:$NB_GID kernels/python-maths/requirements.in ${NOTEBOOK_BASE_DIR}/requirements.in
RUN .venv/bin/pip --no-cache install pip-tools && \
.venv/bin/pip-compile --build-isolation --output-file ${NOTEBOOK_BASE_DIR}/requirements.txt ${NOTEBOOK_BASE_DIR}/requirements.in && \
.venv/bin/pip --no-cache install -r ${NOTEBOOK_BASE_DIR}/requirements.txt && \
rm ${NOTEBOOK_BASE_DIR}/requirements.in
RUN jupyter serverextension enable voila && \
jupyter server extension enable voila
# Import matplotlib the first time to build the font cache.
ENV XDG_CACHE_HOME /home/$NB_USER/.cache/
RUN MPLBACKEND=Agg .venv/bin/python -c "import matplotlib.pyplot" && \
# run fix permissions only once
fix-permissions /home/$NB_USER
# copy README and CHANGELOG
COPY --chown=$NB_UID:$NB_GID CHANGELOG.md ${NOTEBOOK_BASE_DIR}/CHANGELOG.md
COPY --chown=$NB_UID:$NB_GID README.ipynb ${NOTEBOOK_BASE_DIR}/README.ipynb
# remove write permissions from files which are not supposed to be edited
RUN chmod gu-w ${NOTEBOOK_BASE_DIR}/CHANGELOG.md && \
chmod gu-w ${NOTEBOOK_BASE_DIR}/requirements.txt
RUN mkdir --parents "/home/${NB_USER}/.virtual_documents" && \
chown --recursive "$NB_USER" "/home/${NB_USER}/.virtual_documents"
ENV JP_LSP_VIRTUAL_DIR="/home/${NB_USER}/.virtual_documents"
# Copying boot scripts
COPY --chown=$NB_UID:$NB_GID docker /docker
RUN echo 'export PATH="/home/${NB_USER}/.venv/bin:$PATH"' >> "/home/${NB_USER}/.bashrc"
EXPOSE 8888
ENTRYPOINT [ "/bin/bash", "/docker/entrypoint.bash" ]