You may consider using jupyter-server-proxy
I compiled and wrote plugins to run several apps within jupyterlab. Not all work well, but code-server does, though you may need to adapt it to your environment:
I was surprised but it was simple as others suggested:
# To install Server Proxy Extension for Lab
sudo /usr/local/anaconda3/bin/python3 -m pip install jupyter-server-proxy
# To Install VSCode code-server for proxying
sudo /usr/local/anaconda3/bin/python3 -m pip install jupyter-vscode-proxy
# Restart the hub for changes to apply
sudo systemctl restart jupyterhub.service
On login I see the VSCode icon next to iPython notebook … Concerns for myself include sudo for pip and also I am not running Hub at container, so the ports are exposed for other users I think… for test & dev this worked nicely, glad to run VSCode on the same remote host as Python kernel
Yes, this is one of the limitations of jupyter-server-proxy. This is why it’s recommended for use only where users are isolated from each other, such as in a container.
One issue seems to be that code launches jupyter server from the preinstalled python 3.6 instead of the conda notebook environment. If I open the Interactive Window it then installs pip and ipykernel in the python 3.6 environment. Then I can change Interactive Window to conda notebook environment and work in there. Sometimes I can then even get cells in notebook to execute. But I’ve not found the exact steps yet to get it working. Seems random.
Hello
I am trying to do exactly that : using JupyterHub as a … Hub, allowing users to start either JupyterLab or Code-server images on a microk8s server.
I took the idea from nils-braun codehub too.
I am struggling on the configuration of the proxy :
Code-server image needs the “chp: extraCommandLineFlags: - “–no-include-prefix”” option (or i get a 404 because Code-server doesn’t handle base-url )
JupyterLab image needs this option to be disabled, or I get a 404
For the selection of the profile (container image), i use the “profileList” option in the value.yaml used by the Helm chart to make the deployment (see code extract below).
Do you have succeeded on this, or are you using another method ?
Hi @Josh_Richardson
I didn’t found a way to really solve the issue, but I finally settled for a workaround.
The users are connected first on the JupyterLab interface, and they can click on a link to start CodeServer (see picture below).
I really think it should be possible (and even easy) to change the connection URL to redirect to the CodeServer page, but I didn’t found how.
To make my solution work, I basically installed CodeServer, server-proxy and vscode-proxy.
Here is my dockerfile (which also install a XFCE graphic server with jupyter-desktop-server) :
FROM xxxx (should work with any base image from JupyterLab project)
# Fix: https://github.com/hadolint/hadolint/wiki/DL4006
# Fix: https://github.com/koalaman/shellcheck/wiki/SC3014
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
USER root
# Installation des paquets pour le développement
RUN apt-get update --yes && \
apt-get install --yes --quiet --no-install-recommends \
curl \
iputils-ping \
build-essential \
make \
cmake \
g++ \
clang \
htop \
libopencv-dev \
&& \
apt-get --quiet clean && rm -rf /var/lib/apt/lists/*
# Installation de Code Server et server-proxy/vscode-proxy pour intégrer Code dans JupyterLab
ENV CODE_VERSION=4.7.1
RUN curl -fOL https://github.com/coder/code-server/releases/download/v$CODE_VERSION/code-server_${CODE_VERSION}_amd64.deb \
&& dpkg -i code-server_${CODE_VERSION}_amd64.deb \
&& rm -f code-server_${CODE_VERSION}_amd64.deb
RUN /opt/conda/bin/conda install -c conda-forge jupyter-server-proxy
RUN /opt/conda/bin/conda install -c conda-forge jupyter-vscode-proxy
# Installation du bureau XFCE et de l'extention Desktop server pour avoir un affichage graphique
RUN apt-get update --yes --quiet && \
apt-get install --yes --quiet \
dbus-x11 xfce4 xfce4-panel xfce4-session xfce4-settings xorg xubuntu-icon-theme && \
apt-get remove --yes --quiet light-locker && \
apt-get clean --quiet && rm -rf /var/lib/apt/lists/*
RUN /opt/conda/bin/conda install -c manics websockify && \
pip install git+https://github.com/yuvipanda/jupyter-desktop-server.git
# Switch back to jovyan to avoid accidental container runs as root
USER ${NB_UID}
I hope this helps, but I know this didn’t exactly solve the original issue : login directly to CodeServer.
Using conda to install jupyter-server-proxy, jupyter-vscode-proxy and code-server in the base environment also produces the result from your screenshot, @romainrossi.
However, to be able to run code in the VS Code editor, I had to manually install the Python extension, which also included some jupyter extensions:
After that, VS Code was able to find and connect to the right kernel.
My question is: is there a way to automate the Python extension installation, so users don’t have to do this manually every time?
It would be nice with a configuration option to include the VS Code editor with proper installations. It seems to become something that people want to do almost as much as using notebooks. Let me know if there is anything that I can do to help with this.
I have some issues with code server when it runs with JupyterHub on a GKE cluster, while it works perfectly when I test it locally in a Docker container. At first, I thought that it could be caused by an NFS server that I was running for shared data (another container), but I tried to deactivate the NFS server, and the issue still seems to persist. Based on what you are writing here, can there be an issue with having different node pools? For example, one for users and one for the hub.
It would be nice with a configuration option to include the VS Code editor as it is becoming very popular to use through a web browser. Not as a substitute for JupyterLab, but as a supplement for complex development. I will gladly help to make this happen however I can
Hi @antonvorobets I tried to install jupyter-server-proxy, jupyter-vscode-proxy and code-server using base conda, but I cannot see the VS Code icon popping up in the jupyterhub launcher. Can you list the steps you performed to make it work? Thanks
But it only worked when I used the image standalone in a Docker container. I had issues with VC Code when I used it in combination with JupyterHub.
It would be nice to add a configuration option for VS Code with the various JupyterHub deployments because there seems to be some issue when it’s just installed as above.
Came across a tutorial where the user was able to tweak the ‘code-spawner’ code and also add extracommand flags needed by code-server sitting behind a jupyter-server-proxy