# Production overrides for Redis configuration
services:
  redis:
    image: redis:7.2-alpine
    container_name: showprima_redis_prod
    restart: always
    ports:
      # In production, consider binding to specific interface or using internal network only
      - "127.0.0.1:6379:6379"
    command: redis-server /usr/local/etc/redis/redis.conf --requirepass ${REDIS_PASSWORD}
    volumes:
      - ./docker/redis/redis.conf:/usr/local/etc/redis/redis.conf:ro
      - redis_data_prod:/data
      # Backup volume for production
      - redis_backup:/backup
    environment:
      - REDIS_REPLICATION_MODE=master
      - REDIS_PASSWORD=${REDIS_PASSWORD}
    networks:
      - showprima_network_prod
    deploy:
      resources:
        limits:
          cpus: '1.0'
          memory: 512M
        reservations:
          cpus: '0.5'
          memory: 256M
    healthcheck:
      test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD}", "ping"]
      interval: 30s
      timeout: 5s
      retries: 3
      start_period: 60s
    logging:
      driver: "json-file"
      options:
        max-size: "50m"
        max-file: "10"

  # Redis Sentinel for high availability (optional)
  redis-sentinel:
    image: redis:7.2-alpine
    container_name: showprima_redis_sentinel
    restart: always
    command: redis-sentinel /usr/local/etc/redis/sentinel.conf
    volumes:
      - ./docker/redis/sentinel.conf:/usr/local/etc/redis/sentinel.conf:ro
    depends_on:
      - redis
    networks:
      - showprima_network_prod
    profiles:
      - ha

volumes:
  redis_data_prod:
    driver: local
    name: showprima_redis_data_prod
  redis_backup:
    driver: local
    name: showprima_redis_backup

networks:
  showprima_network_prod:
    driver: bridge
    name: showprima_network_prod
    ipam:
      driver: default
      config:
        - subnet: 172.25.0.0/16