Files
openchamber/docker-compose.yml
T
Iuliia Ivashko dc100ed0da fix: bind web server to 127.0.0.1 by default and add --host CLI flag (#750)
## Summary

Fixes #736 — OpenChamber listens on `0.0.0.0` (all interfaces) by default, exposing the server to the network without warning. The log output shows `visit: http://127.0.0.1:...` which is misleading.

## Changes

- **Default bind address changed to `127.0.0.1`** — server is only accessible locally unless explicitly configured otherwise
- **New `--host` CLI flag** — `openchamber --host 0.0.0.0 -p 8080` to listen on all interfaces
- **`OPENCHAMBER_HOST` env var** — documented in help text and docker-compose.yml as an alternative to `--host`
- **Docker entrypoint** defaults to `OPENCHAMBER_HOST=0.0.0.0` so container port mapping continues to work
- **Startup logs** show the actual bind address instead of hardcoded `localhost`

### Resolution priority

```
--host flag  >  OPENCHAMBER_HOST env var  >  127.0.0.1 (default)
```

### What doesn't break

- **Desktop app** — already forces `OPENCHAMBER_HOST=127.0.0.1` via Tauri
- **VS Code extension** — doesn't use the web server
- **Docker** — entrypoint sets `OPENCHAMBER_HOST=0.0.0.0`, preserving current behavior
- **Tunnels** — cloudflared connects to `127.0.0.1` origin internally, works regardless of bind address

## Testing

Automated:
- `bun run type-check` / `bun run lint` — pass

Manual (CLI, direct `node` execution):
- Default bind → `127.0.0.1` (verified via `lsof`/netstat)
- `--host 0.0.0.0` → binds all interfaces
- `--host=0.0.0.0` (inline) → works
- `--host` without value → error exit 2
- `OPENCHAMBER_HOST` env var → respected
- `--host` flag overrides env var
- IPv6 `::1` → correct bracketed URL, health check 200
- CLI daemon start/stop → works
- `visit:` URL → correct
- Help text → `--host` in OPTIONS, `OPENCHAMBER_HOST` in ENVIRONMENT
- Browser UI → loads and works
- Tunnel via UI → works
- Desktop app → no regression

Docker (tested on Ubuntu with native Docker):
- SSH key generated successfully
- `OpenChamber server listening on 0.0.0.0:3000`
- Health check 200
- `uid=1000(openchamber)` confirmed
2026-03-23 15:07:16 +02:00

30 lines
1.3 KiB
YAML

services:
openchamber:
build:
context: .
dockerfile: Dockerfile
container_name: openchamber
ports:
- "3000:3000"
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
- ./data/openchamber:/home/openchamber/.config/openchamber
- ./data/opencode/share:/home/openchamber/.local/share/opencode
- ./data/opencode/state:/home/openchamber/.local/state/opencode
- ./data/opencode/config:/home/openchamber/.config/opencode
- ./data/ssh:/home/openchamber/.ssh
- ./workspaces:/home/openchamber/workspaces
#environment:
# OPENCHAMBER_HOST: 0.0.0.0 # Bind address (default in Docker: 0.0.0.0)
# UI_PASSWORD: your_secure_password_here # Uncomment to set UI password
# OPENCHAMBER_TUNNEL_PROVIDER: cloudflare
# OPENCHAMBER_TUNNEL_MODE: quick # quick | managed-remote | managed-local
# OPENCHAMBER_TUNNEL_HOSTNAME: app.example.com # required for managed-remote
# OPENCHAMBER_TUNNEL_TOKEN: your_cloudflare_token # required for managed-remote
# OPENCHAMBER_TUNNEL_CONFIG: /home/openchamber/.cloudflared/config.yml # optional for managed-local
# OH_MY_OPENCODE: true # enable oh-my-opencode
# OPENCODE_HOST: http://172.17.0.1:4096 # Connect to external OpenCode server
# OPENCODE_SKIP_START: true # skip start opencode
restart: unless-stopped