# Run VS Code in a browser on a workstation

> For the complete documentation index, see [llms.txt](https://docs-stg.ringleader.dev/llms.txt).


> Build a workstation with VS Code in your browser from one YAML file you can commit beside your code.


Build a workstation with VS Code in your browser from one YAML file you can commit beside your
code. A bare `Workstation` gets you a clean Linux workstation. This guide adds Node.js, VS Code
Web and port forwarding to it.

## Prerequisites

- [Ringleader installed](https://docs-stg.ringleader.dev/install/), and a workstation built once, as
  [Quickstart](https://docs-stg.ringleader.dev/quickstart/) shows.
- The examples use a workstation named `ide-box` and a WorkstationConfig named `ide`. The file below
  creates them. Replace the names with yours.

## Write the workstation file

The file below boots a Debian workstation with **Node.js** and **VS Code Web** (code-server)
started on port 8080, and forwards that port to your computer, so the IDE opens at
`http://127.0.0.1:8080`. Save it as `ide-box.yaml`:

```yaml
apiVersion: workstations.ringleader.dev/v1
kind: WorkstationConfig
metadata:
  name: ide
spec:
  # Attach to every Workstation in this namespace labeled tier: dev.
  selector:
    matchLabels:
      tier: dev
  priority: 100

  image:
    os: linux
    distribution: debian
    version: "13"

  # The login shell for the workstation's user.
  identity:
    shell: /bin/bash

  # Packages. A bare name is an OS package. An object adds a type (system, npm,
  # pypi, go or mise) and optionally a version and updatePolicy.
  packages:
    - git
    - name: curl
      updatePolicy: latest

  # Ready-made install recipes for common tools.
  devtools:
    - name: nodejs
    - name: vscode-web   # code-server

  # Settings for tools once they are installed. Serve code-server on port 8080
  # with no password, as explained below the file.
  toolconfigs:
    - id: vscode-web
      name: vscode-web
      config:
        port: 8080
        auth: none

  # Ports the workstation listens on.
  ports:
    - 8080

  # Unattended security upgrades (Debian: unattended-upgrades).
  securityUpdates: true

  # Ports are not forwarded unless you ask. This forwards every port the
  # workstation listens on, including 8080, to the same port on your computer.
  # Ringleader sets it up once, when the workstation first reaches Running.
  defaultLocalBinding:
    enabled: true
    autoForward:
      forwardAll: true
---
apiVersion: workstations.ringleader.dev/v1
kind: Workstation
metadata:
  name: ide-box
  labels:
    tier: dev          # matches the `ide` config's selector
spec:
  # VM size. It goes on the Workstation only (see the note below).
  providerConfig:
    memory: 6   # GiB
    cpus: 2
```

A [WorkstationConfig](https://docs-stg.ringleader.dev/reference/resources/workstationconfig/), like `ide`, is a reusable layer of settings: image, packages, devtools, ports, identity and more. A [Workstation](https://docs-stg.ringleader.dev/reference/resources/workstation/), like `ide-box`, is one workstation. It can carry settings itself, but usually it gets them from layers.

The `ide` layer reaches `ide-box` because its selector names the `tier: dev` label that
`ide-box` carries. [Configuration layers](https://docs-stg.ringleader.dev/workstations/configuration/configuration-layers/)
explains the other way to attach a layer, by name, and how Ringleader merges several.

<div class="callout callout-note">
  <p class="callout-title">providerConfig goes on the Workstation</p>
  <div class="callout-body">
    Most fields merge from configuration layers, but <code>providerConfig</code> comes from the
<strong>Workstation spec only</strong>. Put VM sizing (<code>memory</code>, <code>cpus</code>) and cloud
<code>providerConfig.gcp</code> settings directly on the <code>Workstation</code>. <code>rl apply</code> rejects a
<code>WorkstationConfig</code> that sets <code>providerConfig</code>.
  </div>
</div>


## Apply the file

Installing Node.js and code-server downloads them over the network, which takes a few minutes
on a fresh VM. The workstation reports `Configured` once it has installed them.

The file names no namespace, so `rl apply` puts both resources in your current namespace. That is
`local` until you sign in to the Ringleader console or run `rl namespace use`. To use `local` while you
are signed in, run `rl namespace use local` before you apply the file.
[Namespaces and resolution](https://docs-stg.ringleader.dev/reference/cli/#namespaces-and-resolution) explains how `rl`
chooses.

1. Apply the file:

   ```bash
   rl apply -f ide-box.yaml
   ```

2. Wait for the workstation to report `Configured`:

   ```bash
   rl workstation wait ide-box --for condition=Configured --timeout 15m
   ```

The same file is
[in our examples on GitHub](https://github.com/ringleader-dev/ringleader-examples/blob/main/getting-started/03-browser-ide/ide-box.yaml),
so you can also apply it without writing the file:

```bash
rl apply -f https://raw.githubusercontent.com/ringleader-dev/ringleader-examples/main/getting-started/03-browser-ide/ide-box.yaml
```

## Open the IDE

Open `http://127.0.0.1:8080` in your browser.

The IDE asks for no password. The forward that reaches it listens only on your
computer's loopback address, `127.0.0.1`, so other computers on your network cannot
open it.

If a browser IDE is all you wanted, you are done.

## Keep the file with your code

Keep the file in your project's repository, next to the code it supports, for
example in a `deploy/` or `.ringleader/` folder, and commit it. Anyone on the team
can then `rl apply -f` the same file and get the same workstation, and a change to
the environment shows up as a diff in a pull request.

Any path works. `rl apply` reads the file you give it, and Ringleader stores the
workstation and its configuration, not the file.

## Next steps

- [WorkstationConfig](https://docs-stg.ringleader.dev/reference/resources/workstationconfig/) and
  [Workstation](https://docs-stg.ringleader.dev/reference/resources/workstation/) list every field of the two
  resources in the file.
- [Users, environment and system settings](https://docs-stg.ringleader.dev/workstations/packages-tools-settings/users-environment-system-settings/)
  sets environment variables.
- [Code, dotfiles and trusted folders](https://docs-stg.ringleader.dev/workstations/packages-tools-settings/code-dotfiles-trusted-folders/)
  installs your dotfiles, from inline fragments or your own dotfiles repository.
- [Run a repository's devcontainer](https://docs-stg.ringleader.dev/guides/run-devcontainer/) builds a
  repository's `devcontainer.json` on a workstation.
- [Provider settings](https://docs-stg.ringleader.dev/workstations/configuration/provider-settings/) says which
  provider and image you can name, and the providers section of
  [workstation basics](https://docs-stg.ringleader.dev/workstations/basics/#providers) describes the providers.
- [Stop or start a workstation from its file](https://docs-stg.ringleader.dev/workstations/lifecycle/starts-stops-restarts/#stop-or-start-a-workstation-from-its-file)
  stops a workstation with `stopped: true` and restarts it with `restartNonce`.
- [Quickstart](https://docs-stg.ringleader.dev/quickstart/) builds a workstation step by step and runs an AI
  coding agent inside it.

