fix: drop curl healthcheck and cors.ini mount; configure CORS via API

The couchdb:3 image purges curl after the build, so the curl-based
healthcheck could never succeed. The cors.ini bind-mount also looks
like the cause of the ~600ms container exit observed in the first two
Coolify deploys. Both pieces are removed; CORS is now applied by the
init sidecar via PUTs against /_node/_local/_config/..., which is
idempotent on redeploy.
This commit is contained in:
Julien Calixte
2026-06-01 20:45:32 +02:00
parent 38089ef269
commit cff802bd3f
3 changed files with 33 additions and 25 deletions

View File

@@ -1,6 +1,6 @@
# coolcouch
CouchDB 3 on Coolify, with CORS enabled and system databases bootstrapped at first start.
CouchDB 3 on Coolify. The `couchdb-init` sidecar waits for the server to come up, creates the three system databases, and enables CORS via the config API — no file mounts required.
## Deploy
@@ -9,7 +9,7 @@ CouchDB 3 on Coolify, with CORS enabled and system databases bootstrapped at fir
- `COUCHDB_PASSWORD` — required
- `COUCHDB_USER` — optional, defaults to `admin`
3. In the resource's **Domains** tab, assign a domain to the `couchdb` service on port `5984`. Coolify fills `SERVICE_FQDN_COUCHDB_5984` from this.
4. **Deploy.** The `couchdb-init` one-shot service will wait for CouchDB to be healthy, then `PUT` `_users`, `_replicator`, `_global_changes` and exit.
4. **Deploy.** `couchdb-init` runs once, exits, and won't restart.
## Verify
@@ -24,13 +24,14 @@ curl -fsS -I -X OPTIONS https://$DOMAIN/ \
-H "Access-Control-Request-Method: GET"
```
Expected: `_up` returns `{"status":"ok",...}`; `/` returns the CouchDB welcome JSON; `_all_dbs` returns `["_global_changes","_replicator","_users"]`; the preflight returns a 2xx with an `Access-Control-Allow-Origin` header.
Expected: `_up` returns `{"status":"ok",...}`; `/` returns the CouchDB welcome JSON; `_all_dbs` returns `["_global_changes","_replicator","_users"]`; the preflight returns 2xx with an `Access-Control-Allow-Origin` header.
If the init logs show CORS errors, you can re-trigger only that step by redeploying — the PUTs against `/_node/_local/_config/...` are idempotent.
## CORS
Wildcard origin (`*`), `credentials = false` — the only browser-spec-legal combination with a wildcard. If a client needs cookie/credentialed auth, switch `origins` in `couchdb/local.d/cors.ini` to an explicit list and set `credentials = true`.
Wildcard origin (`*`) with `credentials = false` — the only browser-spec-legal combination with a wildcard. For credentialed auth from the browser, edit the `put_config cors origins`/`credentials` lines in `docker-compose.yml`.
## Files
- `docker-compose.yml` — services, volume, Traefik labels, healthcheck, init sidecar
- `couchdb/local.d/cors.ini` — mounted into `/opt/couchdb/etc/local.d/` so CouchDB picks it up at startup
- `docker-compose.yml` — services, volume, Traefik labels, init sidecar