-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile-jupyter
57 lines (41 loc) · 1.97 KB
/
Dockerfile-jupyter
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
ARG BASE_IMAGE_TAG
FROM 527538141574.dkr.ecr.eu-central-1.amazonaws.com/eoxhub-jupyterlab:${BASE_IMAGE_TAG}
# NOTE: this is not a duplication, but a documented workaround
# https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact
ARG BASE_IMAGE_TAG
ENV BASE_IMAGE_TAG=${BASE_IMAGE_TAG}
ARG NB_USER="jovyan"
ARG NB_UID="1000"
ARG NB_GID="100"
RUN echo "auth requisite pam_deny.so" >> /etc/pam.d/su && \
useradd -m -s /bin/bash -N -u $NB_UID -g $NB_GID $NB_USER && \
chmod g+w /etc/passwd && \
chown $NB_USER $HOME
# add group for nfs provisioner
RUN groupadd users-nfs -g 2005
# allow user kernels here
RUN mkdir /opt/conda/pkgs \
&& chown $NB_USER:$NB_GID /opt/conda/pkgs /opt/conda/envs
USER $NB_UID
ADD --chown=1000 kernel-jupyter.yaml /tmp
RUN pip config set global.cache-dir false && \
mamba env create \
-p /opt/conda/envs/edc-default-${BASE_IMAGE_TAG} \
-f /tmp/kernel-jupyter.yaml && \
mamba clean --all -f -y && \
rm /tmp/kernel-jupyter.yaml && \
pip config set global.cache-dir true
USER root
RUN echo "source activate edc-default-${BASE_IMAGE_TAG}" >> /etc/bash.bashrc
# remove kernel from default env, only jupyter server runs there
RUN /opt/conda/envs/default/bin/python3 -m nb_conda_kernels remove -y python3
# install current conda kernel such that papermill can use it
# https://github.com/Anaconda-Platform/nb_conda_kernels#use-with-nbconvert-voila-papermill
RUN mkdir /etc/jupyter \
&& echo '{"CondaKernelSpecManager": {"kernelspec_path": "--user" }}' > /etc/jupyter/jupyter_config.json \
&& /opt/conda/envs/default/bin/python3 -m nb_conda_kernels list
# NOTE: "nb_conda_kernels list" will create kernel config file
# NOTE: setting kernelspec_path to "" will install it globally
# Need to downgrade edc-jlab in jupyterlab conda env from base image
RUN mamba run -n default python3 -m pip install https://github.com/eurodatacube/edc-jlab/raw/master/dist/edc_jlab-0.5.15-py3-none-any.whl
USER $NB_UID