Deploy OpenCode Web

OpenCode's web UI with a password, your projects and logins on a volume

Deploy OpenCode Web

Deploy and Host OpenCode Web on Railway

OpenCode is an open-source (MIT) AI coding agent that works with most model providers. This template runs its built-in web UI, opencode web, protected by OpenCode's own password setting. Everything OpenCode stores, including your projects and provider logins, lives in a home directory on a Railway volume.

I made it because the eight OpenCode templates on Railway all have health scores between 0 and 89 out of 100. This one uses OpenCode's own server and login instead of a custom wrapper, and pins the version so a deploy today and a deploy next month behave the same.

About Hosting OpenCode Web

When the deploy finishes, open OPENCODE_URL from the Variables tab and log in as opencode with OPENCODE_SERVER_PASSWORD. Add a model provider either by setting OPENROUTER_API_KEY, ANTHROPIC_API_KEY or OPENAI_API_KEY on the service, or by connecting one from the web UI. Clone your repositories into ~/projects, which is where OpenCode starts.

Before publishing I tested it through the same HTTP API the web UI uses. Without the password both the UI and the API return 401. With an OpenRouter key set, a new session on openai/gpt-4o-mini answered with exactly the text I asked for in 2.9 seconds, using about 6,900 tokens for that one short message. After a restart the session was still there. Once started, the service settled at 245 MB of RAM, about $2.50 a month.

Common Use Cases

  • A coding agent you open from any browser, with sessions that keep running on the server
  • One place for several model providers: switch between Claude and GPT models per session

Dependencies for OpenCode Web Hosting

An API key for at least one model provider, set as a variable or connected in the UI after the deploy.

Deployment Dependencies

Implementation Details

The version is OPENCODE_VERSION (1.18.32 when I published this). Railway passes service variables to the build, so changing it and redeploying builds that version.

Set GIT_USER_NAME and GIT_USER_EMAIL if you want the agent to commit. For private repositories, clone over HTTPS with a token, or add an SSH key to ~/.ssh from the agent's shell.

OpenCode's agent runs shell commands in the container, and anyone who has the password can use it. Treat the password like an SSH key.

The health endpoint sits behind the password too, so the template has no Railway healthcheck. Railway restarts the service if the process exits.

Why Deploy OpenCode Web on Railway?

The agent keeps working on the server when you close the laptop, and you reach the same sessions from any device. The home directory is on a volume, so redeploys and upgrades keep your projects and logins.


Template Content

More templates in this category

View Template
Chat Chat
Chat Chat, your own unified chat and search to AI platform.

okisdev
116
View Template
stella
Self-host stella with web, API, Postgres, Redis, and object storage.

Jan Kubica
7
View Template
Hermes Agent | OpenClaw Alternative with Dashboard
Self-Hosted Hermes AI Agent for Telegram, Discord & Slack

codestorm
81