Skip to content

Commit 8c0ab11

Browse files
committed
Modernize docker compose defaults and override knobs
1 parent 421284a commit 8c0ab11

5 files changed

Lines changed: 80 additions & 11 deletions

File tree

.env.example

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# opencode-cloud Docker Compose overrides
2+
#
3+
# Copy to .env in this directory to customize runtime defaults.
4+
5+
# Container image to run.
6+
# Production recommendation: pin to an explicit tag (for example 15.2.0).
7+
OPENCODE_IMAGE=prizz/opencode-cloud-sandbox:latest
8+
9+
# Image pull behavior for docker compose.
10+
# Common values: missing (default), always.
11+
OPENCODE_PULL_POLICY=missing
12+
13+
# Host:container port mapping.
14+
# Local-safe default binds localhost only; use 3000:3000 for public exposure.
15+
OPENCODE_PORT_MAPPING=127.0.0.1:3000:3000
16+
17+
# Hostname passed to opencode web in the container.
18+
OPENCODE_HOST=0.0.0.0
19+
20+
# Graceful shutdown window before Docker sends SIGKILL.
21+
OPENCODE_STOP_GRACE_PERIOD=30s
22+
23+
# Container log settings (json-file driver with rotation by default).
24+
OPENCODE_LOG_DRIVER=json-file
25+
OPENCODE_LOG_MAX_SIZE=10m
26+
OPENCODE_LOG_MAX_FILE=3

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,22 @@ docker compose up -d
9797

9898
This uses the included `docker-compose.yml` which configures all persistent volumes automatically.
9999

100+
Optional `.env` overrides (same directory as `docker-compose.yml`):
101+
102+
```bash
103+
# Example: expose publicly and pin a reproducible image tag
104+
cat > .env <<'EOF'
105+
OPENCODE_PORT_MAPPING=3000:3000
106+
OPENCODE_IMAGE=prizz/opencode-cloud-sandbox:15.2.0
107+
EOF
108+
```
109+
110+
By default, Compose uses `OPENCODE_PULL_POLICY=missing`. To force-refresh to newer image layers:
111+
112+
```bash
113+
docker compose pull && docker compose up -d
114+
```
115+
100116
Retrieve the Initial One-Time Password (IOTP) and open `http://localhost:3000`:
101117

102118
```bash

docker-compose.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,21 @@
1414

1515
services:
1616
opencode:
17-
image: prizz/opencode-cloud-sandbox:latest
17+
image: ${OPENCODE_IMAGE:-prizz/opencode-cloud-sandbox:latest}
18+
pull_policy: ${OPENCODE_PULL_POLICY:-missing}
1819
container_name: opencode-cloud-sandbox
1920
restart: unless-stopped
21+
init: true
22+
stop_grace_period: ${OPENCODE_STOP_GRACE_PERIOD:-30s}
2023
ports:
21-
- "127.0.0.1:3000:3000"
24+
- "${OPENCODE_PORT_MAPPING:-127.0.0.1:3000:3000}"
2225
environment:
23-
- OPENCODE_HOST=0.0.0.0
26+
OPENCODE_HOST: ${OPENCODE_HOST:-0.0.0.0}
27+
logging:
28+
driver: ${OPENCODE_LOG_DRIVER:-json-file}
29+
options:
30+
max-size: ${OPENCODE_LOG_MAX_SIZE:-10m}
31+
max-file: "${OPENCODE_LOG_MAX_FILE:-3}"
2432
volumes:
2533
- opencode-data:/home/opencoder/.local/share/opencode
2634
- opencode-state:/home/opencoder/.local/state/opencode

docs/deploy/digitalocean-droplet.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,12 @@ for the default `opencoder` account or use username/password fallback.
289289

290290
#### 6) Expose publicly (optional)
291291

292-
Edit `docker-compose.yml` and change the port binding:
292+
Set a Compose override so the service binds on all interfaces:
293293

294-
```yaml
295-
ports:
296-
- "3000:3000" # was "127.0.0.1:3000:3000"
294+
```bash
295+
cat > .env <<'EOF'
296+
OPENCODE_PORT_MAPPING=3000:3000
297+
EOF
297298
```
298299

299300
Then restart:

docs/deploy/docker-desktop.md

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ volumes automatically.
3838
# Clone or download docker-compose.yml from the repository root
3939
curl -O https://raw.githubusercontent.com/pRizz/opencode-cloud/main/docker-compose.yml
4040

41+
# Optional: copy defaults and customize Compose knobs
42+
curl -O https://raw.githubusercontent.com/pRizz/opencode-cloud/main/.env.example
43+
cp .env.example .env
44+
4145
# Start the service
4246
docker compose up -d
4347
```
@@ -168,19 +172,26 @@ Docker Desktop), Docker creates anonymous volumes automatically. This protects
168172
against accidental data loss on container restarts, but anonymous volumes are
169173
deleted when the container is removed.
170174

171-
## Environment Variables
175+
## Environment Variables (`.env` for Docker Compose)
172176

173177
| Variable | Default | Notes |
174178
|----------|---------|-------|
175-
| `OPENCODE_HOST` | `0.0.0.0` | Must be `0.0.0.0` for Docker Desktop port forwarding to work |
176-
| `OPENCODE_PORT` | `3000` | Container port for the web UI |
179+
| `OPENCODE_IMAGE` | `prizz/opencode-cloud-sandbox:latest` | Set a pinned tag (for example `15.2.0`) for reproducible deploys |
180+
| `OPENCODE_PULL_POLICY` | `missing` | Compose pull behavior. `missing` does not re-pull when image already exists; use `always` to check registry on each `up` |
181+
| `OPENCODE_PORT_MAPPING` | `127.0.0.1:3000:3000` | Host:container port mapping. Use `3000:3000` to expose publicly |
182+
| `OPENCODE_HOST` | `0.0.0.0` | Hostname passed to opencode inside the container |
183+
| `OPENCODE_STOP_GRACE_PERIOD` | `30s` | Grace period before force kill on shutdown |
184+
| `OPENCODE_LOG_DRIVER` | `json-file` | Docker log driver used for container logs |
185+
| `OPENCODE_LOG_MAX_SIZE` | `10m` | Maximum size for each rotated log file |
186+
| `OPENCODE_LOG_MAX_FILE` | `3` | Number of rotated log files to retain |
177187

178188
## Updating
179189

180190
To update to a newer image version:
181191

182192
```bash
183193
# Docker Compose
194+
# default pull policy is "missing"
184195
docker compose pull
185196
docker compose up -d
186197

@@ -200,7 +211,14 @@ Named volumes persist across this process. Your data is preserved.
200211
Another service is using port 3000. Change the host port:
201212

202213
```bash
203-
# Docker Compose: edit docker-compose.yml, change "127.0.0.1:3000:3000" to "127.0.0.1:8080:3000"
214+
# One-off override
215+
OPENCODE_PORT_MAPPING=127.0.0.1:8080:3000 docker compose up -d
216+
217+
# Persistent override
218+
cp .env.example .env
219+
echo "OPENCODE_PORT_MAPPING=127.0.0.1:8080:3000" >> .env
220+
docker compose up -d
221+
204222
# Docker CLI: use -p 127.0.0.1:8080:3000
205223
```
206224

0 commit comments

Comments
 (0)