Refactor to just be jupyter-desktop (#1)

Refactor to just be jupyter-desktop
This commit is contained in:
Yuvi Panda 2019-10-29 12:34:37 -07:00 committed by GitHub
commit e39bd9a1b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 105 additions and 177 deletions

View File

@ -1,87 +0,0 @@
FROM jupyter/base-notebook:1386e2046833
USER root
# Useful tools for debugging connection problems
RUN apt-get update -y -q && \
apt-get install -y -q \
curl \
net-tools \
vim
# Desktop environment, keep in sync with jupyter_notebook_config.py
# ENV DESKTOP_PACKAGE lxde
ENV DESKTOP_PACKAGE xfce4
RUN apt-get update -y -q && \
apt-get install -y -q \
xterm \
${DESKTOP_PACKAGE}
# Don't install distro versions of tigervnc and websockify, instead install
# upstream versions
# Novnc: just want web files
RUN cd /opt && \
curl -sSfL https://github.com/novnc/noVNC/archive/v1.1.0.tar.gz | tar -zxf -
# Patch novnc to use correct path to websockify (defaults to /)
# Note if you use vnc.html you will need to patch ui.js to use the correct path
# and also to override localstorage which may store an incorrect path from a
# different session
# Also resize server instead of scaling client
RUN sed -i.bak \
-e "s%\('path', 'websockify'\)%'path', window.location.pathname.replace(/[^/]*$/, '').substring(1) + 'websockify'); console.log('websockify path:' + path%" \
-re "s%rfb.scaleViewport = .+%rfb.resizeSession = readQueryVariable('resize', true);%" \
/opt/noVNC-1.1.0/vnc_lite.html
# Install tigervnc to /usr/local
RUN curl -sSfL 'https://bintray.com/tigervnc/stable/download_file?file_path=tigervnc-1.9.0.x86_64.tar.gz' | tar -zxf - -C /usr/local --strip=2
USER jovyan
# Custom jupyter-server-proxy to load vnc_lite.html instead of /
# https://github.com/jupyterhub/jupyter-server-proxy/pull/151
RUN /opt/conda/bin/pip install https://github.com/manics/jupyter-server-proxy/archive/1f22ccf44abd7ab5f7b306d57b6adb1dc3190e8b.zip
RUN conda install -y -q -c manics websockify=0.9.0
ADD jupyter_notebook_config.py /home/jovyan/.jupyter/jupyter_notebook_config.py
########## Applications
USER root
RUN apt-get update -y -q && \
apt-get install -y -q \
firefox \
less \
openjdk-8-jre \
unzip
# default-jre is java 11 which is incompatible with Fiji
USER jovyan
RUN wget -q https://downloads.imagej.net/fiji/latest/fiji-nojre.zip && \
unzip -q fiji-nojre.zip && \
echo TODO: rm fiji-nojre.zip
RUN wget -q https://github.com/ome/omero-insight/releases/download/v5.5.6/OMERO.imagej-5.5.6.zip && \
cd Fiji.app/plugins && \
unzip -q ../../OMERO.imagej-5.5.6.zip && \
echo TODO: rm OMERO.imagej-5.5.6.zip
RUN wget -q https://github.com/ome/omero-insight/releases/download/v5.5.6/OMERO.insight-5.5.6.zip && \
unzip -q OMERO.insight-5.5.6.zip && \
echo TODO: rm OMERO.insight-5.5.6.zip
RUN mkdir .java && \
cd OMERO.insight-5.5.6 && \
wget -q https://www.openmicroscopy.org/img/logos/omero-logomark.svg
# https://developer.gnome.org/desktop-entry-spec/
#COPY --chown=${NB_UID}:${NB_GID} *.desktop /home/jovyan/Desktop/
COPY --chown=1000:100 *.desktop /home/jovyan/Desktop/
# Configure default OMERO.insight server list
#COPY --chown=${NB_UID}:${NB_GID} java_userPrefs .java/.userPrefs
COPY --chown=1000:100 java_userPrefs .java/.userPrefs
WORKDIR ${HOME}
# Both these should work:
# http://127.0.0.1:8888/desktop
# http://localhost:5901/vnc.html

View File

@ -1,14 +0,0 @@
[Desktop Entry]
Version=1.0
Name=Fiji Is Just ImageJ
GenericName=Fiji Is Just ImageJ
X-GNOME-FullName=Fiji Is Just ImageJ
Comment=Scientific Image Analysis
Type=Application
Categories=Education;Science;ImageProcessing;
Exec=/home/jovyan/Fiji.app/ImageJ-linux64
TryExec=/home/jovyan/Fiji.app/ImageJ-linux64
Terminal=false
StartupNotify=true
Icon=/home/jovyan/Fiji.app/images/icon.png
StartupWMClass=fiji-Main

View File

@ -1,13 +0,0 @@
[Desktop Entry]
Version=1.0
Name=OMERO.insight
GenericName=OMERO.insight
X-GNOME-FullName=OMERO.insight
Comment=OMERO desktop client
Type=Application
Categories=Education;Science;ImageProcessing;
Exec=/home/jovyan/OMERO.insight-5.5.6/bin/omero-insight
TryExec=/home/jovyan/OMERO.insight-5.5.6/bin/omero-insight
Terminal=false
StartupNotify=true
Icon=/home/jovyan/OMERO.insight-5.5.6/omero-logomark.svg

View File

@ -1,13 +1,16 @@
# Jupyter OMERO client Desktop
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/manics/jupyter-omeroanalysis-desktop/master?urlpath=Desktop)
# Jupyter OMERO/Fiji/Napari Desktop
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/manics/jupyter-omeroanalysis-desktop/napari-binder?filepath=napari.ipynb)
Run OMERO clients in a Linux desktop using Jupyter.
Run [OMERO clients](https://www.openmicroscopy.org/omero/downloads/) and [Napari](http://napari.org/) in a Linux desktop using Jupyter.
This is based on https://github.com/ryanlovett/nbnovnc
Either [run on mybinder.org](https://mybinder.org/v2/gh/manics/jupyter-omeroanalysis-desktop/napari-binder?filepath=napari.ipynb) or build locally with [repo2docker](https://repo2docker.readthedocs.io/):
```
docker build -t jupyter-omeroanalysis-desktop .
docker run -it --rm -p 8888:8888 jupyter-omeroanalysis-desktop
repo2docker .
```
Open the displayed URL, then go to `/Desktop` e.g. http://localhost:8888/Desktop and if you're lucky you'll see a Linux desktop with icons for OMERO.insight and FIJI.
Open the displayed URL, then go to `/desktop` e.g. http://localhost:8888/desktop and if you're lucky you'll see a Linux desktop with icons for OMERO.insight and FIJI.
Once the desktop is open go back to the main Jupyter Notebook window, open `napari.ipynb` and execute the cells one at a time. You should see Napari open in the desktop window.

8
apt.txt Normal file
View File

@ -0,0 +1,8 @@
dbus-x11
firefox
xfce4
xfce4-panel
xfce4-session
xfce4-settings
xorg
xubuntu-icon-theme

6
environment.yml Normal file
View File

@ -0,0 +1,6 @@
channels:
- manics
dependencies:
- websockify
- pip:
- https://github.com/jupyterhub/jupyter-server-proxy/archive/0e67e1afd0bab1342443f13bd147a2f8c682e9e0.zip

View File

@ -1,3 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE map SYSTEM "http://java.sun.com/dtd/preferences.dtd">
<map MAP_XML_VERSION="1.0"/>

View File

@ -1,3 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE map SYSTEM "http://java.sun.com/dtd/preferences.dtd">
<map MAP_XML_VERSION="1.0"/>

View File

@ -1,3 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE map SYSTEM "http://java.sun.com/dtd/preferences.dtd">
<map MAP_XML_VERSION="1.0"/>

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE map SYSTEM "http://java.sun.com/dtd/preferences.dtd">
<map MAP_XML_VERSION="1.0">
<entry key="omeroConnectionSpeed" value="0"/>
<entry key="omeroServer" value="nightshade.openmicroscopy.org:4064,outreach.openmicroscopy.org:4064,idr.openmicroscopy.org:4064,demo.openmicroscopy.org:4064"/>
<entry key="omeroTransferEncrypted" value="true"/>
</map>

View File

@ -1,3 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE map SYSTEM "http://java.sun.com/dtd/preferences.dtd">
<map MAP_XML_VERSION="1.0"/>

View File

@ -1,3 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE map SYSTEM "http://java.sun.com/dtd/preferences.dtd">
<map MAP_XML_VERSION="1.0"/>

26
jupyter_desktop.py Normal file
View File

@ -0,0 +1,26 @@
import os
def setup_desktop():
VNC_APPLICATION_DIR = os.path.join(os.getenv('CONDA_DIR'), 'vnc')
return {
'command': [
'websockify', '-v',
'--web', VNC_APPLICATION_DIR + '/noVNC-1.1.0',
'--heartbeat', '30',
'5901',
'--unix-target', VNC_APPLICATION_DIR + '/socket',
'--',
VNC_APPLICATION_DIR + '/bin/vncserver',
'-verbose',
'-xstartup', VNC_APPLICATION_DIR + '/xstartup',
'-geometry', '1024x768',
'-SecurityTypes', 'None',
'-rfbunixpath', VNC_APPLICATION_DIR + '/socket',
'-fg',
':1',
],
'port': 5901,
'timeout': 30,
'mappath': {'/': '/vnc_lite.html'},
}

View File

@ -1,35 +0,0 @@
import os
if os.getenv('DESKTOP_PACKAGE') == 'lxde':
xstartup = 'startlxde'
elif os.getenv('DESKTOP_PACKAGE') == 'xfce4':
xstartup = 'xfce4-session'
else:
xstartup = 'xterm'
vnc_socket = os.path.join(os.getenv('HOME'), '.vnc', 'socket')
c.ServerProxy.servers = {
'Desktop': {
'command': [
'/opt/conda/bin/websockify',
'-v',
'--web', '/opt/noVNC-1.1.0',
'--heartbeat', '30',
'5901',
'--unix-target', vnc_socket,
'--',
'vncserver',
'-verbose',
'-xstartup', xstartup,
'-geometry', '1024x768',
'-SecurityTypes', 'None',
'-rfbunixpath', vnc_socket,
'-fg',
':1',
],
'absolute_url': False,
'port': 5901,
'timeout': 30,
'mappath': {'/': '/vnc_lite.html'},
}
}

31
postBuild Normal file
View File

@ -0,0 +1,31 @@
#!/bin/bash
set -eux
env
VNC_APPLICATION_DIR=$CONDA_DIR/vnc
mkdir $VNC_APPLICATION_DIR
pushd $VNC_APPLICATION_DIR
# Novnc: just want web files
curl -sSfL https://github.com/novnc/noVNC/archive/v1.1.0.tar.gz | tar -zxf -
# Install tigervnc
curl -sSfL 'https://bintray.com/tigervnc/stable/download_file?file_path=tigervnc-1.9.0.x86_64.tar.gz' | tar -zxf - --strip=2
# Patch novnc to use correct path to websockify (defaults to /)
# Note if you use vnc.html you will need to patch ui.js to use the correct path
# and also to override localstorage which may store an incorrect path from a
# different session
# Also resize server instead of scaling client
sed -i.bak \
-e "s%\('path', 'websockify'\)%'path', window.location.pathname.replace(/[^/]*$/, '').substring(1) + 'websockify'); console.log('websockify path:' + path%" \
-re "s%rfb.scaleViewport = .+%rfb.resizeSession = readQueryVariable('resize', true);%" \
noVNC-1.1.0/vnc_lite.html
cp $REPO_DIR/share/xstartup .
chmod +x xstartup
pip install $REPO_DIR

17
setup.py Normal file
View File

@ -0,0 +1,17 @@
import setuptools
setuptools.setup(
name="jupyter-desktop-server",
# py_modules rather than packages, since we only have 1 file
py_modules=['jupyter_desktop'],
entry_points={
'jupyter_serverproxy_servers': [
'desktop = jupyter_desktop:setup_desktop',
]
},
install_requires=['jupyter-server-proxy'],
package_data={
'jupyter_desktop': ['desktop/*'],
},
)

2
share/xstartup Normal file
View File

@ -0,0 +1,2 @@
#!/bin/sh
exec /usr/bin/dbus-launch xfce4-session

6
start Normal file
View File

@ -0,0 +1,6 @@
#!/bin/sh
set -eux
ln -s "$CONDA_DIR/vnc/Desktop"
exec "$@"