version: '3.8'

services:
  god-mode:
    build: .
    restart: always
    ports:
      - "4321:4321"
    environment:
      - NODE_ENV=production
      - DATABASE_URL=${DATABASE_URL}
      # Default to local redis container if no external URL provided
      - REDIS_URL=${REDIS_URL:-redis://redis:6379}
      - GOD_MODE_TOKEN=${GOD_MODE_TOKEN}
    # GOD MODE LIMITS (100k Scale):
    ulimits:
      nofile:
        soft: 65536
        hard: 65536
      nproc: 65536
    deploy:
      resources:
        limits:
          memory: 16G
          cpus: '3.5'
    logging:
      options:
        max-size: "10m"
        max-file: "3"
    depends_on:
      - redis
    networks:
      - default
      - coolify

  # Redis is REQUIRED for the Batch Processor (BullMQ)
  # Included here so God Mode works standalone.
  redis:
    image: 'redis:7-alpine'
    command: 'redis-server --appendonly yes'
    restart: always
    volumes:
      - 'god-mode-redis:/data'
    networks:
      - default
      - coolify
    healthcheck:
      test: [ "CMD", "redis-cli", "ping" ]
      interval: 5s
      timeout: 5s
      retries: 5

volumes:
  god-mode-redis:


networks:
  coolify:
    external: true
    name: coolify
