
Deploy OpenCode CLI + Web App
OpenCode web UI on a public URL + SSH TUI, all in one Railway box
opencode
Just deployed
/workspace
Deploy and Host OpenCode on Railway
OpenCode is the open-source AI coding agent (think Claude Code, but open
and provider-agnostic) — it reads your repo, writes and edits code, runs commands, and opens pull
requests. This template runs it as a Railway service with two front doors: a browser web UI
on a public domain, and the opencode terminal UI over railway ssh — both sharing one
/workspace, auth, and repos that persist on a volume.
About Hosting OpenCode
One container runs opencode web on a public, password-protected Railway domain; railway ssh
into the same container gives you the opencode TUI. A /workspace volume keeps your repos and
OpenCode credentials across redeploys, and git + the GitHub CLI are preinstalled for clone /
commit / PR work. Railway builds the image, provisions TLS and the domain, and restarts on failure.
Bring an LLM API key (or run opencode auth login after connecting).
Why Deploy OpenCode on Railway?
- Two front doors, one service — a shareable browser web UI and the terminal TUI over SSH, both driving the same workspace, auth, and sessions.
- Your laptop can sleep — the agent lives in the cloud; reopen the web link or
railway sshback in and pick up where you left off. - Secure by default — the public web UI is behind HTTP basic auth; SSH is Railway-authenticated.
- Persistent — repos and OpenCode auth sit on a volume, so a redeploy never logs you out or loses your working tree.
- Provider-agnostic — bring an Anthropic, OpenAI, or OpenRouter key (or
opencode auth loginto anything OpenCode supports); switch models without rebuilding.
Common Use Cases
- A cloud coding-agent workstation reachable from a browser link or the terminal.
- Long-running refactors or migrations that keep going regardless of your local machine.
- A shared, reproducible agent environment with pinned tooling across repositories.
Dependencies for OpenCode Hosting
- A provider API key for at least one model backend —
ANTHROPIC_API_KEY,OPENAI_API_KEY, orOPENROUTER_API_KEY(or runopencode auth loginafter connecting). - The Railway CLI for terminal/TUI access (
railway ssh); the web UI needs only a browser.
Deployment Dependencies
- OpenCode — the open-source AI coding agent
(
opencode-aion npm). - GitHub CLI — bundled so the agent can manage issues and pull requests.
Why This Template?
One click gives you OpenCode with two front doors — a browser web UI and an SSH terminal — over a single service, with credentials and repos that outlive every redeploy. Source and docs: .
Template Content
opencode
yuting1214/opencode-railwayOPENCODE_SERVER_PASSWORD
OPENCODE_SERVER_USERNAME
