services:
  pp-db:
    image: postgres:18-alpine
    restart: unless-stopped
    environment:
      POSTGRES_USER: pp
      POSTGRES_PASSWORD: pp_password
      POSTGRES_DB: pp
    volumes:
      - pp_db_data:/var/lib/postgresql
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U pp"]
      interval: 10s
      timeout: 5s
      retries: 5

  pp-backend:
    build:
      context: .
      dockerfile: Dockerfile
    restart: unless-stopped
    environment:
      NODE_ENV: production
      DATABASE_URL: postgresql://pp:pp_password@pp-db:5432/pp
      PORT: 5000
      SESSION_SECRET: ${SESSION_SECRET:?SESSION_SECRET is required}
      PP_BASE_URL: ${PP_BASE_URL:?PP_BASE_URL is required}
      ENCRYPTION_KEY: ${ENCRYPTION_KEY:?ENCRYPTION_KEY is required}
      LOG_LEVEL: info
    depends_on:
      pp-db:
        condition: service_healthy
    ports:
      - "5000:5000"
    volumes:
      - ./prisma:/app/prisma

volumes:
  pp_db_data:
