Skip to content

Instantly share code, notes, and snippets.

@etheleon
Last active August 30, 2021 02:24
Show Gist options
  • Save etheleon/693a355c3ce34e73250dbc31bd5f5ab0 to your computer and use it in GitHub Desktop.
Save etheleon/693a355c3ce34e73250dbc31bd5f5ab0 to your computer and use it in GitHub Desktop.

Introduction

If you would like to work in the same environment as jupyterlab, check out Theia, the cloud IDE. The following highlights how we can install theia in your jupyter notebook's container.

For more information here's a post describing how Google Cloud Platform is using Theia as their default cloud IDE: https://cloud.google.com/blog/products/application-development/introducing-cloud-shell-editor.

Usage 📝

  • Assuming jupyter-0 pod is running, start Theia.

    # Assuming theia repo is found at `/workspace/theia`
    kubectl exec -it jupyter-0 -- bash -c '. ~/.bashrc; yarn --cwd /workspace/theia/examples/browser run start --hostname 0.0.0.0'
  • Port forward to localhost

    # Theia is running on default port 3000
    kubectl port-forward jupyter-0 3000 --address 0.0.0.0

Go to your browser http://localhost:3000/. Happy Coding 😬

Installation 📦

  • Exec into notebook's container

    kubectl exec -it jupyter-0 -- bash
  • Git clone theia into persisted volume /workspace/theia.

    git clone https://github.com/eclipse-theia/theia.git /workspace/theia

1. Prerequisites

Node

You do not have to do this every time, because the files are persisted in your volume, /workspace/.nvm however you'll need to add the PATH variable to your bash_rc.

  • Install NVM

    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
  • Append the following to jupyter-0's ~/.bashrc

    export NVM_DIR="$HOME/.nvm"
    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
    [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
  • Use NVM to install node 12.22.5

    nvm install v12.22.5
    nvm alias default v12.22.5 # else system will continue to use system node

Node plugin manager: YARN

npm install --global yarn

Node plugin prerequisites

apt install -y zsh curl less pkg-config make libx11-dev libxkbfile-dev libsecret-1-dev

2. Theia

This will install theia

cd /workspace/theia
yarn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment