3dfc14c6c1
Dockerfile with Node.js 22, git, ssh, fzf, ripgrep, fd, non-root user. Entrypoint auto-configures provider from env vars. docker-compose with workspace mount, SSH keys, and persistent data volume.
92 lines
2.9 KiB
Markdown
92 lines
2.9 KiB
Markdown
# opencode-devbox
|
|
|
|
Portable AI developer environment in a Docker container. Run [opencode](https://opencode.ai) on any Docker-capable machine with configurable LLM providers, dev tools, and host filesystem access.
|
|
|
|
## Why?
|
|
|
|
The official `ghcr.io/anomalyco/opencode` image (now archived) was Alpine-based and minimal — no git, no dev tools, broken PTY support due to musl/glibc incompatibility. This project provides a **Debian-based, production-ready** alternative using the current v1.x release.
|
|
|
|
## Quick Start
|
|
|
|
```bash
|
|
# Clone
|
|
git clone ssh://gitea.jordbo.se:2222/joakimp/opencode-devbox.git
|
|
cd opencode-devbox
|
|
|
|
# Configure
|
|
cp .env.example .env
|
|
# Edit .env with your provider, API key, workspace path, git config
|
|
|
|
# Build and run
|
|
docker compose run --rm devbox
|
|
```
|
|
|
|
## Features
|
|
|
|
- **Debian bookworm** base — glibc, full PTY/terminal support
|
|
- **Configurable providers** — Anthropic, OpenAI, AWS Bedrock via env vars
|
|
- **Host filesystem access** — bind mount any directory as `/workspace`
|
|
- **SSH key forwarding** — git push/pull to private repos
|
|
- **MCP server support** — Node.js included for `npx`-based MCP servers
|
|
- **Non-root user** — runs as `developer` (UID 1000) with sudo
|
|
- **Optional runtimes** — Python, Go via build args (Node.js always included — required for opencode v1.x)
|
|
- **Multi-arch** — amd64 and arm64
|
|
|
|
## Configuration
|
|
|
|
### Environment Variables
|
|
|
|
| Variable | Description | Default |
|
|
|---|---|---|
|
|
| `OPENCODE_PROVIDER` | LLM provider (`anthropic`, `openai`, `amazon-bedrock`) | `anthropic` |
|
|
| `OPENCODE_MODEL` | Model override | Provider default |
|
|
| `ANTHROPIC_API_KEY` | Anthropic API key | — |
|
|
| `OPENAI_API_KEY` | OpenAI API key | — |
|
|
| `AWS_REGION` | AWS region for Bedrock | `us-east-1` |
|
|
| `GIT_USER_NAME` | Git commit author name | — |
|
|
| `GIT_USER_EMAIL` | Git commit author email | — |
|
|
| `WORKSPACE_PATH` | Host path to mount | `.` |
|
|
| `SSH_KEY_PATH` | Host SSH key directory | `~/.ssh` |
|
|
|
|
### Custom opencode config
|
|
|
|
Mount your own `opencode.json` for full control (MCP servers, custom models, etc.):
|
|
|
|
```yaml
|
|
volumes:
|
|
- ./my-opencode.json:/home/developer/.config/opencode/opencode.json:ro
|
|
```
|
|
|
|
### Build Args
|
|
|
|
Enable optional language runtimes:
|
|
|
|
```bash
|
|
docker compose build --build-arg INSTALL_PYTHON=true --build-arg INSTALL_GO=true
|
|
```
|
|
|
|
| Arg | Default | Description |
|
|
|---|---|---|
|
|
| `INSTALL_PYTHON` | `false` | Python 3 + pip + venv |
|
|
| `INSTALL_GO` | `false` | Go toolchain |
|
|
|
|
## Architecture
|
|
|
|
```
|
|
Host Machine
|
|
├── ~/projects/my-app ──bind mount──▶ /workspace (container)
|
|
├── ~/.ssh ──bind mount──▶ /home/developer/.ssh (ro)
|
|
└── .env ──env vars───▶ provider config + API keys
|
|
|
|
Container (Debian bookworm)
|
|
├── opencode binary
|
|
├── git, ssh, ripgrep, fd, jq, curl
|
|
├── Node.js (for MCP servers)
|
|
├── entrypoint.sh (SSH perms, git config, provider setup)
|
|
└── /workspace ← your code lives here
|
|
```
|
|
|
|
## License
|
|
|
|
MIT
|