# Self-hosted Postgres for Cockpit + studio apps (Oracle Always Free / Hetzner VPS). # Run on a VM with: docker compose up -d # # Expose: # :5432 direct → DATABASE_URL (migrations, LISTEN/NOTIFY) # :6432 pool → DATABASE_POOL_URL (Vercel / serverless) # # See docs/infrastructure/postgres-portability.md services: postgres: image: postgres:17-alpine restart: unless-stopped environment: POSTGRES_USER: ${POSTGRES_USER:-studio} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env} volumes: - pg_data:/var/lib/postgresql/data - ./init:/docker-entrypoint-initdb.d:ro healthcheck: test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-studio}"] interval: 5s timeout: 3s retries: 10 ports: - "127.0.0.1:5432:5432" pgbouncer: image: edoburu/pgbouncer:v1.24.1-p1 restart: unless-stopped depends_on: postgres: condition: service_healthy environment: DATABASE_URL: postgres://${POSTGRES_USER:-studio}:${POSTGRES_PASSWORD}@postgres:5432/cockpit POOL_MODE: transaction MAX_CLIENT_CONN: 200 DEFAULT_POOL_SIZE: 20 AUTH_TYPE: scram-sha-256 ports: - "127.0.0.1:6432:5432" volumes: pg_data: