Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Commit

Permalink
Merge pull request #29 from manics/turbovnc
Browse files Browse the repository at this point in the history
  • Loading branch information
yuvipanda authored Feb 2, 2021
2 parents 83ab1a6 + 3a00df2 commit ea881bb
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 15 deletions.
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ RUN apt-get -y update \
xfce4-settings \
xorg \
xubuntu-icon-theme

# Remove light-locker to prevent screen lock
RUN wget 'https://sourceforge.net/projects/turbovnc/files/2.2.5/turbovnc_2.2.5_amd64.deb/download' -O turbovnc_2.2.5_amd64.deb && \
apt-get install -y -q ./turbovnc_2.2.5_amd64.deb && \
apt-get remove -y -q light-locker && \
rm ./turbovnc_2.2.5_amd64.deb && \
ln -s /opt/TurboVNC/bin/* /usr/local/bin/

# apt-get may result in root-owned directories/files under $HOME
RUN chown -R $NB_UID:$NB_GID $HOME

Expand Down
16 changes: 5 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,16 @@ Run XFCE (or other desktop environments) on a JupyterHub.

This is based on https://github.com/ryanlovett/nbnovnc and a fork of https://github.com/manics/jupyter-omeroanalysis-desktop

If a `vncserver` executable is found in `PATH` it will be used, otherwise a bundled TightVNC server is run.
You can use this to install vncserver with support for other features, for example the [`Dockerfile`](./Dockerfile) in this repository installs TurboVNC for improved OpenGL support.

## Docker

To spin up such a notebook, please build and run the container like this.
## Docker

To spin up such a notebook first build the container:

```bash
$ docker build -t $(whoami)/$(basename ${PWD}) .
Sending build context to Docker daemon 36.76MB
Step 1/5 : FROM jupyter/datascience-notebook:latest
**snip**
Successfully installed aiohttp-3.6.2 async-timeout-3.0.1 jupyter-desktop-server-0.1.2 jupyter-server-proxy-1.5.0 multidict-4.7.6 simpervisor-0.3 yarl-1.4.2
Removing intermediate container ed906d6b1074
---> 826211e74ce1
Successfully built 826211e74ce1
Successfully tagged myname/jupyter-desktop-server:latest
$
```

Now you can ran the image:
Expand Down
23 changes: 19 additions & 4 deletions jupyter_desktop/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import shlex
from shutil import which
import tempfile


Expand All @@ -10,14 +11,28 @@ def setup_desktop():
# This is only readable, writeable & searchable by our uid
sockets_dir = tempfile.mkdtemp()
sockets_path = os.path.join(sockets_dir, 'vnc-socket')
vncserver = which('vncserver')

vnc_command = ' '.join((shlex.quote(p) for p in [
os.path.join(HERE, 'share/tigervnc/bin/vncserver'),
if vncserver:
vnc_args = [
vncserver,
]
socket_args = []
else:
# Use bundled tigervnc
vnc_args = [
os.path.join(HERE, 'share/tigervnc/bin/vncserver'),
'-rfbunixpath', sockets_path,
]
socket_args = [
'--unix-target', sockets_path
]

vnc_command = ' '.join(shlex.quote(p) for p in (vnc_args + [
'-verbose',
'-xstartup', os.path.join(HERE, 'share/xstartup'),
'-geometry', '1680x1050',
'-SecurityTypes', 'None',
'-rfbunixpath', sockets_path,
'-fg',
':1',
]))
Expand All @@ -27,7 +42,7 @@ def setup_desktop():
'--web', os.path.join(HERE, 'share/web/noVNC-1.1.0'),
'--heartbeat', '30',
'5901',
'--unix-target', sockets_path,
] + socket_args + [
'--',
'/bin/sh', '-c',
f'cd {os.getcwd()} && {vnc_command}'
Expand Down

0 comments on commit ea881bb

Please sign in to comment.