From e62e2c29191885f0a74d6287a4020bc52dc70d7e Mon Sep 17 00:00:00 2001 From: Mark Date: Sat, 1 Oct 2022 19:10:15 -0700 Subject: [PATCH] Added config volume --- jupyter/README.md | 3 --- jupyter/build/base/Dockerfile | 6 ++++-- jupyter/build/base/jupyter_server_config.py | 2 +- jupyter/build/base/overrides.json | 5 ----- jupyter/build/base/start-notebook.sh | 10 +++++----- jupyter/docker-compose.yml | 3 ++- 6 files changed, 12 insertions(+), 17 deletions(-) delete mode 100644 jupyter/build/base/overrides.json diff --git a/jupyter/README.md b/jupyter/README.md index 0ceb32f..584c5be 100644 --- a/jupyter/README.md +++ b/jupyter/README.md @@ -31,9 +31,6 @@ To build this image, run `build/build.fish.` Edit the script to customize the im ## TODO - - Port config - - User config - - Volume permissions - Auto dark theme - Fix sage - Selenium (broken) diff --git a/jupyter/build/base/Dockerfile b/jupyter/build/base/Dockerfile index d45f767..a2d39f3 100644 --- a/jupyter/build/base/Dockerfile +++ b/jupyter/build/base/Dockerfile @@ -156,7 +156,6 @@ RUN set -x && \ cut -d " " -f 1,2 \ >> "${CONDA_DIR}/conda-meta/pinned" \ && \ - jupyter notebook --generate-config && \ mamba clean --all -f -y && \ npm cache clean --force && \ jupyter lab clean && \ @@ -177,13 +176,16 @@ COPY jupyter_server_config.py /etc/jupyter/ COPY --chown=${NB_UID}:${NB_GID} Rprofile.site /opt/conda/lib/R/etc/ USER root -#COPY overrides.json /opt/conda/share/jupyter/lab/settings/ RUN mkdir "${HOME}/notebooks" && \ chown "${NB_UID}:${NB_GID}" "${HOME}/notebooks" &&\ chmod u+rwx "${HOME}/notebooks" VOLUME "${HOME}/notebooks" +RUN mkdir -p "${HOME}/.jupyter" && \ + chown "${NB_UID}:${NB_GID}" "${HOME}/.jupyter" &&\ + chmod u+rwx "${HOME}/.jupyter" +VOLUME "${HOME}/.jupyter" # Legacy for Jupyter Notebook Server, see: [#1205](https://github.com/jupyter/docker-stacks/issues/1205) #RUN sed -re "s/c.ServerApp/c.NotebookApp/g" \ diff --git a/jupyter/build/base/jupyter_server_config.py b/jupyter/build/base/jupyter_server_config.py index 4c23d14..07ebd09 100644 --- a/jupyter/build/base/jupyter_server_config.py +++ b/jupyter/build/base/jupyter_server_config.py @@ -8,7 +8,7 @@ c = get_config() # noqa: F821 c.ServerApp.ip = "0.0.0.0" c.ServerApp.port = 8888 c.ServerApp.open_browser = False -c.ServerApp.root_dir = "/home/joyvan/notebooks" +c.ServerApp.root_dir = "/home/jovyan/notebooks" # to output both image/svg+xml and application/pdf plot formats in the notebook file c.InlineBackend.figure_formats = {"png", "jpeg", "svg", "pdf"} diff --git a/jupyter/build/base/overrides.json b/jupyter/build/base/overrides.json deleted file mode 100644 index 1ae6394..0000000 --- a/jupyter/build/base/overrides.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "@jupyterlab/apputils-extension:themes": { - "theme": "JupyterLab Dark" - } -} diff --git a/jupyter/build/base/start-notebook.sh b/jupyter/build/base/start-notebook.sh index 6c3be0a..35c3f5e 100755 --- a/jupyter/build/base/start-notebook.sh +++ b/jupyter/build/base/start-notebook.sh @@ -4,10 +4,6 @@ set -e -# The Jupyter command to launch -# JupyterLab by default -DOCKER_STACKS_JUPYTER_CMD="${DOCKER_STACKS_JUPYTER_CMD:=lab}" - if [[ -n "${JUPYTERHUB_API_TOKEN}" ]]; then echo "WARNING: using start-singleuser.sh instead of start-notebook.sh to start a server associated with JupyterHub." exec /usr/local/bin/start-singleuser.sh "$@" @@ -18,4 +14,8 @@ if [[ "${RESTARTABLE}" == "yes" ]]; then wrapper="" fi -exec /usr/local/bin/start.sh ${wrapper} jupyter ${DOCKER_STACKS_JUPYTER_CMD} ${NOTEBOOK_ARGS} "$@" +if [ ! -f /home/${NB_USER}/.jupyter/jupyter_notebook_config.py ]; then + jupyter notebook --generate-config +fi + +exec /usr/local/bin/start.sh ${wrapper} jupyter lab ${NOTEBOOK_ARGS} "$@" diff --git a/jupyter/docker-compose.yml b/jupyter/docker-compose.yml index 26522b3..5905449 100644 --- a/jupyter/docker-compose.yml +++ b/jupyter/docker-compose.yml @@ -7,7 +7,8 @@ services: restart: unless-stopped volumes: - - "./notebooks:/home/joyvan/notebooks" + - "./notebooks:/home/jovyan/notebooks" + - "./jupyter:/home/jovyan/.jupyter" # host:container ports: