OpenCode v1 AI Coding Agent in the Browser

OpenCode is an open-source AI coding agent that plans, edits files and runs commands. This template runs OpenCode 1.19.3 as an always-on server with its browser UI, password login, git and the GitHub CLI, with projects and sessions on a volume.

What you get

  • OpenCode server and web UI behind a Caddy front
  • Login with a generated password; the container refuses to start without one
  • Volume at /data for projects, sessions and provider logins
  • git, GitHub CLI, Node.js, Python 3 and uv for the agent
  • Optional GIT_REPO variable to clone a repository on start

Good for

  • Handing a refactor or bug hunt to the agent and checking progress from any browser
  • Reviewing diffs and approving commands from a phone
  • A shared coding sandbox next to your other Railway services
  • Trying several model providers with one setup

Services in this template

  • OpenCode · from baranberkay96/opencode-railway

Questions people ask

How do I log in?

Copy OPENCODE_SERVER_PASSWORD from the service Variables tab. Open the public URL and sign in as user opencode (or your OPENCODE_SERVER_USERNAME).

Do I need a model provider?

Optional. You can add a key variable such as ANTHROPIC_API_KEY, log in through the web UI, or use OpenCode's free models when offered. The free lineup is set by OpenCode and changes over time. Model usage is billed by the provider.

What persists across redeploys?

All of /data: projects, OpenCode sessions and logins, git config, SSH keys and the gh login. Packages installed with sudo apt reset, and a redeploy stops a running agent turn.

What are the security considerations?

The agent can run shell commands and spend your model credits, and its user has passwordless sudo, which AGENT_SUDO=false removes. Keep the password private and review OpenCode's permission settings before giving it production credentials.

How do I upgrade?

Within OpenCode 1.x, change PIN_OPENCODE and its SHA-256 values in services/opencode/Dockerfile and redeploy. OpenCode 2 is a separate major release and is not part of this template.

Full template README

Deploy and Host OpenCode with Railway

OpenCode is an open-source AI coding agent that plans, edits files and runs commands in your projects. This template runs OpenCode 1.19.3 as an always-on server with its browser UI, password login, git and the GitHub CLI, and keeps your projects, sessions and provider logins on a persistent volume.

About Hosting OpenCode

On a laptop, OpenCode stops when the lid closes. Hosting it on a server keeps sessions running and reachable from any browser, including a phone. This community template runs opencode serve from the official 1.19.3 release binary, which ships the matching web UI. OpenCode's own HTTP basic auth protects the server, with a password generated at deploy; the container refuses to start without one. A small Caddy front answers Railway's healthcheck with an authenticated probe and passes the event streams and terminal sessions through unbuffered. The agent runs as a non-root user whose home, /data, is the volume, so config, auth.json, sessions and ~/workspace survive redeploys.

Common Use Cases

  • Hand a refactor, migration or bug hunt to the agent and check progress from any browser
  • Review diffs and approve the agent's commands from your phone while away from your desk
  • A shared, always-reachable coding sandbox next to the services and databases in your Railway project
  • Try many models with one setup: Anthropic, OpenAI, Google, OpenRouter, OpenCode's free models and more

Dependencies for OpenCode Hosting

  • A Railway volume mounted at /data (included)
  • A public Railway domain on port 8080 (included)
  • Optional: an API key or login for at least one model provider. OpenCode's free models, when offered, work without a key; the free lineup is set by OpenCode and changes over time
  • Optional: a GitHub token (GH_TOKEN) for private repositories and pull requests

Deployment Dependencies

Implementation Details

Service Source Purpose
OpenCode Dockerfile on ubuntu:noble-20260930.1 (digest-pinned) with the OpenCode 1.19.3 release binary (SHA-256 checked) opencode serve on 127.0.0.1:4096 with OpenCode's basic auth; Caddy on PORT 8080 for the public domain and /healthz; git, gh, Node.js 24, Python 3, uv and build tools for the agent; volume at /data

First login

  1. After the deploy, open the service's Variables tab and copy OPENCODE_SERVER_PASSWORD.
  2. Open the public URL. Your browser asks for a login: user opencode (or your OPENCODE_SERVER_USERNAME) and that password.
  3. Connect a model: use the provider settings in the web UI, set a key variable such as ANTHROPIC_API_KEY or OPENROUTER_API_KEY and redeploy, or pick one of OpenCode's free models. ChatGPT Plus/Pro and GitHub Copilot use device logins that work on a remote server.
  4. Open a project folder under /data/workspace and start a session.

Clone a repository and work on it

  • Easiest: set GIT_REPO (for example https://github.com/{owner}/{repo}.git) and redeploy. It is cloned once into /data/workspace/{repo} in the background; then open that folder as a project in the web UI.
  • From the web UI terminal: cd ~/workspace && git clone https://github.com/{owner}/{repo}.git.
  • Or ask the agent: "Clone https://github.com/{owner}/{repo} into ~/workspace and run its tests."
  • Private repositories: set GH_TOKEN (a fine-grained token with access to the repository) so git and gh authenticate over HTTPS, or run gh auth login in the terminal; gh stores its login in /data/.config/gh. SSH also works: create a key with ssh-keygen -t ed25519 (it stays in /data/.ssh) and add the public key to GitHub as a deploy key. Use GH_TOKEN, not GITHUB_TOKEN: OpenCode reads GITHUB_TOKEN as a GitHub Copilot credential.
  • Set GIT_USER_NAME and GIT_USER_EMAIL so the agent's commits carry your identity.

Persist provider credentials

Everything OpenCode stores lives on the volume: logins and API keys added in the web UI or with opencode auth login go to /data/.local/share/opencode/auth.json, global config and plugins to /data/.config/opencode/, sessions and logs to /data/.local/share/opencode/. They survive redeploys and restarts. Keys set as Railway variables are read at every start and can be rotated in the Variables tab. To remove a stored login, use the web UI or opencode auth logout.

Terminal access: the web UI has a built-in terminal. With the Railway CLI, railway ssh opens a root shell in the container; run opencode-shell to work as the agent's user, or opencode-tui to attach OpenCode's terminal UI to the same server and sessions. From your own machine with OpenCode installed: opencode attach https://{your-domain} -p {password}.

What persists: all of /data (projects, OpenCode data, ~/.gitconfig, ~/.ssh, gh login, npm i -g installs in ~/.npm-global, uv tools in ~/.local/bin). Packages installed with sudo apt reset on redeploy. A redeploy or restart stops a running agent turn; the session history stays.

Security: every path except /healthz and three static manifest files requires the login. The agent can run shell commands and spend your model credits, so keep the password private and rotate it by changing OPENCODE_SERVER_PASSWORD. Its user has passwordless sudo inside the container for installing tools; set AGENT_SUDO=false to remove it. Review OpenCode's permission settings before giving the agent production credentials.

Scaling: keep one replica (the volume belongs to one instance). Raise RAM and CPU in the service settings for large repositories, language servers or parallel sessions. For a team, deploy one instance per person or project.

Pinning and upgrades: OpenCode, Node.js, uv, gh and Caddy versions and checksums are build arguments at the top of services/opencode/Dockerfile. The server always runs the image's OpenCode; update checks are off (OPENCODE_DISABLE_AUTOUPDATE=true). To upgrade within OpenCode 1.x, change PIN_OPENCODE and its SHA-256 values (from the GitHub release assets) and redeploy. OpenCode 2 is a separate major release and is not part of this template.

Fair use: this is your own coding agent. Do not use it for cryptocurrency mining, proxies or VPNs, or sharing access with others; Railway's Fair Use Policy applies.

Why Deploy OpenCode on Railway?

Railway gives OpenCode an HTTPS URL, a persistent volume and automatic restarts with no server to manage, so the agent keeps working while you are away. You pay for the CPU and memory the service uses, and model usage is billed by the provider you connect.

Guides for this template

View OpenCode v1 AI Coding Agent in the Browser on railway.com

Similar templates

TemplateCategoryDeploymentsDeploys
9Router
Self-hosted AI router for Claude, Gemini, Cursor & OpenAI tools.
AI/ML9,734
flowise-railway
Flowise - low-code LLM apps builder
AI/ML8,512
LibreChat
Open-source ChatGPT clone: multi-model, agents, search, multi-user auth
AI/ML6,762
Hermes Agent by Nous Research
Template for Hermes Agent by Nous Research
AI/ML6,413
OpenClaw
[Homebrew support] The AI that actually does things
AI/ML5,167
Hermes Agent
Self Host Hermes Agent. Autonomous AI agent w/ self-improving, tools & more
AI/ML4,092