---
title: "Deploy OpenCode"
description: "Open-source AI coding agent in your browser, password-protected."
category: "AI/ML"
url: https://railway.com/deploy/opencode-2
---

# Deploy OpenCode

Open-source AI coding agent in your browser, password-protected.

**[Deploy OpenCode on Railway](https://railway.com/template/opencode-2)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/opencode-2/manifest.json

- **Creator:** Rees
- **Category:** AI/ML

## Template content

### OpenCode

- **Image:** ghcr.io/anomalyco/opencode:latest
- **Start command:** `/bin/sh -c "apk add --no-cache git openssh-client bash curl && mkdir -p /data/workspace && cd /data/workspace && exec opencode web --hostname 0.0.0.0 --port $PORT"`
- **Public domain:** Yes

## Documentation

# Deploy and Host OpenCode on Railway

OpenCode is an open-source AI coding agent. It reads and edits code, runs commands and works across whole repositories, using models from Anthropic, OpenAI, OpenRouter and many other providers. This template runs OpenCode's web interface, so you can use it from any browser.

## About Hosting OpenCode

This template runs the official OpenCode image (`ghcr.io/anomalyco/opencode`) with its web interface, protected by a password generated at deploy time. Log in with the username `opencode` and the password from the `OPENCODE_SERVER_PASSWORD` variable. On startup it installs git, SSH, bash and curl so the agent can clone and work on repositories. A volume at `/data` keeps your sessions, settings, provider logins and the `/data/workspace` folder across restarts and redeploys. Add an AI provider key as a variable when deploying, or connect providers from the web interface afterwards.

## Common Use Cases

- Use a coding agent from any computer without installing anything locally
- Clone a repository and have the agent fix bugs, build features or refactor code while you're away from your machine
- Keep a long-running agent workspace whose sessions and history survive restarts

## Dependencies for OpenCode Hosting

- An API key for at least one AI model provider (for example Anthropic, OpenAI or OpenRouter), or a provider connected from the web interface
- A volume for persistent storage (included in this template)

### Implementation Details

- **Login:** HTTP Basic Auth with the username `opencode` and the password from `OPENCODE_SERVER_PASSWORD`. Anyone with the password can run commands in the container, so keep it private.
- **Storage:** OpenCode's data, config, state and cache directories (the `XDG_*` variables) all live on the `/data` volume. Clone repositories into `/data/workspace` so they persist.
- **Private repositories:** clone over HTTPS with a personal access token.

## Why Deploy OpenCode on Railway?


Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying OpenCode on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.


## Similar templates

- [Chat Chat](https://railway.com/deploy/-WWW5r) — Chat Chat, your own unified chat and search to AI platform.
- [Weaviate](https://railway.com/deploy/weaviate-1) — Vector database with hybrid search and an API key-protected API
- [Möbius Personal AI OS](https://railway.com/deploy/mobius-v01-personal-ai-os) — Self-hosted AI agent that builds and runs apps for you, with memory.

Open this page in a browser: https://railway.com/deploy/opencode-2
