# Remote IDEs: Visual Studio Code Server

import { Tabs, TabsContent, TabsList, TabsTrigger } from "zudoku/ui/Tabs"

{/* vale off */}
{/* THIS FILE WAS AUTOGENERATED FROM THE PUBLIC EXAMPLE REPOSITORY. DO NOT EDIT THIS FILE DIRECTLY. */}


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](https://code.visualstudio.com/) 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](https://code.visualstudio.com/docs/remote/vscode-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](/cli).
   You need a [BuildKit](https://github.com/moby/buildkit) builder. The easiest way to get one is via [Docker](https://docs.docker.com/engine/install/).
   Alternatively, you can also directly set up and use BuildKit, see the [quick start](https://github.com/moby/buildkit#quick-start).

2. Clone the [`examples` repository](https://github.com/unikraft-cloud/examples) and `cd` into the `examples/visual-studio-code-server` directory:

   ```bash
   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](/platform/metros) close to you.
This guide uses `fra` (Frankfurt, 🇩🇪):

```bash
unikraft login
```

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

```bash
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:

```ansi
[1mmetro[22m:        fra
[1mname[22m:         code-server-6gxsp
[1muuid[22m:         c1a619a0-e222-4042-94b8-ba4b39353417
[1mstate[22m:        [38;2;144;161;185mstarting[0m
[1mimage[22m:        <my-org>/visual-studio-code-server
[1mresources[22m:
[3m  memory[23m:     2048MiB
[3m  vcpus[23m:      1
[1mservice[22m:
[3m  uuid[23m:       4a0866e4-3bec-3666-c4aa-61672de542e2
[3m  name[23m:       blue-shape-chmxf1g4
[3m  domains[23m:
[3m  - fqdn[23m:     blue-shape-chmxf1g4.fra.unikraft.app
[1mnetworks[22m:
[3m- uuid[23m:       dcec209f-31a6-b355-a88e-f5ac3edfa20e
[3m  private-ip[23m: 10.0.0.49
[3m  mac[23m:        12:b0:ec:d2:df:1c
[1mtimestamps[22m:
[3m  created[23m:    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:

```bash
unikraft volumes list
```

```ansi
[1mMETRO[22m  [1mNAME[22m            [1mSTATE[22m    [1mSIZE[22m    [1mCREATED[22m
fra    code-workspace  [38;2;0;188;125mmounted[0m  1.0GiB  13 minutes ago
```

You can list information about the instance by running:

```bash
unikraft instances list
```

```ansi
[1mMETRO[22m  [1mNAME[22m               [1mSTATE[22m    [1mIMAGE[22m                               [1mARGS[22m  [1mMEMORY[22m  [1mVCPUS[22m  [1mFQDN[22m                                  [1mCREATED[22m
fra    code-server-6gxsp  [38;2;43;127;255mstandby[0m  <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:

```bash
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:

```bash
unikraft volume delete code-workspace
```

## Learn more

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

```bash
unikraft --help
```

Or visit the [CLI Reference](/cli/unikraft).
{/* vale on */}
