version: '3.8'

services:
  ai_processor:
    # Use the local name of the image you already built with your Dockerfile
    image: yolo-model:1.0
    container_name: nvr_ai_processor
    restart: unless-stopped
    # CRITICAL: Expands shared memory allocation from default 64MB to 1GB
    # to support the FFmpeg in-memory RAM cache (/dev/shm)
    shm_size: '1gb'
    volumes:
      # Mounts your main Python nvr script and config into your baked image dynamically
      - ./nvr_processor.py:/app/nvr_processor.py
      - ./config.json:/app/config.json
    # Overwrite the default CMD to execute your main script
    command: python /app/nvr_processor.py

  mediamtx:
    image: bluenviron/mediamtx:latest
    container_name: mediamtx
    restart: unless-stopped
    # Running in host networking mode allows seamless low-latency WebRTC/RTSP handling
    ports:
     - 8554:8554
     - 8888:8888
     - 8889:8889
    volumes:
     - ./mediamtx.yml:/mediamtx.yml
