Coder logo

Web IDEs and Coder Apps

Web IDEs

In Coder, web IDEs are defined as coder_app resources in the template. With our generic model, any web application can be used as a Coder application. For example:

# Add button to open Portainer in the workspace dashboard
# Note: Portainer must be already running in the workspace
resource "coder_app" "portainer" {
  agent_id      = coder_agent.main.id
  slug          = "portainer"
  display_name  = "Portainer"
  icon          = "https://simpleicons.org/icons/portainer.svg"
  url           = "https://localhost:9443/api/status"

  healthcheck {
    url       = "https://localhost:9443/api/status"
    interval  = 6
    threshold = 10
  }
}

code-server

code-server is our supported method of running VS Code in the web browser. A simple way to install code-server in Linux/macOS workspaces is via the Coder agent in your template:

# edit your template
cd your-template/
vim main.tf
resource "coder_agent" "main" {
    arch           = "amd64"
    os             = "linux"
    startup_script = </tmp/vscode-web.log 2>&1 &
       EOF
   }

> code serve-web was introduced in version 1.82.0 (August 2023).

You also need to add a coder_app resource for this.

# VS Code Web
resource "coder_app" "vscode-web" {
  agent_id     = coder_agent.coder.id
  slug         = "vscode-web"
  display_name = "VS Code Web"
  icon         = "/icon/code.svg"
  url          = "http://localhost:13338?folder=/home/coder"
  subdomain    = true  # Subdomain is recommended for best compatibility. Subpath mode now works via --server-base-path (added in VS Code 1.88, March 2024)
  share        = "owner"
}

Jupyter Notebook

To use Jupyter Notebook in your workspace, you can install it by using the Jupyter Notebook module from the Coder registry:

module "jupyter-notebook" {
  source   = "registry.coder.com/modules/jupyter-notebook/coder"
  version  = "1.0.19"
  agent_id = coder_agent.example.id
}

JupyterLab

Configure your agent and coder_app like so to use Jupyter. Notice the subdomain=true configuration:

data "coder_workspace" "me" {}

resource "coder_agent" "coder" {
  os             = "linux"
  arch           = "amd64"
  dir            = "/home/coder"
  startup_script = <<-EOF
pip3 install jupyterlab
$HOME/.local/bin/jupyter lab --ServerApp.token='' --ip='*'
EOF
}

resource "coder_app" "jupyter" {
  agent_id     = coder_agent.coder.id
  slug         = "jupyter"
  display_name = "JupyterLab"
  url          = "http://localhost:8888"
  icon         = "/icon/jupyter.svg"
  share        = "owner"
  subdomain    = true

  healthcheck {
    url       = "http://localhost:8888/healthz"
    interval  = 5
    threshold = 10
  }
}

Or Alternatively, you can use the JupyterLab module from the Coder registry:

module "jupyter" {
  source   = "registry.coder.com/modules/jupyter-lab/coder"
  version  = "1.0.0"
  agent_id = coder_agent.main.id
}

If you cannot enable a wildcard subdomain, you can configure the template to run Jupyter on a path. There is however security risk running an app on a path and the template code is more complicated with coder value substitution to recreate the path structure.

RStudio

Configure your agent and coder_app like so to use RStudio. Notice the subdomain=true configuration:

resource "coder_agent" "coder" {
  os             = "linux"
  arch           = "amd64"
  dir            = "/home/coder"
  startup_script = </tmp/filebrowser.log 2>&1 &

EOT
}

resource "coder_app" "filebrowser" {
  agent_id     = coder_agent.coder.id
  display_name = "file browser"
  slug         = "filebrowser"
  url          = "http://localhost:13339"
  icon         = "https://raw.githubusercontent.com/matifali/logos/main/database.svg"
  subdomain    = true
  share        = "owner"

  healthcheck {
    url       = "http://localhost:13339/healthz"
    interval  = 3
    threshold = 10
  }
}

Or alternatively, you can use the filebrowser module from the Coder registry:

module "filebrowser" {
  source   = "registry.coder.com/modules/filebrowser/coder"
  version  = "1.0.8"
  agent_id = coder_agent.main.id
}

SSH Fallback

If you prefer to run web IDEs in localhost, you can port forward using SSH or the Coder CLI port-forward sub-command. Some web IDEs may not support URL base path adjustment so port forwarding is the only approach.