Everything not listed in this document should behave the same as upstream OpenCode. If a feature, setting, or behavior is not mentioned here, the upstream documentation is accurate and fully applicable — see the Documentation section of
instructions.mdfor links.
OpenCode is an open-source AI coding agent. This package runs the OpenCode server and its browser interface on StartOS, so coding sessions in a repository are driven from a web page on the network instead of a terminal on the same machine.
- Image and Container Runtime
- Volume and Data Layout
- File Models
- Dependencies
- Network Access and Interfaces
- Installation and First-Run Flow
- Actions
- Tasks
- Health Checks
- Backups and Restore
- Limitations and Differences
- Quick Reference for AI Consumers
The package builds a thin image on top of the upstream OpenCode image
(ghcr.io/anomalyco/opencode), pinned in the package's Dockerfile by release
tag and manifest-list digest. The upstream image is a slim Alpine base that ships
neither git nor bash, and OpenCode shells out to git for repositories, diffs, and
worktrees and to a shell for its terminal tool — so the package Dockerfile adds
git, bash, and openssh-client (for ssh git remotes). Architectures are
x86_64 and aarch64, matching the architectures upstream publishes.
One subcontainer, opencode-sub, runs the server. The image's entrypoint is the
opencode binary itself; the package overrides only the command, to
serve --hostname 0.0.0.0 --port 4096. The container runs as root with
HOME=/root.
The package declares three volumes.
| Volume | Mount point | Contents |
|---|---|---|
main |
/root (read-write) |
The container's entire home: sessions, credentials, repositories, projects, and OpenCode's own config, state, and cache. |
startos |
/etc/opencode-trust (read-only, provider-trust/ only, while a CA is set) |
StartOS-side state: store.json, holding the generated login password, the configured providers' API keys and the connected local-model services, and the optional provider-trust/ca.pem. |
mounts |
not mounted | The read-only public volumes of connected vLLM and llama.cpp services, where the package reads each one's API key and served model. Not backed up. |
main is mounted over the image's home directory, so everything OpenCode writes
under /root persists across restarts and updates:
~/.local/share/opencode/— the sessions database (opencode.db) plus its-shm/-walfiles,log/, andrepos/.~/.config/opencode/— OpenCode's global configuration.~/.local/state/opencode/and~/.cache/opencode/— state and cache.
/tmp/opencode (OpenCode's temporary directory) is not on a volume and is
lost on restart; treat anything only in there as scratch.
Only the optional public CA directory is mounted from startos. The running
server cannot read store.json — it receives the login password as
OPENCODE_PASSWORD and each configured provider's API key as an
OPENCODE_KEY_<ID> variable instead.
The package owns three file models.
| File | Format | Keys | Seeded by | Rewritten by |
|---|---|---|---|---|
startos/store.json |
JSON | adminPassword, providerKeys, localBackends |
the Set Admin Password action | the three actions, on each run |
main/.config/opencode/opencode.json |
JSONC | $schema, providers, model |
the Configure Model Providers action | the same action, on each run |
startos/provider-trust/ca.pem |
PEM | — | the Configure Provider CA action | the same action, on each run |
adminPassword is stored in clear text because the server reads it verbatim
from OPENCODE_PASSWORD and cannot be given a hash. There is no default: it is
absent until the user runs the action, which is what the task waits
for. providerKeys maps a configured provider's id to its API key, and has no
default either. localBackends lists the package ids Connect Local Models
connected. The PEM file is optional and holds one public CA certificate.
Both JSON schemas are permissive (z.looseObject, every key optional), and the
package writes each file only from an action — never at startup, and never to
normalize or repair it. A hand edit therefore survives:
- In
store.json, the running server watches the file and restarts with the new value. - In
opencode.json, OpenCode watches the file and reloads it without a restart. The package leaves every key it does not own — including whatever OpenCode writes there itself — as it found it.
opencode.json is OpenCode's own global configuration, at the path OpenCode
reads it from. The package models it so the Configure Model Providers action can
write provider entries; it is not generated, replaced, or seeded otherwise.
Comments and trailing commas are accepted, but saving reserializes the file as
JSON without its comments or formatting.
Three optional dependencies, each enabled while Connect Local Models has it
connected and it is installed; uninstalling one disables it. Each connected
service must meet its version requirement and be running with its primary
health check passing. An installed service with no API binding still appears
as a dependency, so an older release surfaces an update requirement.
| Dependency | Reached at | Read from its public volume |
OpenCode provider id |
|---|---|---|---|
ollama |
its API binding's bridge address | nothing | ollama |
vllm |
its API binding's bridge address | apiKey and the served model |
vllm |
llama-cpp |
its Bearer-gated API binding's bridge address | apiKey |
llama-cpp |
The package hands each connected service to OpenCode as a provider in
OPENCODE_CONFIG_CONTENT, a config layer OpenCode merges over
opencode.json; nothing is written to the file. A service that is installed
but not yet resolvable — not running its API binding, or vLLM with no model
selected — is left out until it is, and OpenCode restarts when it appears.
- Ollama uses OpenCode's built-in Ollama provider, which lists the pulled models itself every 30 seconds and reads each one's tool and vision support from Ollama.
- vLLM is one model: the one vLLM publishes as served. Switching it in vLLM's Set Model restarts OpenCode onto the new one. Tool calling is on, as every vLLM preset serves with a tool-call parser.
- llama.cpp is one model,
llama-cpp/current, labelledllama.cpp: llama-server answers it with whatever model its Set Model chose.
OpenCode reaches hosted model providers and git remotes over its own outbound network connection.
The service exposes a single interface.
| Interface | Type | Internal port | Protocol | Path | Purpose |
|---|---|---|---|---|---|
ui |
ui |
4096 | HTTP | / |
The OpenCode web app and, under /api/*, the OpenCode HTTP API (its OpenAPI document is at /openapi.json). |
The interface is not masked: the URL itself contains no credential. Access is gated by the server's own login rather than by anything in the address, so what the user opens, and how, is up to the user's gateway choices.
Installing the package raises a single critical task — see Tasks — and the daemon does not start until it is cleared. There is no setup wizard to complete and nothing to configure on disk.
- The user runs the Set Admin Password action, which generates and stores the login password and returns it.
- The daemon starts with
OPENCODE_PASSWORDset to that value. - The user opens the
uiinterface, signs in on the web page with the usernameopencodeand that password.
Model providers are not preconfigured. Hosted providers connect in the web app itself, under Settings → Providers; the Configure Model Providers action adds an OpenAI-compatible endpoint the web app's own catalog has no entry for, and Connect Local Models connects the Ollama, vLLM or llama.cpp service on the same server. The package adds no files OpenCode did not already expect of it.
Four user-facing actions. The OS carries each one's id, name, description, warning, and status gating; what follows is what the metadata cannot express.
- When to run it. On a fresh install, to satisfy the first-run task. Later, whenever the password should be rotated.
- What it changes. Writes
adminPasswordtostartos/store.json, which restarts the running server so it picks up the new value. It touches no other file or volume. - Cost. A few seconds, and the service restarts. The upstream server signs every existing web session out when its password changes, so anyone already signed in must sign in again with the new password.
- Repeat safety. Repeatable. Each run mints a fresh password and replaces the previous one; it never accumulates.
- Outputs. The username
opencode(unmasked, copyable) and the new password (masked, copyable).
- When to run it. When OpenCode should use an OpenAI-compatible endpoint the web app's own catalog has no entry for — a vLLM, LM Studio, or Ollama server on your network. Hosted providers connect in the web app itself, under Settings → Providers.
- What it changes. For each provider in the form, an entry in the
providersmap ofmain/.config/opencode/opencode.json, and its API key underproviderKeysinstartos/store.json; a key given as an{env:…}or{file:…}reference stays in the entry as written instead. Entries carryingpackage: @opencode/ai/providers/openai-compatibleare rebuilt; an ID collision with any other entry is rejected before either file changes. Every other entry, and amodelthat names none of the managed entries, is left as it was. Themodelkey is set when a provider's Default toggle is on; with none on, amodelnaming a managed entry is dropped. A new or changed API key restarts the service, because the server receives it as anOPENCODE_KEY_<ID>environment variable; a change that touches no key is picked up by the running server without a restart. - Cost. Seconds. Nothing outside the two files above is touched, and no session, repository, or project is affected.
- Repeat safety. The form is prefilled with the OpenAI-compatible entries and
is the authority for them: leaving one out disconnects it, and an empty form
disconnects them all. The provider holding the default model opens with
Default on and that model listed first, so saving unchanged keeps the
default. An existing entry's literal API key or key reference is prefilled; on
save the literal moves into
providerKeysand the reference is kept as written. Providers using another package are not listed and are not touched. - Outputs. Each provider with the model IDs it serves, and the default model when one is set.
- When to run it. When an OpenAI-compatible endpoint you use serves a certificate signed by a private or self-signed CA — a vLLM or Ollama server behind an internal certificate authority, for instance — and the web app cannot reach it. Paste the public CA certificate only; never a private key.
- What it changes.
startos/provider-trust/ca.pem, one public CA certificate. The directory is mounted read-only into the container and the certificate is handed to OpenCode asNODE_EXTRA_CA_CERTSon startup, so it applies to outbound TLS connections. The file lives on a volume and is included in the service backup. - Cost. Seconds, and the service restarts so OpenCode re-reads the CA. Nothing else is touched, and no session, repository, or project is affected.
- Repeat safety. Repeatable. Running it again replaces the stored certificate; clearing the field removes trust. The form opens prefilled with the current certificate, so saving unchanged keeps it. One CA at a time.
- Outputs. None.
- When to run it. After installing Ollama, vLLM or llama.cpp on the same server, to use its models in OpenCode; again to disconnect one.
- What it changes.
localBackendsinstartos/store.json, which enables the matching optional dependency and restarts OpenCode with the service as a provider. Nothing inopencode.jsonis touched. - Cost. Seconds, and OpenCode restarts.
- Repeat safety. Repeatable. The form lists only the services installed now,
prefilled with the connected ones; the saved list replaces the previous one.
A selected service whose provider id already exists in
opencode.jsonis rejected without saving. Rename or remove that provider first; OpenCode overlays same-id providers rather than replacing their models and settings. - Outputs. None.
The provider ids ollama, vllm and llama-cpp are reserved for these
services, so Configure Model Providers refuses them.
One task, raised by startos/init/watchCredentials.ts.
| Severity | Raised when | Cleared by |
|---|---|---|
critical |
adminPassword is absent from store.json |
running Set Admin Password |
Because it is critical, it blocks the service from starting and suspends the
ordinary controls until it is satisfied — this is what the user sees first, and
why nothing is reachable before a password exists. It is idempotent on its replay
key, so ordinary rebuilds do not re-raise it. It returns only if store.json
loses the password, and running the action again clears it.
One check, the readiness probe for the opencode daemon.
| Check | Probes | Display | Grace period |
|---|---|---|---|
opencode |
a listening TCP socket on port 4096 | Web Interface | default |
A failure means nothing is listening on the interface port. During the grace period that is normal startup; the probe only reports a hard failure once the server has had time to bind. A persistent failure after startup means the daemon exited — read the service logs, where OpenCode prints its startup error, and confirm the container's data volume is writable before concluding the process is at fault.
The backup strategy is a whole-volume snapshot:
sdk.Backups.ofVolumes('main', 'startos'). StartOS stops the service before the
backup and restarts it afterward, so the SQLite database (including its -wal
and -shm files) is captured quiesced; no logical dump is involved. A restore
therefore reconstructs each volume by its files, not by replaying anything.
main and startos are captured whole; mounts is excluded, since it only
holds connected services' public volumes, mounted afresh at every start:
mainrestores every session, provider credential, cloned repository, project, and OpenCode setting.startosrestores the generated login password, the connected local-model services, and the provider CA, so a restored instance is usable with the password in use at backup time.
No credential has to be re-entered and no resync is required. A connected local-model service is used again once it is installed and running; until then its models are absent.
- Only the server and its web interface are packaged. OpenCode's terminal TUI and its desktop and mobile apps are not part of this package; you drive sessions through the web page.
- The
opencode pairpairing-link flow is not wired up. Sign in with the password from the Set Admin Password action instead of a one-time pairing link or QR code. - OpenCode's self-updater is disabled in the container. The server is updated by updating the StartOS package, not from inside the app.
- The container runs as
root. The upstream image does, and the package does not change its user. - A custom vLLM model needs tool calling enabled. OpenCode calls vLLM's
model with tools on; a model served without
--enable-auto-tool-choiceand a--tool-call-parserrejects those requests. vLLM's presets all set both. - The service opens its own outbound connections — to model providers and to git repositories it clones or fetches. Those are made from the server's outbound route, independently of whichever address the web interface is published on.
package_id: opencode
image: ghcr.io/anomalyco/opencode
architectures: [x86_64, aarch64]
subcontainers: [opencode-sub]
volumes:
main: /root
startos: /etc/opencode-trust # provider-trust/ only, read-only, while a CA is set
mounts: unmounted
file_models:
- startos/store.json
- main/.config/opencode/opencode.json
- startos/provider-trust/ca.pem
startos_managed_env_vars:
- OPENCODE_PASSWORD
- OPENCODE_DISABLE_AUTOUPDATE
- OPENCODE_KEY_<PROVIDER_ID>
- NODE_EXTRA_CA_CERTS
- OPENCODE_CONFIG_CONTENT
dependencies: [ollama, vllm, llama-cpp] # all optional
interfaces:
ui: { type: ui, port: 4096 }
actions:
- set-admin-password
- configure-providers
- configure-provider-ca
- connect-local-models
tasks:
- { action: set-admin-password, severity: critical }
health_checks:
- opencode