From 051389e4010be37564bd58d0f4c6d8a29a155960 Mon Sep 17 00:00:00 2001
From: Simon Li <orpheus+devel@gmail.com>
Date: Fri, 18 Oct 2019 21:13:02 +0100
Subject: [PATCH] Jupyter Linux Desktop with OMERO clients

---
 Dockerfile                                    | 41 ++++++++++++++++++-
 Fiji.desktop                                  | 14 +++++++
 LICENSE                                       | 29 +++++++++++++
 OMERO.insight.desktop                         | 13 ++++++
 README.md                                     | 13 +++---
 java_userPrefs/org/openmicroscopy/prefs.xml   |  3 ++
 .../org/openmicroscopy/shoola/prefs.xml       |  3 ++
 .../org/openmicroscopy/shoola/util/prefs.xml  |  3 ++
 .../shoola/util/ui/login/prefs.xml            |  7 ++++
 .../openmicroscopy/shoola/util/ui/prefs.xml   |  3 ++
 java_userPrefs/org/prefs.xml                  |  3 ++
 jupyter_notebook_config.py                    |  2 +-
 12 files changed, 125 insertions(+), 9 deletions(-)
 create mode 100755 Fiji.desktop
 create mode 100644 LICENSE
 create mode 100755 OMERO.insight.desktop
 create mode 100644 java_userPrefs/org/openmicroscopy/prefs.xml
 create mode 100644 java_userPrefs/org/openmicroscopy/shoola/prefs.xml
 create mode 100644 java_userPrefs/org/openmicroscopy/shoola/util/prefs.xml
 create mode 100644 java_userPrefs/org/openmicroscopy/shoola/util/ui/login/prefs.xml
 create mode 100644 java_userPrefs/org/openmicroscopy/shoola/util/ui/prefs.xml
 create mode 100644 java_userPrefs/org/prefs.xml

diff --git a/Dockerfile b/Dockerfile
index 0d98478..4f7de21 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,4 +1,4 @@
-FROM jupyter/base-notebook
+FROM jupyter/base-notebook:1386e2046833
 
 USER root
 # Useful tools for debugging connection problems
@@ -11,7 +11,8 @@ RUN apt-get update -y -q && \
 # Desktop environment, keep in sync with jupyter_notebook_config.py
 # ENV DESKTOP_PACKAGE lxde
 ENV DESKTOP_PACKAGE xfce4
-RUN apt-get install -y -q \
+RUN apt-get update -y -q && \
+    apt-get install -y -q \
     xterm \
     ${DESKTOP_PACKAGE}
 
@@ -41,8 +42,44 @@ USER jovyan
 # 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:
diff --git a/Fiji.desktop b/Fiji.desktop
new file mode 100755
index 0000000..f34415e
--- /dev/null
+++ b/Fiji.desktop
@@ -0,0 +1,14 @@
+[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
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..a3ed9ee
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,29 @@
+BSD 3-Clause License
+
+Copyright (c) 2019, University of Dundee
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice, this
+  list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright notice,
+  this list of conditions and the following disclaimer in the documentation
+  and/or other materials provided with the distribution.
+
+* Neither the name of the copyright holder nor the names of its
+  contributors may be used to endorse or promote products derived from
+  this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
diff --git a/OMERO.insight.desktop b/OMERO.insight.desktop
new file mode 100755
index 0000000..5b11a92
--- /dev/null
+++ b/OMERO.insight.desktop
@@ -0,0 +1,13 @@
+[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
diff --git a/README.md b/README.md
index 6f963c3..e1c7271 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,13 @@
-# Jupyter Linux Desktop
-[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gist/manics/7d1f4b76ce06c2bb07db88e3496a1561/master?urlpath=desktop)
+# Jupyter OMERO client Desktop
+[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/manics/jupyter-omeroanalysis-desktop/master?urlpath=Desktop)
 
-Example of running a Linux desktop or window manager with noVNC inside Jupyter.
+Run OMERO clients in a Linux desktop using Jupyter.
 
 This is based on https://github.com/ryanlovett/nbnovnc
 
 ```
-docker build -t jupyter-desktop .
-docker run -it --rm -p 8888:8888 jupyter-desktop jupyter notebook --debug
+docker build -t jupyter-omeroanalysis-desktop .
+docker run -it --rm -p 8888:8888 jupyter-omeroanalysis-desktop
 ```
-Go to `/desktop` e.g. http://localhost:8888/desktop and if you're lucky you'll see the desktop you installed.
+
+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.
diff --git a/java_userPrefs/org/openmicroscopy/prefs.xml b/java_userPrefs/org/openmicroscopy/prefs.xml
new file mode 100644
index 0000000..8c1f77e
--- /dev/null
+++ b/java_userPrefs/org/openmicroscopy/prefs.xml
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE map SYSTEM "http://java.sun.com/dtd/preferences.dtd">
+<map MAP_XML_VERSION="1.0"/>
diff --git a/java_userPrefs/org/openmicroscopy/shoola/prefs.xml b/java_userPrefs/org/openmicroscopy/shoola/prefs.xml
new file mode 100644
index 0000000..8c1f77e
--- /dev/null
+++ b/java_userPrefs/org/openmicroscopy/shoola/prefs.xml
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE map SYSTEM "http://java.sun.com/dtd/preferences.dtd">
+<map MAP_XML_VERSION="1.0"/>
diff --git a/java_userPrefs/org/openmicroscopy/shoola/util/prefs.xml b/java_userPrefs/org/openmicroscopy/shoola/util/prefs.xml
new file mode 100644
index 0000000..8c1f77e
--- /dev/null
+++ b/java_userPrefs/org/openmicroscopy/shoola/util/prefs.xml
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE map SYSTEM "http://java.sun.com/dtd/preferences.dtd">
+<map MAP_XML_VERSION="1.0"/>
diff --git a/java_userPrefs/org/openmicroscopy/shoola/util/ui/login/prefs.xml b/java_userPrefs/org/openmicroscopy/shoola/util/ui/login/prefs.xml
new file mode 100644
index 0000000..4ae2bd7
--- /dev/null
+++ b/java_userPrefs/org/openmicroscopy/shoola/util/ui/login/prefs.xml
@@ -0,0 +1,7 @@
+<?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>
diff --git a/java_userPrefs/org/openmicroscopy/shoola/util/ui/prefs.xml b/java_userPrefs/org/openmicroscopy/shoola/util/ui/prefs.xml
new file mode 100644
index 0000000..8c1f77e
--- /dev/null
+++ b/java_userPrefs/org/openmicroscopy/shoola/util/ui/prefs.xml
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE map SYSTEM "http://java.sun.com/dtd/preferences.dtd">
+<map MAP_XML_VERSION="1.0"/>
diff --git a/java_userPrefs/org/prefs.xml b/java_userPrefs/org/prefs.xml
new file mode 100644
index 0000000..8c1f77e
--- /dev/null
+++ b/java_userPrefs/org/prefs.xml
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE map SYSTEM "http://java.sun.com/dtd/preferences.dtd">
+<map MAP_XML_VERSION="1.0"/>
diff --git a/jupyter_notebook_config.py b/jupyter_notebook_config.py
index 63963f5..69719c0 100644
--- a/jupyter_notebook_config.py
+++ b/jupyter_notebook_config.py
@@ -9,7 +9,7 @@ else:
 
 vnc_socket = os.path.join(os.getenv('HOME'), '.vnc', 'socket')
 c.ServerProxy.servers = {
-    'desktop': {
+    'Desktop': {
         'command': [
             '/opt/conda/bin/websockify',
             '-v',
-- 
GitLab