From e4c54c9002c2af276ba07a5ba7634609b53df844 Mon Sep 17 00:00:00 2001 From: Min RK Date: Fri, 19 May 2017 17:36:01 -0700 Subject: [PATCH 1/2] finish removing files from $HOME - mplimporthook should be obsolete with matplotlib 2.0 - curlrc seems to be obsolete now (updates to base image?) - set WORKDIR to $HOME instead of $HOME/work (leave work there for compatibility) --- base-notebook/Dockerfile | 7 ++--- scipy-notebook/Dockerfile | 4 --- scipy-notebook/mplimporthook.py | 55 --------------------------------- 3 files changed, 3 insertions(+), 63 deletions(-) delete mode 100644 scipy-notebook/mplimporthook.py diff --git a/base-notebook/Dockerfile b/base-notebook/Dockerfile index 794fa7de..82790d12 100644 --- a/base-notebook/Dockerfile +++ b/base-notebook/Dockerfile @@ -52,9 +52,8 @@ RUN useradd -m -s /bin/bash -N -u $NB_UID $NB_USER && \ USER $NB_USER -# Setup jovyan home directory -RUN mkdir /home/$NB_USER/work && \ - echo "cacert=/etc/ssl/certs/ca-certificates.crt" > /home/$NB_USER/.curlrc +# Setup work directory for backward-compatibility +RUN mkdir /home/$NB_USER/work # Install conda as jovyan RUN cd /tmp && \ @@ -77,7 +76,7 @@ RUN conda install --quiet --yes \ USER root EXPOSE 8888 -WORKDIR /home/$NB_USER/work +WORKDIR $HOME # Configure container startup ENTRYPOINT ["tini", "--"] diff --git a/scipy-notebook/Dockerfile b/scipy-notebook/Dockerfile index edc56eee..1538a18e 100644 --- a/scipy-notebook/Dockerfile +++ b/scipy-notebook/Dockerfile @@ -86,10 +86,6 @@ RUN ln -s $CONDA_DIR/envs/python2/bin/pip $CONDA_DIR/bin/pip2 && \ ENV XDG_CACHE_HOME /home/$NB_USER/.cache/ RUN MPLBACKEND=Agg $CONDA_DIR/envs/python2/bin/python -c "import matplotlib.pyplot" -# Configure ipython kernel to use matplotlib inline backend by default -RUN mkdir -p $HOME/.ipython/profile_default/startup -COPY mplimporthook.py $HOME/.ipython/profile_default/startup/ - USER root # Install Python 2 kernel spec globally to avoid permission problems when NB_UID diff --git a/scipy-notebook/mplimporthook.py b/scipy-notebook/mplimporthook.py deleted file mode 100644 index 9fad7afe..00000000 --- a/scipy-notebook/mplimporthook.py +++ /dev/null @@ -1,55 +0,0 @@ -"""Startup script for IPython kernel. - -Installs an import hook to configure the matplotlib backend on the fly. - -Originally from @minrk at -https://github.com/minrk/profile_default/blob/master/startup/mplimporthook.py -Repurposed for docker-stacks to address repeat bugs like -https://github.com/jupyter/docker-stacks/issues/235. -""" -import sys -from IPython import get_ipython - -class MatplotlibFinder(object): - """Import hook that notices when matplotlib.pyplot or pylab is imported - and tries to configure the matplotlib backend appropriately for the - environment. - """ - _called = False - - def find_module(self, fullname, path=None): - if self._called: - # already handled - return - - if fullname not in ('pylab', 'matplotlib.pyplot'): - # not matplotlib - return - - # don't call me again - self._called = True - - try: - # remove myself from the import hooks - sys.meta_path = [loader for loader in sys.meta_path if loader is not self] - except ValueError: - pass - - ip = get_ipython() - if ip is None: - # not in an interactive environment - return - - if ip.pylab_gui_select: - # backend already selected - return - - if hasattr(ip, 'kernel'): - # default to inline in kernel environments - ip.enable_matplotlib('inline') - else: - print('enabling matplotlib') - ip.enable_matplotlib() - -# install the finder immediately -sys.meta_path.insert(0, MatplotlibFinder()) \ No newline at end of file From 877a95d1624b9db134008dcae08f044fba69d727 Mon Sep 17 00:00:00 2001 From: Min RK Date: Sat, 27 May 2017 18:24:57 -0700 Subject: [PATCH 2/2] add JULIA_PKGDIR to chown in start.sh --- base-notebook/start.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/base-notebook/start.sh b/base-notebook/start.sh index 516c4993..3ae92d5b 100755 --- a/base-notebook/start.sh +++ b/base-notebook/start.sh @@ -9,7 +9,11 @@ if [ $UID == 0 ] ; then # Change UID of NB_USER to NB_UID if it does not match if [ "$NB_UID" != $(id -u $NB_USER) ] ; then usermod -u $NB_UID $NB_USER - chown -R $NB_UID $CONDA_DIR + for d in "$CONDA_DIR" "$JULIA_PKGDIR"; do + if [[ ! -z "$d" && -d "$d" ]]; then + chown -R $NB_UID "$d" + fi + done fi # Change GID of NB_USER to NB_GID if NB_GID is passed as a parameter