fix: remove hardcoded Postgres creds + host port exposure in self-host compose

The commented-out durable-Postgres block that SELF-HOSTING.md tells operators
to uncomment shipped a default openjev/openjev/openjev user/password/db and
published 5432:5432 to the host. An operator who followed the docs verbatim
got Postgres (API key hashes, webhook secrets, session data) reachable by
anyone on the host's network with a trivially guessable credential.

Now requires POSTGRES_PASSWORD to be set (fails fast via compose's :? syntax
if missing) and no longer publishes the Postgres port to the host — db stays
reachable only on the internal compose network.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
caelum0x 2026-11-07 02:56:55 +03:00
parent 4847e35451
commit cd42e8564a
3 changed files with 21 additions and 10 deletions

View File

@ -156,8 +156,12 @@ LAYA_ENGINE_URL=http://127.0.0.1:8092
# =============================================================================
# Postgres connection string. When set, real Postgres is used and migrations run
# at start; when UNSET, an in-memory PGLite fallback is used (data is lost on
# restart). For durable self-host, run Postgres and point this at it, e.g.:
# DATABASE_URL=postgresql://openjev:openjev@db:5432/openjev
# restart). For durable self-host, uncomment the `db` service in
# docker-compose.yml, set POSTGRES_PASSWORD below to a real secret (not the
# word "openjev" — that was only ever a placeholder), and point this at it
# using the SAME password, e.g.:
# POSTGRES_PASSWORD=<openssl rand -hex 24>
# DATABASE_URL=postgresql://openjev:<same POSTGRES_PASSWORD>@db:5432/openjev
# =============================================================================
# Auth & signing secret (optional — self-host sign-in)

View File

@ -30,13 +30,18 @@ downloaded model weights).
By default the Node service uses an in-memory PGLite database — data resets on restart.
For persistence, uncomment the `db` (Postgres) service and the `pgdata` volume in
`docker-compose.yml`, then set in `.env`:
`docker-compose.yml`, pick your own strong password, and set both in `.env`
(the compose file does not publish Postgres's port to the host — `db` is only
reachable from the other containers on the internal compose network):
```bash
DATABASE_URL=postgresql://openjev:openjev@db:5432/openjev
POSTGRES_PASSWORD=<a real secret, e.g. `openssl rand -hex 24`>
DATABASE_URL=postgresql://openjev:<same POSTGRES_PASSWORD>@db:5432/openjev
```
Migrations run automatically at container start.
Never leave `POSTGRES_PASSWORD`/`DATABASE_URL` at the old `openjev`/`openjev` default —
that credential pair is public (it was this project's placeholder) and must not be used
on any host reachable by anyone else. Migrations run automatically at container start.
### LLM escalation (optional)

View File

@ -68,19 +68,21 @@ services:
- "8092"
# --- Optional durable Postgres -------------------------------------------
# Uncomment this block AND set DATABASE_URL in .env to:
# postgresql://openjev:openjev@db:5432/openjev
# Uncomment this block, set POSTGRES_PASSWORD in .env to a real secret, and
# set DATABASE_URL in .env to:
# postgresql://openjev:<same POSTGRES_PASSWORD>@db:5432/openjev
# No host port is published — the Node service reaches `db` over the
# internal compose network only. Do NOT add a `ports: ["5432:5432"]`
# mapping here; that would expose Postgres on the host's network interface.
# db:
# image: postgres:16-alpine
# restart: unless-stopped
# environment:
# POSTGRES_USER: openjev
# POSTGRES_PASSWORD: openjev
# POSTGRES_PASSWORD: "${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD in .env}"
# POSTGRES_DB: openjev
# volumes:
# - pgdata:/var/lib/postgresql/data
# ports:
# - "5432:5432"
volumes:
laya-models: