diff --git a/Dockerfile b/Dockerfile index 6526a28..810958e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -102,3 +102,46 @@ RUN set -x && \ ENV CONDA_CUDA_OVERRIDE="11.2" RUN mamba install -y tensorflow cudatoolkit>=11.2 -c conda-forge #RUN mamba install -y -c conda-forge tensorflow-gpu +WORKDIR /tmp +RUN mamba install --quiet --yes \ + 'notebook' \ + 'jupyterhub' \ + 'jupyterlab' && \ + jupyter notebook --generate-config && \ + mamba clean --all -f -y && \ + npm cache clean --force && \ + jupyter lab clean && \ + rm -rf "/home/${NB_USER}/.cache/yarn" && \ + fix-permissions "${CONDA_DIR}" && \ + fix-permissions "/home/${NB_USER}" + +ENV JUPYTER_PORT=8888 +EXPOSE $JUPYTER_PORT + +# Configure container startup +CMD ["start-notebook.sh"] + +# Copy local files as late as possible to avoid cache busting +COPY start-notebook.sh start-singleuser.sh /usr/local/bin/ +# Currently need to have both jupyter_notebook_config and jupyter_server_config to support classic and lab +COPY jupyter_server_config.py /etc/jupyter/ + +# Fix permissions on /etc/jupyter as root +USER root + +# Legacy for Jupyter Notebook Server, see: [#1205](https://github.com/jupyter/docker-stacks/issues/1205) +RUN sed -re "s/c.ServerApp/c.NotebookApp/g" \ + /etc/jupyter/jupyter_server_config.py > /etc/jupyter/jupyter_notebook_config.py && \ + fix-permissions /etc/jupyter/ + +# HEALTHCHECK documentation: https://docs.docker.com/engine/reference/builder/#healthcheck +# This healtcheck works well for `lab`, `notebook`, `nbclassic`, `server` and `retro` jupyter commands +# https://github.com/jupyter/docker-stacks/issues/915#issuecomment-1068528799 +HEALTHCHECK --interval=5s --timeout=3s --start-period=5s --retries=3 \ + CMD wget -O- --no-verbose --tries=1 --no-check-certificate \ + http${GEN_CERT:+s}://localhost:${JUPYTER_PORT}${JUPYTERHUB_SERVICE_PREFIX:-/}api || exit 1 + +# Switch back to jovyan to avoid accidental container runs as root +USER ${NB_UID} + +WORKDIR "${HOME}" \ No newline at end of file