# Production stack: built images (no bind mounts), nginx serves the built
# frontend + reverse-proxies Socket.IO, Postgres is internal-only.
#
# Usage:
#   cp .env.example .env   # fill in real secrets
#   docker compose -f docker-compose.prod.yaml up -d --build

services:
  db:
    image: postgres:18-alpine
    environment:
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: ${POSTGRES_DB}
      TZ: Europe/Bratislava
      PGTZ: Europe/Bratislava
    volumes:
      - pgdata:/var/lib/postgresql
    restart: always
    networks:
      caddy_network:

  pgadmin:
    image: dpage/pgadmin4:latest
    environment:
      PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL}
      PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD}
    volumes:
      - pgadmin_data:/var/lib/pgadmin
    restart: always
    depends_on:
      - db
    networks:
      caddy_network:

  backend:
    build: .
    environment:
      DATABASE_URL: postgresql+asyncpg://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}
      CORS_ALLOWED_ORIGINS: ${CORS_ALLOWED_ORIGINS}
      ADMIN_TOKEN: ${ADMIN_TOKEN}
      ENCRYPTION_KEY: ${ENCRYPTION_KEY}
      GEOIP_DB_PATH: /app/geoip/GeoLite2-Country.mmdb
    volumes:
      - /home/tim/docker_volumes/bridzik/:/app/geoip:ro
    restart: always
    depends_on:
      - db
    networks:
      caddy_network:

  frontend:
    container_name: bridzik
    build: ./frontend
    environment:
      BACKEND_UPSTREAM: backend:5000
    restart: always
    depends_on:
      - backend
    networks:
      caddy_network:

volumes:
  pgdata:
  pgadmin_data:

networks:
  caddy_network:
    external: true