diff --git a/Dockerfile b/Dockerfile index 55150d4..6f08cac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -131,12 +131,31 @@ RUN set -x && \ fix-permissions "${CONDA_DIR}" && \ fix-permissions "/home/${NB_USER}" +EXPOSE 8888 + # Configure container startup ENTRYPOINT ["tini", "-g", "--"] -CMD ["start.sh"] +CMD ["start-notebook.sh"] # Copy local files as late as possible to avoid cache busting -COPY start.sh /usr/local/bin/ +COPY start.sh 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=15s --timeout=3s --start-period=5s --retries=3 \ + CMD wget -O- --no-verbose --tries=1 --no-check-certificate \ + http${GEN_CERT:+s}://localhost:8888${JUPYTERHUB_SERVICE_PREFIX:-/}api || exit 1 # Switch back to jovyan to avoid accidental container runs as root USER ${NB_UID} diff --git a/start-singleuser.sh b/start-singleuser.sh new file mode 100644 index 0000000..7c49847 --- /dev/null +++ b/start-singleuser.sh @@ -0,0 +1,13 @@ +#!/bin/bash +# Copyright (c) Jupyter Development Team. +# Distributed under the terms of the Modified BSD License. + +set -e + +# set default ip to 0.0.0.0 +if [[ "${NOTEBOOK_ARGS} $*" != *"--ip="* ]]; then + NOTEBOOK_ARGS="--ip=0.0.0.0 ${NOTEBOOK_ARGS}" +fi + +# shellcheck disable=SC1091,SC2086 +. /usr/local/bin/start.sh jupyterhub-singleuser ${NOTEBOOK_ARGS} "$@" \ No newline at end of file