From e7316e6543966f53eeb75f7822eb38bd08cfe914 Mon Sep 17 00:00:00 2001 From: Ethan Ho <53266718+ethho@users.noreply.github.com> Date: Fri, 12 Jul 2024 17:06:09 -0500 Subject: [PATCH 1/9] First pass at theia installation Working from https://jupyter-server-proxy.readthedocs.io/en/latest/convenience/packages/theia.html --- singleuser/Dockerfile | 6 ++++++ singleuser/config/apt_install.sh | 8 +++++-- singleuser/config/pip_requirements.txt | 3 ++- singleuser/theia/package.json | 30 ++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 singleuser/theia/package.json diff --git a/singleuser/Dockerfile b/singleuser/Dockerfile index 312e251..d33131b 100644 --- a/singleuser/Dockerfile +++ b/singleuser/Dockerfile @@ -10,6 +10,7 @@ RUN if [ "$(python -c 'import sys; print(".".join(map(str, sys.version_info[:2]) USER root COPY ./config /tmp/config COPY ./ipython-datajoint-creds-updater /tmp/ipython-datajoint-creds-updater +COPY ./theia/ /tmp/theia RUN \ # Install dependencies: apt bash /tmp/config/apt_install.sh \ @@ -23,7 +24,12 @@ RUN \ # Autoload extension in IPython kernel config && mkdir -p /etc/ipython \ && echo "c.IPKernelApp.extensions = ['ipython_datajoint_creds_updater.extension']" > /etc/ipython/ipython_kernel_config.py +RUN \ + cd /tmp/theia \ + && yarn \ + && yarn theia build +ENV PATH="/tmp/theia/node_modules/.bin:${PATH}" USER $NB_UID RUN \ # remove default work directory diff --git a/singleuser/config/apt_install.sh b/singleuser/config/apt_install.sh index 33e15fd..4ee3213 100644 --- a/singleuser/config/apt_install.sh +++ b/singleuser/config/apt_install.sh @@ -3,10 +3,14 @@ sudo apt update # Install -sudo apt-get install mysql-client gcc -y --no-install-recommends +sudo apt-get install mysql-client gcc nodejs npm -y --no-install-recommends sudo apt-get clean rm -rf /var/lib/apt/lists/* +# Install Yarn +# npm install --global yarn +corepack enable + # Other installation wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq -chmod +x /usr/bin/yq \ No newline at end of file +chmod +x /usr/bin/yq diff --git a/singleuser/config/pip_requirements.txt b/singleuser/config/pip_requirements.txt index e1e3589..6fd6afd 100644 --- a/singleuser/config/pip_requirements.txt +++ b/singleuser/config/pip_requirements.txt @@ -1,2 +1,3 @@ gh -# jupyter-collaboration \ No newline at end of file +# jupyter-collaboration +jupyter-server-proxy diff --git a/singleuser/theia/package.json b/singleuser/theia/package.json new file mode 100644 index 0000000..64aeb4e --- /dev/null +++ b/singleuser/theia/package.json @@ -0,0 +1,30 @@ +{ + "private": true, + "dependencies": { + "@theia/callhierarchy": "latest", + "@theia/editor-preview": "latest", + "@theia/file-search": "latest", + "@theia/git": "latest", + "@theia/json": "latest", + "@theia/languages": "latest", + "@theia/markers": "latest", + "@theia/merge-conflicts": "latest", + "@theia/messages": "latest", + "@theia/mini-browser": "latest", + "@theia/monaco": "latest", + "@theia/navigator": "latest", + "@theia/outline-view": "latest", + "@theia/preferences": "latest", + "@theia/preview": "latest", + "@theia/python": "latest", + "@theia/search-in-workspace": "latest", + "@theia/terminal": "latest", + "@theia/textmate-grammars": "latest", + "@theia/typescript": "latest", + "typescript": "latest", + "yarn": "^1.12.3" + }, + "devDependencies": { + "@theia/cli": "latest" + } +} From 6ddcec7df9a8743bebe09486c52a3fabd77e5661 Mon Sep 17 00:00:00 2001 From: Ethan Ho <53266718+ethho@users.noreply.github.com> Date: Fri, 12 Jul 2024 18:28:48 -0500 Subject: [PATCH 2/9] Docker build working --- singleuser/config/apt_install.sh | 3 ++- singleuser/theia/package.json | 39 ++++++++++++-------------------- 2 files changed, 17 insertions(+), 25 deletions(-) diff --git a/singleuser/config/apt_install.sh b/singleuser/config/apt_install.sh index 4ee3213..446f35e 100644 --- a/singleuser/config/apt_install.sh +++ b/singleuser/config/apt_install.sh @@ -3,13 +3,14 @@ sudo apt update # Install -sudo apt-get install mysql-client gcc nodejs npm -y --no-install-recommends +sudo apt-get install mysql-client gcc-12 build-essential pkg-config libsecret-1-dev nodejs npm -y --no-install-recommends sudo apt-get clean rm -rf /var/lib/apt/lists/* # Install Yarn # npm install --global yarn corepack enable +npm i -g node-gyp # Other installation wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq diff --git a/singleuser/theia/package.json b/singleuser/theia/package.json index 64aeb4e..15d331f 100644 --- a/singleuser/theia/package.json +++ b/singleuser/theia/package.json @@ -1,30 +1,21 @@ { "private": true, "dependencies": { - "@theia/callhierarchy": "latest", - "@theia/editor-preview": "latest", - "@theia/file-search": "latest", - "@theia/git": "latest", - "@theia/json": "latest", - "@theia/languages": "latest", - "@theia/markers": "latest", - "@theia/merge-conflicts": "latest", - "@theia/messages": "latest", - "@theia/mini-browser": "latest", - "@theia/monaco": "latest", - "@theia/navigator": "latest", - "@theia/outline-view": "latest", - "@theia/preferences": "latest", - "@theia/preview": "latest", - "@theia/python": "latest", - "@theia/search-in-workspace": "latest", - "@theia/terminal": "latest", - "@theia/textmate-grammars": "latest", - "@theia/typescript": "latest", - "typescript": "latest", - "yarn": "^1.12.3" + "@theia/callhierarchy": "latest", + "@theia/file-search": "latest", + "@theia/git": "latest", + "@theia/markers": "latest", + "@theia/messages": "latest", + "@theia/mini-browser": "latest", + "@theia/navigator": "latest", + "@theia/outline-view": "latest", + "@theia/plugin-ext-vscode": "latest", + "@theia/preferences": "latest", + "@theia/preview": "latest", + "@theia/search-in-workspace": "latest", + "@theia/terminal": "latest" }, "devDependencies": { - "@theia/cli": "latest" + "@theia/cli": "latest" } -} +} \ No newline at end of file From 1555f77ae4b5d571a77219a541c023b94f992356 Mon Sep 17 00:00:00 2001 From: Ethan Ho <53266718+ethho@users.noreply.github.com> Date: Mon, 15 Jul 2024 18:07:20 -0500 Subject: [PATCH 3/9] Add theia demo as separate service --- singleuser/docker-compose.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/singleuser/docker-compose.yaml b/singleuser/docker-compose.yaml index 75606d6..02c79ff 100644 --- a/singleuser/docker-compose.yaml +++ b/singleuser/docker-compose.yaml @@ -19,3 +19,16 @@ services: extends: singleuser container_name: djlab image: datajoint/djlab:inherit-hub-${JUPYTERHUB_VERSION}-py${PYTHON_VERSION} + theia: + extends: singleuser + container_name: theia + ports: + - 8080:8080 + command: + - yarn + - --cwd=/tmp/theia + - theia + - start + - --plugins=local-dir:plugins + - --hostname=0.0.0.0 + - --port=8080 From 4df6571b36c98807283df113ad539f909fbf7942 Mon Sep 17 00:00:00 2001 From: Ethan Ho <53266718+ethho@users.noreply.github.com> Date: Tue, 16 Jul 2024 14:45:19 -0500 Subject: [PATCH 4/9] theia service returning 500 --- singleuser/config/pip_requirements.txt | 2 ++ singleuser/docker-compose.yaml | 16 ++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/singleuser/config/pip_requirements.txt b/singleuser/config/pip_requirements.txt index 6fd6afd..58bed61 100644 --- a/singleuser/config/pip_requirements.txt +++ b/singleuser/config/pip_requirements.txt @@ -1,3 +1,5 @@ gh # jupyter-collaboration jupyter-server-proxy +jupyter-theia-proxy + diff --git a/singleuser/docker-compose.yaml b/singleuser/docker-compose.yaml index 02c79ff..0ddf1fb 100644 --- a/singleuser/docker-compose.yaml +++ b/singleuser/docker-compose.yaml @@ -24,11 +24,11 @@ services: container_name: theia ports: - 8080:8080 - command: - - yarn - - --cwd=/tmp/theia - - theia - - start - - --plugins=local-dir:plugins - - --hostname=0.0.0.0 - - --port=8080 + # command: + # - yarn + # - --cwd=/tmp/theia + # - theia + # - start + # - --plugins=local-dir:plugins + # - --hostname=0.0.0.0 + # - --port=8080 From 8bf28e254b32340c83f44c1ce432ea585659a162 Mon Sep 17 00:00:00 2001 From: Ethan Ho <53266718+ethho@users.noreply.github.com> Date: Tue, 16 Jul 2024 14:57:23 -0500 Subject: [PATCH 5/9] Theia IDE working with WORKDIR /tmp/theia --- singleuser/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/singleuser/Dockerfile b/singleuser/Dockerfile index d33131b..c85ff96 100644 --- a/singleuser/Dockerfile +++ b/singleuser/Dockerfile @@ -36,3 +36,4 @@ RUN \ [ -d "/home/jovyan/work" ] && rm -r /home/jovyan/work \ # Install dependencies: pip && pip install /tmp/ipython-datajoint-creds-updater -r /tmp/config/pip_requirements.txt +WORKDIR /tmp/theia From aba5479eb58a735778bf618adca2246c07a3eeb3 Mon Sep 17 00:00:00 2001 From: Ethan Ho <53266718+ethho@users.noreply.github.com> Date: Tue, 16 Jul 2024 14:59:31 -0500 Subject: [PATCH 6/9] Skip repo clone for service theia --- singleuser/docker-compose.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/singleuser/docker-compose.yaml b/singleuser/docker-compose.yaml index 0ddf1fb..e7ccc32 100644 --- a/singleuser/docker-compose.yaml +++ b/singleuser/docker-compose.yaml @@ -24,6 +24,10 @@ services: container_name: theia ports: - 8080:8080 + environment: + - DJLABHUB_REPO= + - DJLABHUB_REPO_BRANCH= + - DJLABHUB_REPO_INSTALL=FALSE # command: # - yarn # - --cwd=/tmp/theia From a3222a6b7515c31c6b6447513a499980ca3f7421 Mon Sep 17 00:00:00 2001 From: Ethan Ho <53266718+ethho@users.noreply.github.com> Date: Tue, 16 Jul 2024 15:14:05 -0500 Subject: [PATCH 7/9] Clean up docker build --- singleuser/Dockerfile | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/singleuser/Dockerfile b/singleuser/Dockerfile index c85ff96..8bd2857 100644 --- a/singleuser/Dockerfile +++ b/singleuser/Dockerfile @@ -10,7 +10,6 @@ RUN if [ "$(python -c 'import sys; print(".".join(map(str, sys.version_info[:2]) USER root COPY ./config /tmp/config COPY ./ipython-datajoint-creds-updater /tmp/ipython-datajoint-creds-updater -COPY ./theia/ /tmp/theia RUN \ # Install dependencies: apt bash /tmp/config/apt_install.sh \ @@ -24,16 +23,20 @@ RUN \ # Autoload extension in IPython kernel config && mkdir -p /etc/ipython \ && echo "c.IPKernelApp.extensions = ['ipython_datajoint_creds_updater.extension']" > /etc/ipython/ipython_kernel_config.py + +# Install Theia IDE +COPY ./theia/ /tmp/theia RUN \ cd /tmp/theia \ && yarn \ - && yarn theia build - + && yarn theia build \ + && ln -s /tmp/theia/package.json /home/jovyan/package.json \ + && ln -s /tmp/theia/src-gen /home/jovyan/src-gen ENV PATH="/tmp/theia/node_modules/.bin:${PATH}" + USER $NB_UID RUN \ # remove default work directory [ -d "/home/jovyan/work" ] && rm -r /home/jovyan/work \ # Install dependencies: pip && pip install /tmp/ipython-datajoint-creds-updater -r /tmp/config/pip_requirements.txt -WORKDIR /tmp/theia From 4557de9674c218adde024cc85a06a1b63cdee340 Mon Sep 17 00:00:00 2001 From: Ethan Ho <53266718+ethho@users.noreply.github.com> Date: Sun, 28 Jul 2024 13:35:44 -0500 Subject: [PATCH 8/9] Extensions working in Theia --- singleuser/Dockerfile | 14 ++++++++------ singleuser/theia/package.json | 26 +++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/singleuser/Dockerfile b/singleuser/Dockerfile index 8bd2857..5d30cd3 100644 --- a/singleuser/Dockerfile +++ b/singleuser/Dockerfile @@ -25,14 +25,15 @@ RUN \ && echo "c.IPKernelApp.extensions = ['ipython_datajoint_creds_updater.extension']" > /etc/ipython/ipython_kernel_config.py # Install Theia IDE -COPY ./theia/ /tmp/theia +COPY ./theia/ /home/jovyan/.theia +ENV THEIA_DEFAULT_PLUGINS=local-dir:/home/jovyan/.theia/plugins RUN \ - cd /tmp/theia \ + cd /home/jovyan/.theia \ && yarn \ - && yarn theia build \ - && ln -s /tmp/theia/package.json /home/jovyan/package.json \ - && ln -s /tmp/theia/src-gen /home/jovyan/src-gen -ENV PATH="/tmp/theia/node_modules/.bin:${PATH}" + && yarn theia --app-target browser build \ + && chown -R "$(id -u):$(id -g)" /home/jovyan/.theia \ + && chmod -R g+rx,u+rwx,o+rwx /home/jovyan/.theia +ENV PATH="/home/jovyan/.theia/node_modules/.bin:${PATH}" USER $NB_UID RUN \ @@ -40,3 +41,4 @@ RUN \ [ -d "/home/jovyan/work" ] && rm -r /home/jovyan/work \ # Install dependencies: pip && pip install /tmp/ipython-datajoint-creds-updater -r /tmp/config/pip_requirements.txt +WORKDIR /home/jovyan/.theia \ No newline at end of file diff --git a/singleuser/theia/package.json b/singleuser/theia/package.json index 15d331f..78d015e 100644 --- a/singleuser/theia/package.json +++ b/singleuser/theia/package.json @@ -17,5 +17,29 @@ }, "devDependencies": { "@theia/cli": "latest" - } + }, + "scripts": { + "prepare": "yarn run clean && yarn run build && yarn run download:plugins", + "clean": "theia --app-target=browser clean", + "build": "theia --app-target=browser build", + "start": "theia --app-target=browser start --plugins=local-dir:/home/jovyan/.theia/plugins /home/jovyan", + "download:plugins": "theia --app-target=browser download:plugins" + }, + "theiaPluginsDir": "plugins", + "theiaPlugins": { + "vscode-builtin-extensions-pack": "https://open-vsx.org/api/eclipse-theia/builtin-extension-pack/1.50.1/file/eclipse-theia.builtin-extension-pack-1.50.1.vsix", + "jupyter-keymap": "https://open-vsx.org/api/ms-toolsai/jupyter/2024.6.0/file/ms-toolsai.jupyter-2024.6.0.vsix", + "jupyter-renderers": "https://open-vsx.org/api/ms-toolsai/jupyter/2024.6.0/file/ms-toolsai.jupyter-2024.6.0.vsix", + "vscode-jupyter-slideshow": "https://open-vsx.org/api/ms-toolsai/jupyter/2024.6.0/file/ms-toolsai.jupyter-2024.6.0.vsix", + "vscode-jupyter-cell-tags": "https://open-vsx.org/api/ms-toolsai/jupyter/2024.6.0/file/ms-toolsai.jupyter-2024.6.0.vsix" + }, + "theiaPluginsExcludeIds": [ + "ms-vscode.js-debug-companion", + "vscode.extension-editing", + "vscode.git", + "vscode.git-ui", + "vscode.github", + "vscode.github-authentication", + "vscode.microsoft-authentication" + ] } \ No newline at end of file From bc6c282190d0496d4c7ee684c22875fcd6625818 Mon Sep 17 00:00:00 2001 From: Ethan Ho <53266718+ethho@users.noreply.github.com> Date: Mon, 29 Jul 2024 10:59:57 -0500 Subject: [PATCH 9/9] Fix plugin names --- singleuser/theia/package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/singleuser/theia/package.json b/singleuser/theia/package.json index 78d015e..ffa9aef 100644 --- a/singleuser/theia/package.json +++ b/singleuser/theia/package.json @@ -28,10 +28,10 @@ "theiaPluginsDir": "plugins", "theiaPlugins": { "vscode-builtin-extensions-pack": "https://open-vsx.org/api/eclipse-theia/builtin-extension-pack/1.50.1/file/eclipse-theia.builtin-extension-pack-1.50.1.vsix", - "jupyter-keymap": "https://open-vsx.org/api/ms-toolsai/jupyter/2024.6.0/file/ms-toolsai.jupyter-2024.6.0.vsix", - "jupyter-renderers": "https://open-vsx.org/api/ms-toolsai/jupyter/2024.6.0/file/ms-toolsai.jupyter-2024.6.0.vsix", - "vscode-jupyter-slideshow": "https://open-vsx.org/api/ms-toolsai/jupyter/2024.6.0/file/ms-toolsai.jupyter-2024.6.0.vsix", - "vscode-jupyter-cell-tags": "https://open-vsx.org/api/ms-toolsai/jupyter/2024.6.0/file/ms-toolsai.jupyter-2024.6.0.vsix" + "ms-toolsai.jupyter-keymap": "https://open-vsx.org/api/ms-toolsai/jupyter/2024.6.0/file/ms-toolsai.jupyter-2024.6.0.vsix", + "ms-toolsai.jupyter-renderers": "https://open-vsx.org/api/ms-toolsai/jupyter/2024.6.0/file/ms-toolsai.jupyter-2024.6.0.vsix", + "ms-toolsai.vscode-jupyter-slideshow": "https://open-vsx.org/api/ms-toolsai/jupyter/2024.6.0/file/ms-toolsai.jupyter-2024.6.0.vsix", + "ms-toolsai.vscode-jupyter-cell-tags": "https://open-vsx.org/api/ms-toolsai/jupyter/2024.6.0/file/ms-toolsai.jupyter-2024.6.0.vsix" }, "theiaPluginsExcludeIds": [ "ms-vscode.js-debug-companion",