services:
  # Redis - Required for BullMQ background jobs (notifications, SLAs)
  # Uses host networking so Compose does not create a bridge (avoids DOCKER-FORWARD / iptables failures on some hosts).
  # Redis listens on the host on port 6379 (same as REDIS_PORT in .env).
  redis:
    image: redis:7.2-alpine
    container_name: re-onboarding-redis
    restart: always
    network_mode: host
    volumes:
      - redis_data:/data
    command: redis-server --save 60 1 --loglevel warning

  # RedisInsight - GUI for monitoring Redis/BullMQ (Optional)
  # Connect in the UI to host.docker.internal:6379 (extra_hosts maps that to the host where Redis runs).
  redis-insight:
    image: redislabs/redisinsight:latest
    container_name: re-onboarding-redis-insight
    restart: always
    ports:
      - "8001:8001"
    extra_hosts:
      - "host.docker.internal:host-gateway"
    depends_on:
      - redis

  # PostgreSQL - Uses the default bridge; `docker compose up` (full stack) still needs iptables/Docker networking working.
  postgres:
    image: postgres:15-alpine
    container_name: re-onboarding-db
    restart: always
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: Admin@123
      POSTGRES_DB: royal_enfield_onboarding
    ports:
      - "5432:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data

volumes:
  redis_data:
  postgres_data:
