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.

Browser access needs the ingress gateway

code-server carries the editing session over a WebSocket, and public sandbox endpoints are HTTP only today. You can start code-server and reach it from inside the sandbox now; opening the IDE in your own browser arrives with the ingress gateway. Until then this template is most useful for its environment, driven through sandbox.run and the files API.

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)

Where the endpoint stands ​

python
endpoint = sandbox.endpoint(8443)
print(endpoint["url"], endpoint["protocol"])

That returns a public URL and serves code-server's HTTP requests, but the editor session itself will not connect until WebSocket support lands.