version: "3.9"

services:
  redis:
    image: redis:8
    container_name: redis_server
    restart: always
    network_mode: host
    volumes:
      - ./redis.conf:/usr/local/etc/redis/redis.conf
    command: ["redis-server", "/usr/local/etc/redis/redis.conf"]
  deepstream-app:
    build: .
    image: ${IMAGE_NAME}:${TAG}
    depends_on:
      - redis
    container_name: deepstream_with_triton
    restart: always
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]
    network_mode: host
    volumes:
      # Mount configs (edit locally, no rebuild needed)
      - ./data:/app/data
      - ./Put.mp4:/root/Put.mp4

      # Mount models for first Triton: Pose detection
      - ./pose_detection/models:/root/pose_detection/models:ro

      # Mount second Triton repo: Face detection
      - ./face_post_process:/root/face_models:ro

    env_file:
      - ./triton_ports.env
    environment:
      REDIS_HOST: 127.0.0.1   # since DeepStream is host network
      NVIDIA_VISIBLE_DEVICES: all
    entrypoint: ["/app/entrypoint.sh"]