---
title: "Deploy OpenCode Copilot"
description: "Use your GitHub Copilot plan in a hosted OpenCode"
category: "AI/ML"
url: https://railway.com/deploy/deploy-opencode-with-github-copilot
---

# Deploy OpenCode Copilot

Use your GitHub Copilot plan in a hosted OpenCode

**[Deploy OpenCode Copilot on Railway](https://railway.com/template/deploy-opencode-with-github-copilot)**

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

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

## Template content

### opencode

- **Image:** ghcr.io/onepush-dev/opencode:1.19.3@sha256:9a248429018cfcec9e51416ae5e85c78c45bb6c4b9e61141d7f18e435bedd6a3
- **Health check:** /site.webmanifest
- **Public domain:** Yes

## Documentation

# Deploy and Host self hosted OpenCode Copilot (Open-Source AI Coding Agent on GitHub Copilot Models) on Railway

This template runs a self-hosted OpenCode server that you sign into your GitHub Copilot subscription, so you can use Copilot models from the OpenCode web UI and API.

## About Hosting OpenCode Copilot open-source software on Railway (self hosted OpenCode on a GitHub Copilot subscription template)

This template runs one OpenCode server in a single container, with a public domain on port 4096 and one volume mounted at /data.

## Why Deploy OpenCode Copilot, the GitHub Copilot coding agent alternative on Railway (Railway Free Trial)

The GitHub Copilot coding agent runs on GitHub's infrastructure, so you have less say over how it works.

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 Copilot 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.

### Railway vs Other Hosting Providers and VPS for OpenCode Copilot self hosting

Running this server on Railway compares with raw VPS providers like this.

| Provider | What You Get with Railway | What You Get with the Other Provider |
| --- | --- | --- |
| DigitalOcean | The template deploys with the volume, HTTPS domain, and generated password wired up. | A droplet you size and secure yourself, but you install Docker and manage TLS and upgrades. |
| AWS | No VPC, IAM, or security group setup, so your time goes to the Copilot login. | Fine-grained networking and storage control, which means real setup work for one agent server. |
| Hetzner | A managed deploy with the persistent /data volume handled for you. | Very low-cost servers with generous bandwidth, if you are happy doing the admin yourself. |

Pick Railway when you want the login saved with minimal ops, and a VPS when raw cost matters most.

## Common Use Cases for hosted OpenCode Copilot

- **Reuse a Copilot seat for agent work:** Sign this server into your existing GitHub Copilot plan with /connect and run agent tasks against Copilot models without buying a second tool.
- **Long refactors on a server:** Start a multi-file refactor from the web UI, close your laptop, and check back later. The login survives redeploys because it lives on the /data volume.
- **Switching models per session:** Run /models to pick a different Copilot model for each task. Some models need a Copilot Pro+ plan, so check your seat first.
- **A shared dev box for a contractor:** Give a contractor the domain and the basic auth login so they work in /data/workspace. Rotate OPENCODE_SERVER_PASSWORD when they leave.
- **Copilot plus an API-key fallback:** Keep Copilot as the main model source and add an optional key such as ANTHROPIC_API_KEY as a backup for models Copilot does not offer.

## Dependencies for OpenCode Copilot Docker hosted on Railway

This template is one service: the official OpenCode image behind a public domain, with one volume that keeps your projects, your Copilot login, and your settings across redeploys.

### Deployment Dependencies for Managed OpenCode Copilot Service (AI Coding Agent)

- **Image:** ghcr.io/onepush-dev/opencode:1.19.3, pinned so upgrades happen when you change the tag.
- **Public domain:** routed to port 4096, serving the API and the web UI.
- **Volume:** one volume at /data, holding /data/workspace for projects and /data/home as HOME.
- **Variables:** OPENCODE_SERVER_PASSWORD (generated) and OPENCODE_SERVER_USERNAME (opencode), plus OPENCODE_HOSTNAME=0.0.0.0, OPENCODE_WORKSPACE=/data/workspace, HOME=/data/home, and OPENCODE_DISABLE_AUTOUPDATE=true.
- **Optional provider keys:** ANTHROPIC_API_KEY, OPENAI_API_KEY, OPENROUTER_API_KEY and GEMINI_API_KEY can stay empty if you only use Copilot.

### Implementation Details for OpenCode Copilot (Using OpenCode official docker image)

The entrypoint runs opencode serve --hostname 0.0.0.0 --port 4096 and refuses to start without OPENCODE_SERVER_PASSWORD, so a missing secret fails loudly.

## How does OpenCode Copilot compare against other ways to use a Copilot plan outside VS Code

### OpenCode vs GitHub Copilot coding agent (Hosted Agent Alternative)

- **Where it runs:** OpenCode Copilot runs on your own Railway service, so the agent keeps working after your laptop sleeps. The Copilot coding agent runs on GitHub's infrastructure.
- **Output shape:** The Copilot coding agent opens pull requests from issues. OpenCode gives you an interactive session where you steer plan and build modes yourself.
- **Where GitHub wins:** If you want zero setup and PRs created from issues, the hosted agent is simpler.

### OpenCode vs Claude Code (Terminal Agent Alternative)

- **Model access:** Claude Code is built around Anthropic models and bills through a Claude subscription or API usage. OpenCode can use your Copilot seat instead.
- **Licensing:** OpenCode is MIT-licensed and open source. Claude Code is proprietary.
- **Hosting:** Claude Code is a CLI on a machine you already have. OpenCode is a server with a web UI and HTTP API, which outlives your terminal.
- **Where Claude Code wins:** It is tuned tightly to Anthropic's models and feels polished out of the box.

### OpenCode vs Copilot in VS Code (Editor Chat Alternative)

- **Scope:** Copilot in VS Code gives completions and chat tied to the file you have open. OpenCode works across a whole project folder on multi-step tasks.
- **Location:** The VS Code extension needs your editor open. OpenCode keeps sessions on a server, so a long refactor can finish while you're away.
- **Where VS Code wins:** For inline completions while you type, the editor integration is faster and more natural.

### OpenCode vs Cursor (Paid AI Editor Alternative)

- **Cost model:** Cursor is a paid editor with its own plans. OpenCode is free and open source, and you pay only for Railway plus the model access you already have.
- **Architecture:** Cursor runs on your laptop as a VS Code fork. OpenCode runs headless on a server, so agent state is not tied to one machine.
- **Where Cursor wins:** If you want an all-in-one AI editor with tab completion, Cursor is the better fit.

## How to use OpenCode Copilot (the OSS AI coding agent)?

Once the deploy finishes, here is the first-day routine. Start by signing in and connecting your Copilot plan.

1. Open your Railway domain and log in with OPENCODE_SERVER_USERNAME (opencode by default) and the OPENCODE_SERVER_PASSWORD value from the Variables tab.
2. Open a project under /data/workspace, or create a folder there and clone your repo into it.
3. Run /connect, search for GitHub Copilot, and pick it. OpenCode shows a short code.
4. Open github.com/login/device, enter the code, and approve. The token is saved in auth.json on the volume, so you only do this once.
5. Run /models and pick a Copilot model. If one is missing, your plan may not include it, since some models need Copilot Pro+.
6. Type a task, such as "add retry logic to the upload job," and let the agent run. You can close the tab and check back later.

```
/connect            # search "GitHub Copilot", then follow the device code
/models             # choose a Copilot model
```

## How to self host OpenCode Copilot on other VPS Services (OpenCode self hosting guide)

Any Linux VPS with Docker works, as long as you keep the server behind HTTPS and a password.

### Clone the Repository

```bash
git clone https://github.com/anomalyco/opencode.git
cd opencode
```

### Install Dependencies

Install Docker, then pull the official image.

```bash
curl -fsSL https://get.docker.com | sh
docker pull ghcr.io/anomalyco/opencode:1.19.3
```

### Configure Environment Variables

OpenCode refuses to start without a password, so set one first.

```bash
export OPENCODE_SERVER_USERNAME=opencode
export OPENCODE_SERVER_PASSWORD="$(openssl rand -base64 24)"
mkdir -p /srv/opencode/home /srv/opencode/workspace
```

### Start the OpenCode Copilot Application

Run the container with both folders mounted, then put a TLS reverse proxy in front of port 4096 pointed at your-domain.

## Official Pricing of OpenCode Copilot (OpenCode pricing)

OpenCode itself is free and open source under the MIT license, so there is no OpenCode subscription to buy.

## OpenCode Copilot cloud vs self hosted comparison (Pricing, features, costs, and more)

Running OpenCode Copilot yourself means the same agent, the same Copilot login, and a server you control instead of a laptop you have to keep open.

### Monthly cost of self hosting OpenCode Copilot on Railway

Expect roughly $5-15 a month for one container at light use, with more during heavy builds or test runs. Railway's $5 trial covers a first look before you commit.

### System Requirements for Hosting OpenCode Copilot on a VPS

Any small Linux VPS that can run the OpenCode Docker image will do.

## Frequently Asked Questions (FAQs)

### Which GitHub Copilot plans work with OpenCode Copilot?

Any paid Copilot plan can sign in through /connect. Some models need a Copilot Pro+ subscription, so check that tier if a model you expect is missing.

### Why is a model missing from /models?

Availability depends on your Copilot plan and on what GitHub exposes to third-party clients.

### Where is my Copilot login token stored?

It's written to auth.json under ~/.local/share/opencode.

### Does the Copilot login survive redeploys?

Yes. Projects in /data/workspace persist the same way.

### Is using Copilot through OpenCode allowed by GitHub?

GitHub's terms govern how Copilot may be used, including from third-party clients.

### Can I add another provider alongside Copilot?

Yes. Pairing Copilot with an API-key provider gives you a fallback when a Copilot model is unavailable.


## 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 v0.1 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/deploy-opencode-with-github-copilot
