jupyter-server / jupyverse

A Jupyter server based on FastAPI :rocket:
https://jupyter-server.github.io/jupyverse
Other
210 stars 27 forks source link

Docker distribution #410

Open almereyda opened 1 month ago

almereyda commented 1 month ago

Problem

Wanting to create a new JupyterLab on Jupyverse instance, passing by the conversation in #301, I've found a nice example on how to run the authentication dependency Fief through Docker Compose.

As a Jupyverse user, I am now left to imagine the same for it.

Proposed Solution

Add a section about running Jupyverse in a container to the documentation page

Additional context

This assumes the existence of an example Container image capable of running the Jupyverse collaboration server, best enriched with a useful Compose environment.

JupyterLab has top-level support from Docker, as seen in the official guide Data science with JupyterLab | Docker Docs.

Jupyverse should be similarly easy to employ as the jupyter/docker-stacks.

welcome[bot] commented 1 month ago

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively. welcome You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! :wave:
Welcome to the Jupyter community! :tada:

davidbrochart commented 1 month ago

Thanks for opening an issue @almereyda. Would you like to contribute with this enhancement to the documentation?

almereyda commented 1 month ago

Right at it.

davidbrochart commented 1 month ago

Awesome, looking forward to it :tada:

almereyda commented 1 month ago

I was able to run Jupyverse with this patch

diff --git a/images/base-notebook/Dockerfile b/images/base-notebook/Dockerfile
index 07903b94..b05aad79 100644
--- a/images/base-notebook/Dockerfile
+++ b/images/base-notebook/Dockerfile
@@ -42,8 +42,10 @@ RUN mamba install --yes \
     'jupyterlab' \
     'notebook' \
     'jupyterhub' \
-    'nbclassic' && \
-    jupyter server --generate-config && \
+    'nbclassic' \
+    'jupyverse' \
+    'fps-auth' \
+    'fps-jupyterlab' && \
     mamba clean --all -f -y && \
     npm cache clean --force && \
     jupyter lab clean && \
@@ -51,6 +53,12 @@ RUN mamba install --yes \
     fix-permissions "${CONDA_DIR}" && \
     fix-permissions "/home/${NB_USER}"

+RUN pip install --user -U \
+                https://github.com/jupyterlab/jupyter-collaboration/releases/download/v3.0.0alpha2/jupyter_collaboration-3.0.0a2-py3-none-any.whl \
+                https://github.com/jupyterlab/jupyter-collaboration/releases/download/v3.0.0alpha2/jupyter_collaboration_ui-1.0.0a2-py3-none-any.whl \
+                https://github.com/jupyterlab/jupyter-collaboration/releases/download/v3.0.0alpha2/jupyter_docprovider-1.0.0a2-py3-none-any.whl \
+                https://github.com/jupyterlab/jupyter-collaboration/releases/download/v3.0.0alpha2/jupyter_server_ydoc-1.0.0a2-py3-none-any.whl
+
 ENV JUPYTER_PORT=8888
 EXPOSE $JUPYTER_PORT

diff --git a/images/base-notebook/start-singleuser.py b/images/base-notebook/start-singleuser.py
index c80339f5..2d85f780 100755
--- a/images/base-notebook/start-singleuser.py
+++ b/images/base-notebook/start-singleuser.py
@@ -6,11 +6,30 @@ import shlex
 import sys

 # Entrypoint is start.sh
-command = ["jupyterhub-singleuser"]
+command = ["jupyverse"]

-# set default ip to 0.0.0.0
-if "--ip=" not in os.environ.get("NOTEBOOK_ARGS", ""):
-    command.append("--ip=0.0.0.0")
+# set default listening host to 0.0.0.0
+if "--host=" not in os.environ.get("NOTEBOOK_ARGS", ""):
+    command.append("--host=0.0.0.0")
+
+# set default host port to 8000
+if "--port=" not in os.environ.get("NOTEBOOK_ARGS", ""):
+    command.append("--port=8000")
+
+# set default jupyterlab.server_side_execution to true
+if "jupyterlab.server_side_execution=" not in os.environ.get("NOTEBOOK_ARGS", ""):
+    command.append("--set")
+    command.append("jupyterlab.server_side_execution=true")
+
+# set default kernels.require_yjs to true
+if "kernels.require_yjs=" not in os.environ.get("NOTEBOOK_ARGS", ""):
+    command.append("--set")
+    command.append("kernels.require_yjs=true")
+
+# set default auth mode to noauth
+if "auth.mode=" not in os.environ.get("NOTEBOOK_ARGS", ""):
+    command.append("--set")
+    command.append("auth.mode=noauth")

 # Append any optional NOTEBOOK_ARGS we were passed in.
 # This is supposed to be multiple args passed on to the notebook command,

on top of jupyter/docker-stacks@996fae12 with these commands:

cd  images/base-notebook
podman build --format docker -t jupyverse .
podman run --rm -it -e NOTEBOOK_ARGS="--set auth.mode=token" -p 8000:8000 jupyverse start-singleuser.py

While it was possible to create and save a notebook which returned upon reopening, it was not possible to replicate server side execution.

Needs further investigation.

almereyda commented 1 month ago

The installation of the collaboration features should probably be their own FROM: overlay, plus the addition of the two associated --set parameters/of the different entrypoint.

Also I was unsure which entrypoint to apply, both start-notebook.py and start-singleuser.py didn't really fit, other than for the default --auth.mode=noauth mode. Should we delete both and start anew with start-jupyverse.py?