# Production docker-compose — full stack
services:
  app:
    build:
      context: .
      dockerfile: apps/screenburn/Dockerfile
    image: ghcr.io/screenburn-hq/screenburn-app:latest
    ports:
      - "3000:3000"
    env_file: .env
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_started
    restart: unless-stopped

  hocuspocus:
    build:
      context: .
      dockerfile: packages/collaboration/Dockerfile
    image: ghcr.io/screenburn-hq/screenburn-collab:latest
    ports:
      - "1234:1234"
    env_file: .env
    depends_on:
      postgres:
        condition: service_healthy
    restart: unless-stopped

  postgres:
    image: postgres:16
    volumes:
      - pgdata:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: screenburn
      POSTGRES_USER: screenburn
      POSTGRES_PASSWORD: ${DB_PASSWORD}
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U screenburn"]
      interval: 5s
      timeout: 5s
      retries: 5
    restart: unless-stopped

  redis:
    image: redis:7
    restart: unless-stopped

  caddy:
    image: caddy:2
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
      - caddy_data:/data
      - caddy_config:/config
    depends_on:
      - app
      - hocuspocus
    restart: unless-stopped

volumes:
  pgdata:
  caddy_data:
  caddy_config:
