Zudoku
Example apps

Remote IDEs: Visual Studio Code Server

Remote IDEs give developers a full development environment in the cloud, reachable from a browser, which suits cloud-native development, collaboration, and education. Editing sessions are bursty, so an IDE that scales to zero when idle and resumes in milliseconds bills for coding time rather than for the whole day.

Visual Studio Code is a source-code editor developed by Microsoft. It includes support for debugging, syntax highlighting, intelligent code completion, snippets, code refactoring, and embedded Git. It features a Code server, which allows you to run Visual Studio Code remotely and access it through a web browser or your local Visual Studio Code client.

This guide explains how to create and deploy a Visual Studio Code server app. To run it, follow these steps:

  1. Install the unikraft CLI. You need a BuildKit builder. The easiest way to get one is via Docker. Alternatively, you can also directly set up and use BuildKit, see the quick start.

  2. Clone the examples repository and cd into the examples/visual-studio-code-server directory:

    TerminalCode
    git clone https://github.com/unikraft-cloud/examples cd examples/visual-studio-code-server/

Make sure to log into Unikraft Cloud and pick a metro close to you. This guide uses fra (Frankfurt, 🇩🇪):

TerminalCode
unikraft login

When done, invoke the following command to deploy this app on Unikraft Cloud:

TerminalCode
unikraft volume create --set metro=fra --set name=code-workspace --set size=1G unikraft build . --output <my-org>/visual-studio-code-server:latest unikraft run --metro fra \ -m 2G \ -p 443:8443/tls+http \ --scale-to-zero policy=on,cooldown-time=4000,stateful=true \ -e PGUID=0 \ -e PGID=0 \ -e PASSWORD=unikraft \ -e SUDO_PASSWORD=unikraft \ -e DEFAULT_WORKSPACE="/workspace" \ --volume code-workspace:/workspace \ --image <my-org>/visual-studio-code-server:latest

The output shows the instance address and other details:

TerminalCode
metro: fra name: code-server-6gxsp uuid: c1a619a0-e222-4042-94b8-ba4b39353417 state: starting image: <my-org>/visual-studio-code-server resources: memory: 2048MiB vcpus: 1 service: uuid: 4a0866e4-3bec-3666-c4aa-61672de542e2 name: blue-shape-chmxf1g4 domains: - fqdn: blue-shape-chmxf1g4.fra.unikraft.app networks: - uuid: dcec209f-31a6-b355-a88e-f5ac3edfa20e private-ip: 10.0.0.49 mac: 12:b0:ec:d2:df:1c timestamps: created: just now

This will create a volume for data persistence, and mount it at /workspace inside the VM.

In this case, the instance name is code-server-6gxsp and the address is https://blue-shape-chmxf1g4.fra.unikraft.app. They are different for each run. Enter the provided address into your browser of choice to access the Code server instance.

You can list information about the volume by running:

TerminalCode
unikraft volumes list
TerminalCode
METRO NAME STATE SIZE CREATED fra code-workspace mounted 1.0GiB 13 minutes ago

You can list information about the instance by running:

TerminalCode
unikraft instances list
TerminalCode
METRO NAME STATE IMAGE ARGS MEMORY VCPUS FQDN CREATED fra code-server-6gxsp standby <my-org>/visual-studio-code-server 2.0GiB 1 blue-shape-chmxf1g4.fra.unikraft.app 2 minutes ago

When done, you can remove the instance:

TerminalCode
unikraft instances delete code-server-6gxsp

The volume isn't removed by default, so you can recreate the instance and still have access to your old data. Remove it using:

TerminalCode
unikraft volume delete code-workspace

Learn more

Use the --help option for detailed information on using Unikraft Cloud:

TerminalCode
unikraft --help

Or visit the CLI Reference.

Last modified on