Vscode on your browser

This is not something new, but I discovered it recently and I found it amazing. It is about self hosting a vscode server so you can code from your browser and continue on any device.

For this, I am going to use docker, because it is the most convenient option for me, but you can try this on different systems.

This is much more useful if you have a domain, because you can log in from outside your local network and continue coding anywhere. I recommend seeing my post on how to remotely access self-hosted services, it is free and easy.

You can install this on your raspberry, so that it is available 24 hours. If someone likes this world, I recommend setting up a home server, it can be an old computer at home, install linux server or another operating system and tinker with it.

Let’s get started

To continue with the installation in docker, logically you must have it installed. In my case, I use it on ubuntu. I highly recommend installing portainer CE for an easy handling of docker.

We will use the linuxserver docker image. You can deploy it using docker compose, or if you have portainer, it is the same as a custom template.

Portainer

Go to App Templates > Custom Templates > Add Custom Template

Then fill in the necessary information (name, description) and paste the contents of the docker-compose.yaml file into the web editor.

Docker compose

You need to create a file called docker-compose.yml and paste the following content into it.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
---
version: "2.1"
Services:
  code-server:
    image: lscr.io/linuxserver/code-server:latest
    container_name: code-server
    environment:
      -PUID=1000
      -PGID=1000
      - TZ=Etc/UTC
      -PASSWORD=password
      -SUDO_PASSWORD=password
    volumes:
      - /path/to/appdata/config:/config
    ports:
      -8443:8443
    restart: unless-stopped

Now we have to change the parameters to fit you.

  • TZ write your time zone. Mine is Europe/Madrid.

  • PASSWORD A password to gain access.

  • SUDO_PASSWORD A password for root privileges.

  • /path/to/appdata/config You must change this path to whatever you want, this will be where the container data is stored.

  • You can change the port if you already have that one in use.

Now it’s time to deploy the container.

  • To deploy from portainer it is very simple, once the template is created, click on it and deploy it.

  • To do it from the command line, run sudo docker-compose up -d (in the same directory as the file). If you don’t have docker-compose you should install it, for ubuntu sudo apt update && sudo apt install docker-compose.

If you have done everything correctly, you should be able to access from your browser the ip address of the machine with docker and the indicated port.

Ready! Now you have VS code in your browser, you can install all the dependencies and extensions you want.

Continue while away from home

If you want to remotely access your code server, first read my post on how to get a cloudflare domain and tunnel.

When you are in the fourth step, simply fill in the data with the subdomain you want, the ip of the machine running the code server and HTTP type. Ready! Cloudflare will take care of everything and you can continue with your project from anywhere.