Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
59 lines (58 loc) · 2.29 KB
/
Copy pathdocker-compose.yml
File metadata and controls
59 lines (58 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# OpenCode API — single-service compose file.
#
# cp .env.example .env # then set OPENCODE_API_KEYS
# docker compose up --build
#
# The image does NOT contain the OpenCode CLI. Uncomment the `opencode` mount
# below (or set OPENCODE_SERVER_URL) so the gateway can reach an upstream
# `opencode serve`; otherwise completions fail with 503 upstream_unavailable.
#
# Linux/macOS: - "$(command -v opencode):/usr/local/bin/opencode:ro"
# Windows: - "C:/Users/<you>/AppData/Roaming/npm/node_modules/@opencode/cli/bin/opencode.exe:/usr/local/bin/opencode:ro"
services:
opencode-api:
build:
context: .
dockerfile: Dockerfile
image: opencode-api:latest
container_name: opencode-api
restart: unless-stopped
# Reads OPENCODE_API_KEYS and every other setting from .env. Values in the
# `environment` block below override the file.
env_file:
- .env
environment:
HOST: 0.0.0.0
PORT: "20123"
OPENCODE_DATA_DIR: /data
OPENCODE_WORKDIR: /workspace
# Where the mounted CLI binary appears inside the container.
OPENCODE_BIN: /usr/local/bin/opencode
# Log as JSON lines, since a container has no TTY.
OPENCODE_LOG_PRETTY: "false"
ports:
- "20123:20123"
volumes:
# Gateway state: upstream logs, optional session cache.
- ${OPENCODE_DATA_DIR:-./.opencode-api}:/data
# Directory OpenCode hands to its agents. This is the sandbox root; do not
# point it at a source checkout you care about.
- ${OPENCODE_WORKDIR:-./workspace}:/workspace
# REQUIRED for the private-server mode — uncomment and fix the host path:
# - "${OPENCODE_BIN_HOST:-/usr/local/bin/opencode}:/usr/local/bin/opencode:ro"
# The container runs as uid/gid 1000 (`node`). Make sure the two host
# directories above are writable by that user:
# mkdir -p .opencode-api workspace && sudo chown -R 1000:1000 .opencode-api workspace
healthcheck:
test:
- CMD
- node
- -e
- "fetch('http://127.0.0.1:20123/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"
interval: 30s
timeout: 5s
start_period: 10s
retries: 3
# Long-running model turns: keep the gateway reachable while a request is
# streaming.
stop_grace_period: 30s