nerdware/docker-compose.prod.yml
AyoubBenziza cfc5339a25 fix(server): connect via PG* vars (robust to special chars in password)
postgres-js failed to parse DATABASE_URL when the password contained URL-special
characters (@ : / # ...). New createSqlClient(): uses DATABASE_URL if set, else
falls back to PG* env vars (PGHOST/PGUSER/PGPASSWORD/...) which postgres-js reads
directly — password passed verbatim, no URL encoding. docker-compose.prod.yml now
sets PG* for the server instead of an inline DSN.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-11 23:54:56 +02:00

65 lines
1.8 KiB
YAML

# Stack de production NerdWare (postgres + serveur + client).
# Pensé pour Dokploy (assigne les domaines via Traefik) ou un `docker compose up`.
#
# Variables attendues (UI Dokploy ou fichier .env à côté de ce fichier) :
# POSTGRES_PASSWORD mot de passe Postgres
# ADMIN_TOKEN jeton du back-office quiz
# CORS_ORIGINS domaine(s) du client, ex. https://nerdware.example.com
# VITE_SERVER_URL URL publique du serveur, ex. https://api.nerdware.example.com
services:
postgres:
image: postgres:17-alpine
restart: unless-stopped
environment:
POSTGRES_USER: ${POSTGRES_USER:-nerdware}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-nerdware}
POSTGRES_DB: ${POSTGRES_DB:-nerdware}
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-nerdware} -d ${POSTGRES_DB:-nerdware}"]
interval: 5s
timeout: 5s
retries: 5
server:
build:
context: .
dockerfile: apps/server/Dockerfile
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
environment:
NODE_ENV: production
HOST: 0.0.0.0
PORT: 3001
# Connexion via PG* (mot de passe passé tel quel, pas d'encodage d'URL).
PGHOST: postgres
PGPORT: 5432
PGUSER: ${POSTGRES_USER:-nerdware}
PGPASSWORD: ${POSTGRES_PASSWORD:-nerdware}
PGDATABASE: ${POSTGRES_DB:-nerdware}
ADMIN_TOKEN: ${ADMIN_TOKEN}
CORS_ORIGINS: ${CORS_ORIGINS}
UPLOADS_DIR: /data/uploads
volumes:
- uploads:/data/uploads
expose:
- "3001"
web:
build:
context: .
dockerfile: apps/web/Dockerfile
args:
VITE_SERVER_URL: ${VITE_SERVER_URL}
restart: unless-stopped
depends_on:
- server
expose:
- "80"
volumes:
pgdata:
uploads: