Commit 937dc6ef authored by Peter Parente's avatar Peter Parente

Create jovyan user before conda install

Avoids costly chown, fixes #81

(c) Copyright IBM Corp. 2015
parent 3afdf219
...@@ -38,31 +38,36 @@ ENV SHELL /bin/bash ...@@ -38,31 +38,36 @@ ENV SHELL /bin/bash
ENV NB_USER jovyan ENV NB_USER jovyan
ENV NB_UID 1000 ENV NB_UID 1000
# Install conda # Create jovyan user with UID=1000 and in the 'users' group
RUN mkdir -p $CONDA_DIR && \ RUN useradd -m -s /bin/bash -N -u $NB_UID $NB_USER && \
echo export PATH=$CONDA_DIR/bin:'$PATH' > /etc/profile.d/conda.sh && \ mkdir -p /opt/conda && \
chown jovyan /opt/conda
USER jovyan
# Setup jovyan home directory
RUN mkdir /home/$NB_USER/work && \
mkdir /home/$NB_USER/.jupyter && \
mkdir /home/$NB_USER/.local
# Install conda as jovyan
RUN cd /tmp && \
mkdir -p $CONDA_DIR && \
wget --quiet https://repo.continuum.io/miniconda/Miniconda3-3.9.1-Linux-x86_64.sh && \ wget --quiet https://repo.continuum.io/miniconda/Miniconda3-3.9.1-Linux-x86_64.sh && \
echo "6c6b44acdd0bc4229377ee10d52c8ac6160c336d9cdd669db7371aa9344e1ac3 *Miniconda3-3.9.1-Linux-x86_64.sh" | sha256sum -c - && \ echo "6c6b44acdd0bc4229377ee10d52c8ac6160c336d9cdd669db7371aa9344e1ac3 *Miniconda3-3.9.1-Linux-x86_64.sh" | sha256sum -c - && \
/bin/bash /Miniconda3-3.9.1-Linux-x86_64.sh -f -b -p $CONDA_DIR && \ /bin/bash Miniconda3-3.9.1-Linux-x86_64.sh -f -b -p $CONDA_DIR && \
rm Miniconda3-3.9.1-Linux-x86_64.sh && \ rm Miniconda3-3.9.1-Linux-x86_64.sh && \
$CONDA_DIR/bin/conda install --yes conda==3.14.1 $CONDA_DIR/bin/conda install --yes conda==3.14.1
# Install Jupyter notebook # Install Jupyter notebook as jovyan
RUN conda install --yes \ RUN conda install --yes \
'notebook=4.0*' \ 'notebook=4.0*' \
terminado \ terminado \
&& conda clean -yt && conda clean -yt
# Create jovyan user with UID=1000 and in the 'users' group USER root
# Grant ownership over the conda dir and home dir, but stick the group as root.
RUN useradd -m -s /bin/bash -N -u $NB_UID $NB_USER && \
mkdir /home/$NB_USER/work && \
mkdir /home/$NB_USER/.jupyter && \
mkdir /home/$NB_USER/.local && \
chown -R $NB_USER:users $CONDA_DIR && \
chown -R $NB_USER:users /home/$NB_USER
# Configure container startup # Configure container startup as root
EXPOSE 8888 EXPOSE 8888
WORKDIR /home/$NB_USER/work WORKDIR /home/$NB_USER/work
ENTRYPOINT ["tini", "--"] ENTRYPOINT ["tini", "--"]
...@@ -71,4 +76,7 @@ CMD ["start-notebook.sh"] ...@@ -71,4 +76,7 @@ CMD ["start-notebook.sh"]
# Add local files as late as possible to avoid cache busting # Add local files as late as possible to avoid cache busting
COPY start-notebook.sh /usr/local/bin/ COPY start-notebook.sh /usr/local/bin/
COPY jupyter_notebook_config.py /home/$NB_USER/.jupyter/ COPY jupyter_notebook_config.py /home/$NB_USER/.jupyter/
RUN chown -R $NB_USER:users /home/$NB_USER/.jupyter RUN chown -R $NB_USER:users /home/$NB_USER/.jupyter
\ No newline at end of file
# Stay as root so that the start-notebook.sh command can properly change
# jovyan to a configurable NB_UID and grant sudo if requested
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment