Spawn an IDE with jupyter server proxy

Hi all,
I have installed the jupyterhub with the helm chart and made some customizations to the values file. I have several server options → profiles for users. I want one of the profiles to spawn an IDE directly to another ns. This is the dockerfile of the pod that should be spawned:

FROM lscr.io/linuxserver/code-server:latest
RUN apt-get update && apt-get install -y \
    gcc \
    python3-dev \
    python3-pip

RUN pip install \
    "apache-airflow[celery]==2.9.2" --constraint "https://raw.githubusercontent.com/apache/airflow/constraints-2.9.2/constraints-3.8.txt"
EXPOSE 8443

I wanted to se the jupyter-server-proxy to directly send the user to this port rather than the notebook, but I struggle to understand the documentation for that. I saw that Accessing Arbitrary Ports or Hosts — Jupyter Server Proxy documentation can be helpful but I do not know where this config should be added (perhaps on hub.extraConfig).

If you want to use jupyter-server-proxy, the dockerfile you posted will not work. Jupyter Server Proxy needs a jupyter server to proxy the requests/reponse to third party web app. So, you are obliged to install jupyter_server and jupyterhub (which provides jupyterhub-singleuser) and all the related entrypoint scripts that a jupyterhub-singleuser image provides.

I would suggest you to take the jupyterhub-singleuser image and add code-server into it. Then, you will have to create an entrypoint to code-server and it can be done using jupyter_server_proxy.py file (You need to look where to place this in the image) with following content:

c.ServerProxy.servers = {
    "code-server": {
        "command": ["code-server", "--bind-addr", "localhost:{port}"], 
    }
}

Then in the kubespawner_override you will have to configure image name and default_url as follows:

{
    "image_spec": "<custom image name>",
    "default_url": "/code-server",
}

This is more or less how to configure to spawn a code server instance instead of JupyterLab/notebook

1 Like