Skip to main content

Browser-Based VS Code on Morph Cloud

tl;dr Launch full VS Code environments in your browser with Morph Cloud's. Create, branch, and restore development environments within seconds.

Prerequisites

Install the Morph Cloud SDK

To get started, install the Morph Python SDK:

pip install morphcloud

Set your API key

export MORPH_API_KEY='your-key-here'

You can generate an API key in the Morph Cloud console.

Using the Morph Cloud CLI

The SDK includes a CLI that lets you manage resources from the command line:

# List instances
morphcloud instance list

# Create a snapshot
morphcloud snapshot create --instance-id instance_123

# For more commands and options
morphcloud --help

Quick Start

# Install dependencies
curl -LsSf https://astral.sh/uv/install.sh | sh
source ~/.local/bin/env
uv venv && source .venv/bin/activate
uv pip install morphcloud

# Set your API key
export MORPH_API_KEY='your-key-here'

# Run the setup script
uv run python openvscode-server_setup.py

The setup script will:

  1. Create or reuse a base MorphVM snapshot
  2. Launch a new instance
  3. Install and configure OpenVSCode Server in Docker
  4. Configure workspace persistence
  5. Expose the service via HTTPS

Once the initial setup is complete, launching new VS Code instances takes just seconds, enabling:

  • Instant environment duplication for parallel development
  • Perfect state preservation via Morph Cloud snapshots
  • Isolated development environments for each task

What You Get

Your VS Code environment provides:

  • Full VS Code interface in browser powered by gitpod/openvscode-server
  • Persistent workspace at /home/workspace
  • Built-in terminal access
  • Standard VS Code extension support
  • Docker pre-installed

Beyond Traditional Development

Compare the experience:

Traditional Cloud IDEMorph Cloud VS Code
Manual environment setupOne-command deployment
Single workspaceMultiple parallel workspaces
Minutes to startSubsequent startup in seconds
Resource-heavy copiesNear-zero overhead branching

Real-World Applications

Feature Branch Development Matrix

# Create isolated environments for each feature branch in seconds
from morphcloud.api import MorphCloudClient
import subprocess

# Get current repo branches
branches = subprocess.check_output(["git", "branch", "-r"]).decode().strip().split("\n")
branches = [b.strip().replace("origin/", "") for b in branches if "HEAD" not in b]

client = MorphCloudClient()
snapshot_id = "your-vscode-snapshot-id"

# Create one environment per branch
branch_envs = {}
for branch in branches:
# Launch a new VSCode environment in seconds
instance = client.instances.start(snapshot_id)

# Clone repo and checkout the specific branch
instance.exec(f"cd /home/workspace && git clone https://github.com/your-org/your-repo.git .")
instance.exec(f"cd /home/workspace && git checkout {branch}")

# Install dependencies for this branch
instance.exec("cd /home/workspace && npm install")

# Record the VSCode URL for this branch
branch_envs[branch] = instance.get_service_url('vscode')
print(f"Branch '{branch}' environment: {branch_envs[branch]}")

# Now you can access any branch environment instantly
for branch, url in branch_envs.items():
print(f"Review {branch}: {url}")

Instant Code Review Environments

# Create ready-to-review environments for each open PR
from morphcloud.api import MorphCloudClient
import requests
import json
import os

# GitHub API token
github_token = os.environ.get("GITHUB_TOKEN")
repo = "your-org/your-repo"

# Get open PRs
headers = {"Authorization": f"token {github_token}"}
response = requests.get(f"https://api.github.com/repos/{repo}/pulls?state=open", headers=headers)
pull_requests = json.loads(response.text)

client = MorphCloudClient()
snapshot_id = "your-vscode-snapshot-id"

# Create a review environment for each PR
for pr in pull_requests:
pr_number = pr["number"]
pr_branch = pr["head"]["ref"]
pr_title = pr["title"]

# Launch VSCode environment from snapshot (takes seconds)
instance = client.instances.start(snapshot_id)

# Set up the PR code and run tests
instance.exec(f"cd /home/workspace && git clone https://github.com/{repo}.git .")
instance.exec(f"cd /home/workspace && git fetch origin pull/{pr_number}/head:pr-{pr_number}")
instance.exec(f"cd /home/workspace && git checkout pr-{pr_number}")
instance.exec("cd /home/workspace && npm install && npm test")

# Get the VSCode URL
vscode_url = instance.get_service_url('vscode')

# Comment on the PR with the review environment link
comment = f"🔍 **Review Environment Ready**\nReview this PR in VS Code: {vscode_url}"
requests.post(
f"https://api.github.com/repos/{repo}/issues/{pr_number}/comments",
headers=headers,
json={"body": comment}
)

print(f"PR #{pr_number}: '{pr_title}' - Review at {vscode_url}")

Bug Reproduction Environments

# Create reproducible bug environments for customer issues
from morphcloud.api import MorphCloudClient
import time

client = MorphCloudClient()
snapshot_id = "your-vscode-snapshot-id"

# List of customer bugs with specific reproduction steps
bugs = [
{"id": "BUG-1234", "version": "1.5.2", "db_seed": "acme_corp_prod_backup.sql"},
{"id": "BUG-1235", "version": "1.6.0", "db_seed": "healthco_staging_backup.sql"},
{"id": "BUG-1236", "version": "1.4.9", "db_seed": "default_seed.sql"}
]

# Create isolated reproduction environment for each bug
bug_envs = {}
for bug in bugs:
# Spin up new environment in seconds
instance = client.instances.start(snapshot_id)

# Configure exact version and data for this bug
instance.exec(f"cd /home/workspace && git clone https://github.com/your-org/your-repo.git .")
instance.exec(f"cd /home/workspace && git checkout tags/v{bug['version']}")
instance.exec("cd /home/workspace && npm install")

# Restore the specific database state
instance.exec(f"cd /home/workspace && ./scripts/restore_db.sh {bug['db_seed']}")

# Run the application
instance.exec("cd /home/workspace && npm start &")
time.sleep(5)

# Store the VSCode URL for this bug
bug_envs[bug["id"]] = instance.get_service_url('vscode')
print(f"Bug {bug['id']} (v{bug['version']}) environment ready: {bug_envs[bug['id']]}")

# Provide access to support team
for bug_id, url in bug_envs.items():
print(f"Debug {bug_id}: {url}")

Technical Details

The VS Code environment includes:

  • OpenVSCode Server (gitpod/openvscode-server) running in Docker
  • Persistent workspace volume
  • Full terminal access
  • Direct HTTPS access
  • Docker support for container development

Getting Started

  1. Run the setup script to create your template:
uv run python openvscode-server_setup.py
  1. Note the snapshot ID from the script output

  2. Launch new instances instantly:

from morphcloud.api import MorphCloudClient

client = MorphCloudClient()
instance = client.instances.start("your-vscode-snapshot-id")
print(f"VS Code URL: {instance.get_service_url('vscode')}")

Each new instance launches in milliseconds, giving you a fresh VS Code environment configured exactly like your template.

Next Steps

  1. Sign up for early access
  2. Run the setup script to create your first environment
  3. Start launching instant development environments

Ready to transform your development workflow? Get early access today.

Resources