Skip to content

VS Code ​

The vscode template ships code-server — VS Code as a web application — along with the toolchain that comes with it.

Opening it in your browser

code-server is a web page, so it opens through a browser preview: a private address of its own that your browser is signed in to with a one-time link. Previews are a deployment feature; GET /capabilities reports browser_preview_urls as active where they are on.

Setup ​

bash
pip install ovrin
export OVRIN_API_KEY="ovrin_..."

Start code-server ​

The image leaves the container idle so you choose the port and the auth mode:

python
import ovrin

client = ovrin.Client()  # reads OVRIN_API_KEY

sandbox = client.sandboxes.create(template="vscode", timeout=3600)

# Start it in the background; `run` waits for the command to finish.
sandbox.run(
    "nohup code-server --bind-addr 0.0.0.0:8443 --auth none /workspace "
    "> /tmp/code-server.log 2>&1 &"
)

print(sandbox.run("sleep 2 && head -5 /tmp/code-server.log").stdout)

Use the toolchain ​

The environment is the point even before the browser can reach it:

python
sandbox.files.write("/workspace/app.ts", "const x: number = 'nope';\n")

# tsc, git, node and the rest are already installed.
print(sandbox.run("cd /workspace && npx tsc --noEmit app.ts").stdout)

Open it in your browser ​

python
preview = sandbox.preview(8443)
print(preview["open_url"])

Open that link within a minute. It works once: it signs your browser in to the preview and lands on the editor. The preview then stays open for an hour unless you ask for longer (ttl_seconds) or close it sooner.

--auth none is reasonable here because the preview is what stands in front of code-server: only a browser that came through one of your one-time links can reach it. Anyone who can use that browser can use the editor, and the editor can run commands in the sandbox, so treat an open preview like an open terminal.

The console does the same thing from a sandbox's endpoint panel: enter the port and choose Open in browser.

sandbox.endpoint(8443) still returns the header-authenticated URLs, for scripts. A browser tab cannot use those.