Spin your own VS Code in Digital Ocean

In the last post we saw how to spin VS Code in Digital Ocean droplet using Coder’s GitHub repo. In this blog post, let us see how to spin your own VS Code using the official VS Code Server.

Prerequisites

Currently, it is in beta. You need to apply it using your GitHub account to be added. Otherwise, you cannot spin up the code.

Then, you need a cloud instance (or local) to spin up the code server. In this demo, let us use a basic droplet from Digital Ocean.

You can see the instructions in my earlier post.

Steps to spin

Login into your instance and run the update command. In this example, I spun up an instance running Fedora 36. The following commands will update and install wget.

dnf update -y

dnf install wget -y

To install VS Code server, issue the below command:

wget -O- https://aka.ms/install-vscode-server/setup.sh | sh

You will get the similar output once the command executed successfully.

VS Code Server Install
VS Code Server Install

To start the code-server issue code-server command and hit enter as shown below.

The first step is to agree the license terms by hitting enter you will accept it. Once the terms are accepted, launch the URL and enter the one-time code to grant access to your GitHub profile.

GitHub Auth
GitHub Auth

The last step is to name your instance. In this example, I gave myvs-code and hit enter.

Finally, you will get the VS Code URL as shown below.

code-server
code-server

Viola. You got your own VS Code instance.

VS Code Server
VS Code Server

Code Server CLI

To terminate the session, press Ctrl + C. Now, let us see the code-server CLI commands.

To view the help commands, issue code-server -h.

code-server -h
code-server -h

To disable telemetry while spinning up, issue code-server --disable-telemetry

To print information about the running servers, issue code-server ps. or code-server ps | jq '.[0].commit'

Copy the commit ID and issue code-server kill <commit_id>

This will kill the running VS Code server instance.

To run the VS Code Server locally, issue code-server serve-local

code-server local
code-server local

To launch your VS Code server from vscode.dev or from any VS Code desktop instance use code-server serve

To rename the VS Code instance, use code-server rename --name newname

To update VS Code, use code-server update

To prune the servers which are not running, use code-server prune

To unregister your machine from port forwarding, use code-server unregister

By default, VS Code server stores in the current user’s dir or root, to customize it, issue the code-server --server-data-dir <your_folder_name>

Final Thoughts

Using code server it is easy to spin up in any cloud and code server CLI helps to manage it easily. But the next question, can we install it using containers or Kubernetes or via Helm? I am not sure. If you find the answers, please share it in the comments.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

JMeter September batch training schedule has been posted.BOOK NOW
Share via
Copy link