Swap tini for supervisord

* Pass $@ args to start-notebook.sh
* Set tini as entrypoint, but keep start-notebook.sh as easily overridable CMD
* su to jovyan user within start-notebook.sh script

Contribution (c) Copyright IBM Corp. 2015
This commit is contained in:
Peter Parente
2015-09-16 22:48:32 -04:00
parent 735c520486
commit 678b64e9e4
7 changed files with 21 additions and 18 deletions

View File

@@ -91,4 +91,5 @@ USER root
# switching at runtime.
RUN $CONDA_DIR/envs/python2/bin/python \
$CONDA_DIR/envs/python2/bin/ipython \
kernelspec install-self
kernelspec install-self

View File

@@ -96,4 +96,5 @@ USER root
# switching at runtime.
RUN $CONDA_DIR/envs/python2/bin/python \
$CONDA_DIR/envs/python2/bin/ipython \
kernelspec install-self
kernelspec install-self

View File

@@ -22,13 +22,19 @@ RUN apt-get update && apt-get install -yq --no-install-recommends \
texlive-latex-extra \
texlive-fonts-extra \
texlive-fonts-recommended \
supervisor \
sudo \
&& apt-get clean
# Install Tini
RUN wget --quiet https://github.com/krallin/tini/releases/download/v0.6.0/tini && \
echo "d5ed732199c36a1189320e6c4859f0169e950692f451c03e7854243b95f4234b *tini" | sha256sum -c - && \
mv tini /usr/local/bin/tini && \
chmod +x /usr/local/bin/tini
# Configure environment
ENV CONDA_DIR /opt/conda
ENV PATH $CONDA_DIR/bin:$PATH
ENV SHELL /bin/bash
ENV NB_USER jovyan
ENV NB_UID 1000
@@ -36,6 +42,7 @@ ENV NB_UID 1000
RUN mkdir -p $CONDA_DIR && \
echo export PATH=$CONDA_DIR/bin:'$PATH' > /etc/profile.d/conda.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 - && \
/bin/bash /Miniconda3-3.9.1-Linux-x86_64.sh -f -b -p $CONDA_DIR && \
rm Miniconda3-3.9.1-Linux-x86_64.sh && \
$CONDA_DIR/bin/conda install --yes conda==3.14.1
@@ -57,10 +64,11 @@ RUN useradd -m -s /bin/bash -N -u $NB_UID $NB_USER && \
# Configure container startup
EXPOSE 8888
CMD [ "start-notebook.sh" ]
WORKDIR /home/$NB_USER/work
ENTRYPOINT ["tini", "--"]
CMD ["start-notebook.sh"]
# Add local files as late as possible to avoid cache busting
COPY start-notebook.sh /usr/local/bin/
COPY notebook.conf /etc/supervisor/conf.d/
COPY jupyter_notebook_config.py /home/$NB_USER/.jupyter/
RUN chown -R $NB_USER:users /home/$NB_USER/.jupyter

View File

@@ -1,10 +0,0 @@
[program:notebook]
user=jovyan
umask=0002
directory=/home/jovyan/work
command=ipython notebook
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/%(program_name)s.log
redirect_stderr=true
environment=HOME="/home/jovyan",USER="jovyan",SHELL="/bin/bash"

View File

@@ -11,5 +11,6 @@ if [ ! -z "$GRANT_SUDO" ]; then
echo "$NB_USER ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/notebook
fi
# Start supervisord in foreground, PID1
exec supervisord -n -c /etc/supervisor/supervisord.conf
# Start the notebook server
exec su $NB_USER -c "env PATH=$PATH jupyter notebook $@"

View File

@@ -57,4 +57,5 @@ USER root
# switching at runtime.
RUN $CONDA_DIR/envs/python2/bin/python \
$CONDA_DIR/envs/python2/bin/ipython \
kernelspec install-self
kernelspec install-self

View File

@@ -52,3 +52,4 @@ USER root
RUN $CONDA_DIR/envs/python2/bin/python \
$CONDA_DIR/envs/python2/bin/ipython \
kernelspec install-self