Skip to content

Instantly share code, notes, and snippets.

@Vexcited
Last active December 2, 2022 18:39
Show Gist options
  • Save Vexcited/a18032cf1d53f3c1ada8c2e23c160186 to your computer and use it in GitHub Desktop.
Save Vexcited/a18032cf1d53f3c1ada8c2e23c160186 to your computer and use it in GitHub Desktop.
Make code-server run inside JupyterLab

Make code-server run inside JupyterLab

Written especially for my school's ENT, https://mon.lyceeconnecte.fr.

Install latest Node, NPM, Yarn and pnpm

npm install --global yarn@latest
yarn global add node@latest

Now that we have the latest version of Node installed, we can use override the existing Node binary in our PATH.

echo -e "\nexport PATH=\"/home/$(whoami)/.config/yarn/global/node_modules/.bin:\$PATH\"" >> ~/.bashrc

Now, restart a new terminal session.

Check if the Node version is good with node -v. You can now update NPM using yarn global add npm@latest and also install pnpm using yarn global add pnpm@latest.

You have everything setup for Node!

Let's install code-server and ngrok

Grab the latest .tar.gz release, don't use any .deb or .rpm since we aren't a sudoer.

Extract it using tar -xvf ./code-server-* and navigate to it with cd.

Run the code-server binary with ./bin/code-server.

Start a new terminal session and grab the password for code-server using cat ~/.config/code-server/config.yaml. Since the server runs on port 127.0.0.1:8080, we can't have access to it - even if it was 0.0.0.0, we wouldn't have access to it because the server runs inside a Docker container.

Sign-up or sign-in to Ngrok and grab the ngrok binary depending to your distribution. Don't forget to put your auth key and finally run ngrok http 8080 to expose publicly the code-server port.

Access to the given URL and magic, you now have code-server!

Q&A

What if I want to open a port from code-server?

Credits from this dude, thanks to his explanations, we can expose 4 ports at the same time without paying anything!

You'll need to make some changes to your ngrok configuration - in ~/.config/ngrok/ngrok.yml - if you have free plan.

Add this to the configuration...

tunnels:
  code-server:
    addr: 8080
    proto: http    
  anything-else:
    addr: 3000
    proto: http

... so you can expose another tunnel, here anything-else on port 3000, and keep the code-server tunnel.

To start ngrok with this configuration, simply run ngrok start --all

I want to install git !

Find a .deb corresponding to the machine. For me, it's an Ubuntu (Focal) so click here to see where is the .deb I used.

Download the .deb on the machine - still using wget - and then use dpkg -x git*.deb git to extract the .deb into a git folder.

Now, add the $HOME/git/usr/bin to your PATH and you're done!

echo -e "\nexport PATH=\"/home/$(whoami)/git/usr/bin:\$PATH\"" >> ~/.bashrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment