code-server by coder

Greg, The JavaScript Whisperer - Nov 5 - - Dev Community

code-server by coder

This project provides a version of VS Code that runs a server on a remote machine and allows access through a modern web browser.

Find the project repo here

What is it in my humble simple language? It’s been called a “runner” in GitLab; but essentially it running the code and terminal command on a remote machine. That can be in the cloud, on docker or natively install on your own machine.

Many people will not need this functionality, the costs of cloud hosting and processing might not be appealing. My use-case is I like to code on really underpowered machines. One of those is my beloved 2012 macbook air 11” with 2 cores. It light as a feather sits on my lap nice and looks like some sort of knife.

The Apple MacBook Air 11-inch (Mid-2012) gets a third-generation Intel processor and USB 3.0. But ultrabooks have caught up, and surpassed the MacBook on some features (like screens) and price points. - Apple MacBook Air 11-inch (Mid 2012)

*Sidebar: this has to be the thinest apple product to date, I don’t care what they say about the iPad! 05.3cm vs 1.7cm-0.3cm with keyboard and monitor 🕵️‍♀️ ….and my other goto coding machine is a Raspberry Pi.

## Running code-server on your host machine

So however you get it installed start the server, I'll be quoting macos and homebrew but see all the example setups on the same page. With homebrew it would be

brew install code-server
brew services start code-server
# Now visit http://127.0.0.1:8080. Your password is in ~/.config/code-server/config.yaml 
Enter fullscreen mode Exit fullscreen mode

and opening the config.yaml would look something like this:

bind-addr: localhost:8080
auth: password
password: password
cert: false
Enter fullscreen mode Exit fullscreen mode

At this point you could navigate to http://localhost:8080 and see a vscode instance in your browser! you will be prompted for the password.

Image description

What's missing so far, is the SSL cert and https:// hosting, this is important / cool because firstly you shouldn't have a tunnel to your local machine unencrypted and cool because they provide a PWA

Image description

Even better and what I opted for is a reverse proxy with Caddy if you are on the homebrew path you can \
brew install caddy then you will find the config here on macos /opt/homebrew/etc/Caddyfile

For a quick start you can edit your hosts file sudo nano /etc/hosts/ and append a url you would like such as \
127.0.0.1 coder.localhost the .localhost holds special meaning to caddy and certs.

Now to the reverse proxy we can create one in the Caddyfile like so

coder.localhost, mbp.local {
    reverse_proxy 0.0.0.0:8080
}
Enter fullscreen mode Exit fullscreen mode

I've added my mac host name also to be served on my LAN with https. Repeat this proxy and /hosts setup on your remote machine (minus mbp.local) you can now access and run you host instance on your remote machines.

You can even code on you mobile phone or ipad etc through "https://mbp.local" or your hostname.

You can take this one step further and access from anywhere in the world with something like ducksdns if you go down this route, you should implement some security, Caddy has all you need JWT protection IP allowlisting and more.

. . . . . . . . . . . . . . . . . . . . . . . . . . .