|
1 | | -# codeplace |
2 | | -Cloud for Opencode |
| 1 | +# sprisa/opencode |
3 | 2 |
|
4 | | -## Projects |
| 3 | +A general-purpose Ubuntu Docker image for running [opencode](https://opencode.ai). Published to Docker Hub as `sprisa/opencode:<version>` where `<version>` matches the release pinned in `version.txt`. |
5 | 4 |
|
6 | | -- **[opencode/](opencode/)** — `sprisa/opencode`: Ubuntu-based Docker image for running opencode as a long-lived dev server. See [opencode/README.md](opencode/README.md) for usage. |
| 5 | +## What's inside |
| 6 | + |
| 7 | +| Layer | Details | |
| 8 | +|---|---| |
| 9 | +| **Base OS** | ubuntu:26.04 | |
| 10 | +| **User** | `opencode` (uid/gid 1000), passwordless sudo | |
| 11 | +| **opencode** | Pinned in `version.txt` as `OPENCODE_VERSION` build arg | |
| 12 | +| **Node.js** | Current LTS via `n`, installed to `/opt/n` (outside home) | |
| 13 | +| **Python 3** | pip, venv | |
| 14 | +| **Build tools** | `build-essential`, `pkg-config` (for native npm addons, pip source builds) | |
| 15 | +| **CLI utilities** | git, curl, wget, jq, ripgrep, fd-find, vim, nano, less, unzip, ssh client | |
| 16 | +| **Init** | tini as PID 1 (zombie reaping, clean shutdown) | |
| 17 | + |
| 18 | +## Usage |
| 19 | + |
| 20 | +### Quick start |
| 21 | + |
| 22 | +```bash |
| 23 | +docker run -it -p 4096:4096 -v $(pwd):/home/opencode sprisa/opencode:latest |
| 24 | +``` |
| 25 | + |
| 26 | +The server starts on port 4096. Mount your project at `/home/opencode` to persist the entire home directory (dotfiles, config, and `~/workspace`). |
| 27 | + |
| 28 | +### Environment variables |
| 29 | + |
| 30 | +| Variable | Default | Description | |
| 31 | +|---|---|---| |
| 32 | +| `OPENCODE_PORT` | `4096` | Port the server listens on | |
| 33 | +| `OPENCODE_SERVER_PASSWORD` | *(none)* | Optional auth password for the server | |
| 34 | +| `OPENCODE_CORS_ORIGIN` | *(none)* | Optional CORS origin; omit to disable CORS | |
| 35 | + |
| 36 | +### Examples |
| 37 | + |
| 38 | +**With authentication:** |
| 39 | +```bash |
| 40 | +docker run -it -p 4096:4096 \ |
| 41 | + -e OPENCODE_SERVER_PASSWORD=secret \ |
| 42 | + -v myproject:/home/opencode \ |
| 43 | + sprisa/opencode:latest |
| 44 | +``` |
| 45 | + |
| 46 | +**With CORS enabled for a specific origin:** |
| 47 | +```bash |
| 48 | +docker run -it -p 4096:4096 \ |
| 49 | + -e OPENCODE_CORS_ORIGIN=https://myapp.example.com \ |
| 50 | + sprisa/opencode:latest |
| 51 | +``` |
| 52 | + |
| 53 | +**Custom port:** |
| 54 | +```bash |
| 55 | +docker run -it -p 8080:8080 \ |
| 56 | + -e OPENCODE_PORT=8080 \ |
| 57 | + sprisa/opencode:latest |
| 58 | +``` |
| 59 | + |
| 60 | +## Building & pushing |
| 61 | + |
| 62 | +All docker commands go through `task` which reads the pinned version from `version.txt`: |
| 63 | + |
| 64 | +```bash |
| 65 | +task docker:build # Build locally as sprisa/opencode:<version> |
| 66 | +task docker:login # Docker Hub login (needs $DOCKER_USER / $DOCKER_PASS) |
| 67 | +task docker:push # Push +latest and +<version> for amd64/arm64 |
| 68 | +``` |
| 69 | + |
| 70 | +## Updating the opencode version |
| 71 | + |
| 72 | +```bash |
| 73 | +task update-version |
| 74 | +``` |
| 75 | + |
| 76 | +Fetches the latest release from [anomalyco/opencode](https://github.com/anomalyco/opencode) on GitHub and writes it to `version.txt`. |
| 77 | + |
| 78 | +## Runtime notes |
| 79 | + |
| 80 | +- The `opencode` user has passwordless sudo, so you can `su - opencode -c 'apt install <pkg>'` inside the container. |
| 81 | +- The root filesystem is ephemeral; mount `/home/opencode` as the persistent volume for all user data (dotfiles, config, projects). The `~/workspace` subdirectory is the default workdir. |
| 82 | +- `~/.local/bin` is on PATH and user-writable, useful for dropping custom tools at runtime. |
| 83 | +- Node version can be switched at runtime with `n <version>` (e.g. `n lts`). |
0 commit comments