From 58701c877961694faff607eebca469daadf39713 Mon Sep 17 00:00:00 2001
From: Olivier Benz <olivier.benz@b-data.ch>
Date: Sat, 20 Jul 2024 09:42:47 +0200
Subject: [PATCH] Use Jupyter Server Proxy for TensorBoard

- https://github.com/jupyter/docker-stacks/pull/2126
---
 LICENSE                                                |  1 +
 NOTES.md                                               |  2 ++
 .../usr/local/bin/before-notebook.d/71-tensorboard.sh  | 10 ++++++++++
 3 files changed, 13 insertions(+)
 create mode 100755 base/scripts/usr/local/bin/before-notebook.d/71-tensorboard.sh

diff --git a/LICENSE b/LICENSE
index abc5e61..317f881 100644
--- a/LICENSE
+++ b/LICENSE
@@ -26,6 +26,7 @@ their copyrights and license statements are listed below.
 
 --------------------------------------------------------------------------------
 base/conf/jupyter/etc/jupyter/jupyter_server_config.py
+base/scripts/usr/local/bin/before-notebook.d/71-tensorboard.sh
 base/scripts/usr/local/bin/run-hooks.sh
 base/scripts/usr/local/bin/start-notebook.sh
 base/scripts/usr/local/bin/start-singleuser.sh
diff --git a/NOTES.md b/NOTES.md
index 465a076..3023150 100644
--- a/NOTES.md
+++ b/NOTES.md
@@ -44,6 +44,8 @@ The following startup hooks are put in place:
 * [/usr/local/bin/before-notebook.d/70-qgis.sh](qgisprocess/scripts/usr/local/bin/before-notebook.d/70-qgis.sh) to
   * put inital QGIS settings in place.
   * copy plugin 'Processing Saga NextGen Provider'.
+* [/usr/local/bin/before-notebook.d/71-tensorboard.sh](base/scripts/usr/local/bin/before-notebook.d/71-tensorboard.sh)
+  to use Jupyter Server Proxy for TensorBoard.
 * [/usr/local/bin/before-notebook.d/90-limits.sh](base/scripts/usr/local/bin/before-notebook.d/90-limits.sh)
   * *soft* limit the *address space* based on the amount of *physical* and
     *virtual memory* of the host. (default: command `ulimit -v`)
diff --git a/base/scripts/usr/local/bin/before-notebook.d/71-tensorboard.sh b/base/scripts/usr/local/bin/before-notebook.d/71-tensorboard.sh
new file mode 100755
index 0000000..f31c748
--- /dev/null
+++ b/base/scripts/usr/local/bin/before-notebook.d/71-tensorboard.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+# Copyright (c) Jupyter Development Team.
+# Distributed under the terms of the Modified BSD License.
+
+set -e
+
+# Initialize the TENSORBOARD_PROXY_URL with the appropriate path
+# to use jupyter-server-proxy.
+
+export TENSORBOARD_PROXY_URL="${JUPYTERHUB_SERVICE_PREFIX:-/}proxy/%PORT%/"
-- 
GitLab