mirror of
https://github.com/jupyter/docker-stacks.git
synced 2025-10-15 22:12:57 +00:00
Merge pull request #388 from minrk/nothing-in-home
finish removing files from $HOME
This commit is contained in:
@@ -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", "--"]
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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())
|
Reference in New Issue
Block a user