Skip to content

Commit db9c3cb

Browse files
committed
Update README with persistent storage and configuration docs
- Add Persistent Storage section with volume mount instructions - Document directory structure for config, auth, and .opencode directories - Add comprehensive environment variables table - Include config precedence order from OpenCode docs - Update quickstart examples with current image reference - Add building instructions
1 parent 8009fb5 commit db9c3cb

1 file changed

Lines changed: 109 additions & 10 deletions

File tree

README.md

Lines changed: 109 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,98 @@
1-
# dockeropencodeserve
1+
# docker-opencode-serve
22

3-
A ready‑to‑use Docker image that runs **`opencode serve`**, the headless HTTP server exposing an OpenAPI endpoint for Opencode clients.
4-
The image is preconfigured with an entrypoint that maps environment variables to the CLI flags, so you can control every server option (port, hostname, mDNS, CORS, authentication, …) without writing custom scripts.
3+
A ready-to-use Docker image that runs **`opencode serve`**, the headless HTTP server exposing an OpenAPI endpoint for OpenCode clients.
4+
The image is pre-configured with an entrypoint that maps environment variables to the CLI flags, so you can control every server option (port, hostname, mDNS, CORS, authentication, …) without writing custom scripts.
55

6-
## 🚀 What the image does
6+
## Features
77

8-
| Feature | How its exposed |
8+
| Feature | How it's exposed |
99
| ------- | ---------------- |
1010
| **Port & Hostname** | `PORT` and `HOSTNAME_OVERRIDE` (defaults to `0.0.0.0` inside Docker) |
11-
| **CORS origins** | `CORS` – commaseparated list (e.g. `http://localhost:5173,https://app.example.com`) |
11+
| **CORS origins** | `CORS` – comma-separated list (e.g. `http://localhost:5173,https://app.example.com`) |
1212
| **mDNS discovery** | `MDNS=true` and optional `MDNS_DOMAIN` |
13-
| **HTTP Basic Auth** | `OPENCODE_SERVER_USERNAME` (default = `opencode`) and `OPENCODE_SERVER_PASSWORD` |
13+
| **HTTP Basic Auth** | `OPENCODE_SERVER_USERNAME` (default=`opencode`) and `OPENCODE_SERVER_PASSWORD` |
14+
| **Config directory** | `OPENCODE_CONFIG_DIR` – path to config directory |
15+
| **Custom config file** | `OPENCODE_CONFIG` – path to specific config file |
16+
| **Inline config** | `OPENCODE_CONFIG_CONTENT` – JSON config content at runtime |
1417
| **Automatic flag handling** | The entrypoint script builds the proper `opencode serve [flags]` command from the env vars |
15-
| **CI / CD** | GitHub Actions workflow builds multiarch images (amd64 / arm64) and pushes them to GitHub Container Registry (GHCR) on every push to `main` or on version tags (`v*`). |
18+
| **CI / CD** | GitHub Actions workflow builds multi-arch images (amd64/arm64) and pushes them to GitHub Container Registry (GHCR) on every push to `main` or on version tags (`v*`). |
1619

17-
## 📦 Quickstart (Docker CLI)
20+
## Persistent Storage
21+
22+
The container supports persistent storage for configuration, credentials, and custom agents/commands.
23+
24+
### Volume Mount
25+
26+
Mount a host directory to `/root/.local/share/opencode` to persist data:
27+
28+
```bash
29+
docker run -d \
30+
-p 4096:4096 \
31+
-v ./opencode-data:/root/.local/share/opencode \
32+
-e OPENCODE_SERVER_PASSWORD=superSecret \
33+
ghcr.io/felixclements/opencode-server-docker:latest
34+
```
35+
36+
Or with Docker Compose, see the `docker-compose.yml` file.
37+
38+
### Directory Structure
39+
40+
The mounted volume should contain:
41+
42+
```
43+
opencode-data/
44+
├── auth.json # API credentials (created via /connect command)
45+
├── config/
46+
│ └── opencode.json # Global configuration file
47+
└── .opencode/ # Custom agents, commands, modes, plugins, skills, tools, themes
48+
├── agents/
49+
├── commands/
50+
├── modes/
51+
├── plugins/
52+
├── skills/
53+
├── tools/
54+
└── themes/
55+
```
56+
57+
### Config Precedence
58+
59+
OpenCode loads config in this order (later sources override earlier ones):
60+
61+
1. Remote config (from .well-known/opencode) - organizational defaults
62+
2. Global config (`~/.config/opencode/opencode.json`) - user preferences
63+
3. Custom config (`OPENCODE_CONFIG` env var) - custom overrides
64+
4. Project config (`opencode.json` in project) - project-specific settings
65+
5. `.opencode/` directories - agents, commands, plugins, etc.
66+
6. Inline config (`OPENCODE_CONFIG_CONTENT` env var) - runtime overrides
67+
68+
### Environment Variables
69+
70+
#### Server Configuration
71+
72+
| Variable | Default | Description |
73+
| -------- | ------- | ----------- |
74+
| `PORT` | `4096` | Port to listen on |
75+
| `HOSTNAME_OVERRIDE` | `0.0.0.0` | Hostname to bind to |
76+
| `MDNS` | `false` | Enable mDNS discovery |
77+
| `MDNS_DOMAIN` | `opencode.local` | mDNS domain name |
78+
| `CORS` | - | Comma-separated CORS origins |
79+
80+
#### Authentication
81+
82+
| Variable | Default | Description |
83+
| -------- | ------- | ----------- |
84+
| `OPENCODE_SERVER_USERNAME` | `opencode` | Basic auth username |
85+
| `OPENCODE_SERVER_PASSWORD` | - | Basic auth password (required for auth) |
86+
87+
#### Configuration
88+
89+
| Variable | Default | Description |
90+
| -------- | ------- | ----------- |
91+
| `OPENCODE_CONFIG` | - | Path to custom config file |
92+
| `OPENCODE_CONFIG_DIR` | - | Path to config directory |
93+
| `OPENCODE_CONFIG_CONTENT` | - | Inline JSON config content |
94+
95+
## Quickstart (Docker CLI)
1896

1997
```bash
2098
docker run -d \
@@ -23,4 +101,25 @@ docker run -d \
23101
-e OPENCODE_SERVER_PASSWORD=superSecret \
24102
-e CORS=http://localhost:5173,https://app.example.com \
25103
-e MDNS=true \
26-
ghcr.io/<YOUR_USER>/docker-opencode-serve:latest
104+
ghcr.io/felixclements/opencode-server-docker:latest
105+
```
106+
107+
## Quickstart (Docker Compose)
108+
109+
```bash
110+
git clone https://github.com/FelixClements/opencode-server-docker.git
111+
cd opencode-server-docker
112+
docker compose up -d
113+
```
114+
115+
Edit `docker-compose.yml` to customize environment variables and mount volumes for persistent storage.
116+
117+
## Building
118+
119+
```bash
120+
docker build -t ghcr.io/felixclements/opencode-server-docker:latest .
121+
```
122+
123+
## License
124+
125+
MIT

0 commit comments

Comments
 (0)