You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 0f0c271
Browse filesBrowse the repository at this point in the historyBrowse files
> **macOS / Docker users**: `docker-compose.yml` puts data in the **named volume `coding2api-data`** (the VM's local ext4) by default. **Do not switch it back to a `./data:/app/data` bind mount** — SQLite on macOS's virtiofs shared mount corrupts the database (repeated `database disk image is malformed`; worst case the main DB header is zeroed out). See "Deployment notes".
76
+
75
77
Pull the image: `docker compose pull` (or `docker pull ghcr.io/robbsluo/coding2api:v0.15.1`). Pushing a `v*` tag to main runs `.github/workflows/publish.yml` → publishes `<tag>` + `:latest`. For https on a VPS with a public IP see "[Public deployment](#public-deployment-docker--caddy-automatic-https)".
76
78
77
79
## Users and roles
@@ -549,7 +551,7 @@ The authoritative list is `src/config.py`; every item is passed through `docker-
549
551
|`ADMIN_USERNAMES`| empty | Bootstrap only (while no active admin exists): promoted to `admin` on first start |
550
552
|`USERS_FILE`|`secrets/users.txt`| Bootstrap only: legacy user file, imported once |
551
553
|`PUBLIC_BASE_URL`|`http://127.0.0.1:8000`| Browser-reachable base; TRAE login callback; HSTS over https. Does not control session cookie `Secure`. Loopback / `0.0.0.0` → callback base falls back to the request origin |
552
-
|`DATA_DIR`|`./data`| SQLite and runtime data directory |
554
+
|`DATA_DIR`|`./data`| SQLite and runtime data directory. **Bare-metal** uses `./data`; **Docker deploys use the named volume `coding2api-data`** (mounted at `/app/data` in the container) — do not bind-mount the host directory; see "Deployment notes" (SQLite on virtiofs corrupts the database)|
553
555
|`DEFAULT_MODEL`|`deepseek-v4.1-flash`| Used when the model is empty / `auto`|
554
556
|`QUOTA_PROBE_MINUTES`|`60`| Quota probe period (min 1) |
555
557
|`REFRESH_INTERVAL_MINUTES`|`30`| Token pre-refresh period (min 5) |
@@ -706,6 +708,8 @@ The table above marks only common hot-reloadable items; **89 items** in total (`
706
708
707
709
-**Platform: Linux / macOS only.** The single-instance lock (`src/instance_lock.py`) relies on `flock`; on Windows it exits with a readable Chinese message — use WSL2 / Docker. The `data/``0700` trust boundary is enforced on Windows via `icacls` in `src/security/private_files.py`.
708
710
-**One writer per `DATA_DIR`**: never run a host process (`python -m src.main` / launchd) and a Docker container against the same `./data` at the same time. On macOS virtiofs, `flock` does not cross the host/container boundary: the container acquires the lock even while the host holds it, so the single-instance guard is void and two writers corrupt SQLite (observed as `database disk image is malformed`). When switching deployment modes, stop one side first (`launchctl bootout` or `docker compose stop`) and confirm the other is not running. Do not delete/modify `-wal`/`-shm` from the host while the container is running — that yields `disk I/O error`; stop the container for maintenance.
711
+
- **Docker deploys: `DATA_DIR` must be a named volume — never bind-mount the host directory** (`./data:/app/data`). `docker-compose.yml` already defaults to the named volume `coding2api-data`; **do not switch it back to `./data`**. Why: on macOS, Docker (Docker Desktop / colima, `vmType: vz` + `mountType: virtiofs`) exposes a bind-mounted host directory to the container as a **virtiofs/FUSE shared filesystem** — the `flock`/POSIX-lock, `mmap`, `fsync`, and atomic-rename semantics SQLite relies on do not hold across the VM boundary, so WAL writes get corrupted. Observed symptoms: repeated `database disk image is malformed`, `integrity_check` reporting missing index rows, and in the worst case **the main database header zeroed out entirely** (`0000...`, the file will not open) — recoverable only from a backup. A named volume lives on the VM's local ext4, where the locking semantics are sound. Verify with `docker exec coding2api stat -f -c '%T' /app/data`: it should print a local fs such as `ext2/ext3`; **`fuse` / `virtiofs` means it is wrong**. To migrate historical data see `scripts/migrate-data-to-volume.sh`.
712
+
-**Don't let multiple checkouts / worktrees fight over the same container name**: `container_name: coding2api` is globally unique. If you keep several git worktrees / older checkouts that each ship a compose file, running `docker compose up` from a **non-primary** directory uses *that* copy (which may still have the old bind-mount config) and **replaces the running production container**. Always deploy from the primary checkout; don't `up` the same-named service from an old worktree until it has been upgraded to the named-volume compose.
709
713
-**Mount ownership**: the container runs as uid 1001 (`appuser`) → `mkdir -p data secrets && sudo chown -R 1001:1001 data secrets`.
710
714
-**Time zone**: the image defaults to `TZ=Asia/Shanghai`; `TZ` from `.env` passes through. Check-in and quota periods key off "9am today", so it must match the host.
711
715
-**TRAE callback**: `PUBLIC_BASE_URL` is local-only by default; remote / container deployments must set a browser-reachable address. Forgetting it fails loudly: a loopback / `0.0.0.0` base falls back to the request origin and the *Add credential* dialog shows the effective address. If the callback is unreachable from the browser (common NAS / remote "network error"), paste the whole link from the address bar into the TRAE box — login works without the browser reaching this service.
0 commit comments