From bef2c97e06c72aa8d7af5fa89fb984ea520d2ef8 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Thu, 18 Mar 2021 09:54:35 +0100 Subject: [PATCH 1/3] base-image onbuild: detect and inject jupyter_notebook_config.py --- base-image/Dockerfile | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/base-image/Dockerfile b/base-image/Dockerfile index 2fc02fbc..bd5808c8 100644 --- a/base-image/Dockerfile +++ b/base-image/Dockerfile @@ -134,4 +134,16 @@ ONBUILD RUN echo "Checking for 'start'..." \ chmod +x start \ && cp start /srv/start \ ; fi + +# Copy jupyter_notebook_config.py to /etc/jupyter, which is an action not done +# with repo2docker. +ONBUILD USER root +ONBUILD RUN echo "Checking for config 'jupyter_notebook_config.py'..." \ + ; [ -d binder ] && cd binder \ + ; [ -d .binder ] && cd .binder \ + ; if test -f "jupyter_notebook_config.py" ; then \ + mkdir -p /etc/jupyter \ + && cp jupyter_notebook_config.py /etc/jupyter \ + ; fi +ONBUILD USER ${NB_USER} # ---------------------- From f309b526a83dcc6ccd16787e0c6daf027d1d6961 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Thu, 18 Mar 2021 09:55:37 +0100 Subject: [PATCH 2/3] ml/pangeo-notebook: don't register the same jupyter kernels twice --- ml-notebook/jupyter_notebook_config.py | 5 +++++ pangeo-notebook/jupyter_notebook_config.py | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 ml-notebook/jupyter_notebook_config.py create mode 100644 pangeo-notebook/jupyter_notebook_config.py diff --git a/ml-notebook/jupyter_notebook_config.py b/ml-notebook/jupyter_notebook_config.py new file mode 100644 index 00000000..1d5e5598 --- /dev/null +++ b/ml-notebook/jupyter_notebook_config.py @@ -0,0 +1,5 @@ +import os + +# Configure nb_conda_kernels to avoid registering jupyter kernels in our conda +# environment again. +c.CondaKernelSpecManager.env_filter = f'.*envs/{os.environ["CONDA_ENV"]}.*' diff --git a/pangeo-notebook/jupyter_notebook_config.py b/pangeo-notebook/jupyter_notebook_config.py new file mode 100644 index 00000000..1d5e5598 --- /dev/null +++ b/pangeo-notebook/jupyter_notebook_config.py @@ -0,0 +1,5 @@ +import os + +# Configure nb_conda_kernels to avoid registering jupyter kernels in our conda +# environment again. +c.CondaKernelSpecManager.env_filter = f'.*envs/{os.environ["CONDA_ENV"]}.*' From c6a7e7a10610d04c3df8e397542fb6a265d9229b Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Thu, 18 Mar 2021 21:53:07 +0100 Subject: [PATCH 3/3] Group root commands as cache always breaks anyhow --- base-image/Dockerfile | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/base-image/Dockerfile b/base-image/Dockerfile index bd5808c8..7082888a 100644 --- a/base-image/Dockerfile +++ b/base-image/Dockerfile @@ -59,7 +59,8 @@ ENTRYPOINT ["/srv/start"] # Only run these if used as a base image # ---------------------- ONBUILD USER root -# hardcode for now +# FIXME (?): user and home folder is hardcoded for now +# FIXME (?): this line breaks the cache of all steps below ONBUILD COPY --chown=jovyan:jovyan . /home/jovyan ONBUILD RUN echo "Checking for 'binder' or '.binder' subfolder" \ @@ -82,6 +83,15 @@ ONBUILD RUN echo "Checking for 'apt.txt'..." \ && rm -rf /var/lib/apt/lists/* \ ; fi +# Copy jupyter_notebook_config.py to /etc/jupyter +ONBUILD RUN echo "Checking for 'jupyter_notebook_config.py'..." \ + ; [ -d binder ] && cd binder \ + ; [ -d .binder ] && cd .binder \ + ; if test -f "jupyter_notebook_config.py" ; then \ + mkdir -p /etc/jupyter \ + && cp jupyter_notebook_config.py /etc/jupyter \ + ; fi + ONBUILD USER ${NB_USER} # Create "notebook" conda environment and dask labextensions @@ -134,16 +144,4 @@ ONBUILD RUN echo "Checking for 'start'..." \ chmod +x start \ && cp start /srv/start \ ; fi - -# Copy jupyter_notebook_config.py to /etc/jupyter, which is an action not done -# with repo2docker. -ONBUILD USER root -ONBUILD RUN echo "Checking for config 'jupyter_notebook_config.py'..." \ - ; [ -d binder ] && cd binder \ - ; [ -d .binder ] && cd .binder \ - ; if test -f "jupyter_notebook_config.py" ; then \ - mkdir -p /etc/jupyter \ - && cp jupyter_notebook_config.py /etc/jupyter \ - ; fi -ONBUILD USER ${NB_USER} # ----------------------