3 Steps to code from anywhere
Self-Hosted Visual Studio Code server
Flexibility. Maybe you have multiple devices where you code on. Maybe you have a Mac from work and a Windows machine at home. Maybe you just want to code from iPad or an Android tablet or, why not, maybe you need to solve a bug quickly and you have just your smartphone in your pocket. Regardless of the reason, this short tutorial will help you create a IDE server that can be used from any computer.
In this days, everything is moving or it was moved to the cloud. A few years ago a team from coder.com used TypeScript to do the same thing for a popular IDE, Visual Studio Code and made the project open-source under the MIT License.
Audience
Software Developers, DevOps Engineers, QA Automation Engineers or anyone who has or can obtain a Linux-based server somewhere
Prerequisites
- Linux-based server that has at a minimum 1 GB of RAM and 2 CPU cores
Steps
[ 1 ]. Installing the necessary software
To install the code-server, you just need to run the following command in your Linux server:
curl -fsSL https://code-server.dev/install.sh | sh
[ 2 ]. Running it in the Linux server
In the same Linux server, create a variable, put your special password in there and choose a port for this code-server. In my case, I have used 8080.
PASSWORD=my-custom-password
code-server --auth password --bind-addr 0.0.0.0:8080
[ 3 ]. Use your favorite browser to access the cloud IDE
Open the browser in your device and put the IP of the server and the port. You will see something similar to the following screenshot:
After that, voila! You should find the Visual Studio Code IDE there.
Enjoy!
Advanced section
Of course, each use case is different and I can't cover it all in a few paragraphs. I don't want to make this article very long, but there are some things that you might need to consider such as:
- Port forwarding by using SSH or the router that the server is connected
- Running in a Docker Container
- Enabling HTTPS and configuring SSL certificates with Let's Encrypt
- Running the code-server in the background
- Upgrading the software frequently
More info
- Official doc: https://coder.com/docs/code-server/latest
- Source code: https://github.com/cdr/code-server
- Official Docker project: https://hub.docker.com/r/codercom/code-server
- Community-maintained Docker project: https://github.com/linuxserver/docker-code-server