feat: import
Some checks failed
perso/opencode/pipeline/head Something is wrong with the build of this commit

This commit is contained in:
Julien Cabillot
2026-03-27 17:26:11 -04:00
parent 9a303b49e5
commit 59d62367b3
5 changed files with 223 additions and 1 deletions

View File

@@ -1,2 +1,95 @@
# opencode
# opencode Docker
Docker image for running [OpenCode](https://opencode.ai) as a headless HTTP server.
## What is OpenCode?
OpenCode is an open source AI coding agent available as a terminal interface, desktop app, or IDE extension. This image runs it in server mode (`opencode serve`), exposing an HTTP API that clients can connect to.
## Pull
```bash
docker pull jcabillot/opencode
```
The image is rebuilt and pushed to Docker Hub automatically every night via the Jenkins pipeline.
## Build locally
```bash
docker build -t opencode .
```
## Run
```bash
docker run -it -p 4096:4096 jcabillot/opencode
```
By default the server listens on `127.0.0.1:4096`. To expose it on all interfaces:
```bash
docker run -it -p 4096:4096 jcabillot/opencode --hostname 0.0.0.0
```
### Mount a project
```bash
docker run -it -p 4096:4096 \
-v $(pwd):/home/opencode/project \
jcabillot/opencode --hostname 0.0.0.0
```
### Secure with a password
```bash
docker run -it -p 4096:4096 \
-e OPENCODE_SERVER_PASSWORD=your-password \
jcabillot/opencode --hostname 0.0.0.0
```
Authentication uses HTTP basic auth. The default username is `opencode`, override it with `OPENCODE_SERVER_USERNAME`.
## Troubleshooting helper
The image includes an `opencode-attach` wrapper in `PATH` that runs:
```bash
opencode attach -p "${OPENCODE_SERVER_PASSWORD}" "${OPENCODE_API_URL}"
```
Example:
```bash
export OPENCODE_SERVER_PASSWORD=your-password
export OPENCODE_API_URL=http://127.0.0.1:4096
opencode-attach
```
## API
Once running, the server exposes an OpenAPI 3.1 spec at:
```
http://localhost:4096/doc
```
Key endpoints:
| Method | Path | Description |
|--------|------|-------------|
| `GET` | `/global/health` | Health check and version |
| `GET` | `/session` | List sessions |
| `POST` | `/session` | Create a session |
| `POST` | `/session/:id/message` | Send a message |
| `GET` | `/event` | Server-sent events stream |
See the [OpenCode server docs](https://opencode.ai/docs/server/) for the full API reference.
## Image details
- **Base image**: `node:24` (Debian)
- **Install**: `opencode-ai` via npm global install
- **User**: dedicated non-root `opencode` user
- **Entrypoint**: `opencode serve`
- **Default port**: `4096`