mirror of
https://github.com/jupyter/docker-stacks.git
synced 2025-10-14 13:32:56 +00:00
79 lines
2.9 KiB
Docker
79 lines
2.9 KiB
Docker
# Copyright (c) Jupyter Development Team.
|
|
# Distributed under the terms of the Modified BSD License.
|
|
ARG OWNER=jupyter
|
|
ARG BASE_CONTAINER=$OWNER/docker-stacks-foundation
|
|
FROM $BASE_CONTAINER
|
|
|
|
LABEL maintainer="Jupyter Project <jupyter@googlegroups.com>"
|
|
|
|
# Fix: https://github.com/hadolint/hadolint/wiki/DL4006
|
|
# Fix: https://github.com/koalaman/shellcheck/wiki/SC3014
|
|
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
|
|
|
USER root
|
|
|
|
# Install all OS dependencies for notebook server that starts but lacks all
|
|
# features (e.g., download as all possible file formats)
|
|
RUN apt-get update --yes && \
|
|
apt-get install --yes --no-install-recommends \
|
|
fonts-liberation \
|
|
# - pandoc is used to convert notebooks to html files
|
|
# it's not present in aarch64 ubuntu image, so we install it here
|
|
pandoc \
|
|
# - run-one - a wrapper script that runs no more
|
|
# than one unique instance of some command with a unique set of arguments,
|
|
# we use `run-one-constantly` to support `RESTARTABLE` option
|
|
run-one && \
|
|
apt-get clean && rm -rf /var/lib/apt/lists/*
|
|
|
|
USER ${NB_UID}
|
|
|
|
# Install Jupyter Notebook, Lab, and Hub
|
|
# Generate a notebook server config
|
|
# Cleanup temporary files
|
|
# Correct permissions
|
|
# Do all this in a single RUN command to avoid duplicating all of the
|
|
# files across image layers when the permissions change
|
|
WORKDIR /tmp
|
|
RUN mamba install --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 docker_healthcheck.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 /etc/jupyter/docker_healthcheck.py || exit 1
|
|
|
|
# Switch back to jovyan to avoid accidental container runs as root
|
|
USER ${NB_UID}
|
|
|
|
WORKDIR "${HOME}"
|