[winswitch] [xpra] Xpra and JupyterHub

Troll Berserker berserker.troll at yandex.com
Sun Jul 8 22:32:52 BST 2018


I was working on a local JupyterHub deployment
(if you don't know what Jupyter and JupyterHub is,
you may get a rough idea what is it from the first
8 minutes of this https://www.youtube.com/watch?v=gSVvxOchT8Y video)
and once thought that it would be great to run X11 displays
in Jupyter signle-user notebook server about the same way
it is possible to start terminal emulators inside it.

While googling I've found the project named nbserverproxy
and the issue about proxying noVNC with it

nbserverproxy is a Jupyter notebook extension which
enables one to access a HTTP service running inside
Jupyter single-user server, see example in the readme

I've tried to run Xpra and discovered a bug in the nbserverproxy
websocket proxying logic, the fix will be merged sooner or later.

There is also a request to make nbserverproxy a standalone service
Having websocket issue solved, I've tried to use nbserverproxy
without the Jupyter Notebook app running and it was possible,
the JupyterHub package provides classes which make it easy
to authenticate against the Hub.

A day ago I finally got a working container with Xpra and the
proxy in front of it running without Jupyter notebook server.

JupyterHub supports a bunch of different Authenticators and Spawners
(for example, we are using KubeSpawner to spawn single-user
containers in a Kubernetes cloud)
I don't know any other remote desktop project which could be
as flexible as JupyterHub+Xpra combination.
AFAIK x2go and Apache Guacamole support some sort of load balancing,
but I don't think they support, for example, Kubernetes.
The disadvantage is that the only way to access Xpra is its HTML5 client.

I'm attaching the Dockerfile and the entry script I'm using.
This is the first version which is not ideal and has some workarounds and
dirty hacks I had to use to make it working.
I've found that  Xpra became kinda rebellious: it ignores the orders I give it
not to launch dbus and pulseaudio and not to put sockets in an original HOME directory
(which is a network-mounted FS which doesn't seem to support sockets and pipes)
so I had to install nss-sssd connector to map UIDs to usernames so that
the dbus-launch doesn't refuse to start and I had to override the HOME variable.
-------------- next part --------------
FROM ubuntu:18.04

ARG TERM=linux
ARG DEBIAN_FRONTEND=noninteractive

RUN echo 'APT::Install-Recommends "false";' > /etc/apt/apt.conf.d/norecommendsplease \
 && apt-get update \
 && apt-get install -y curl gnupg patch ca-certificates

RUN curl https://xpra.org/gpg.asc | apt-key add - \
 && echo "deb https://xpra.org/beta bionic main" > /etc/apt/sources.list.d/xpra.list \
 && apt-get update \
 && apt-get install -y xpra python-websockify libjs-jquery

RUN apt-get install -y python3-pip git python3-setuptools \
 && pip3 install jupyterhub git+https://github.com/BerserkerTroll/nbserverproxy.git@patch-1

RUN apt-get install -y libnss-sss xterm

ADD proxyxpra.py /

ENTRYPOINT '/proxyxpra.py'

More information about the shifter-users mailing list