services:
  backend:
    build: .
    container_name: nvr_backend_gateway
    restart: unless-stopped
    env_file:
      - .env
    environment:
      INGESTION_CONFIG_PATH: /ingestion/config.json
    ports:
      - "8000:8000"
    volumes:
      - ../Ingestion/config.json:/ingestion/config.json:ro
    depends_on:
      mongodb:
        condition: service_started
      minio:
        condition: service_started
      minio-init:
        condition: service_completed_successfully

  mongodb:
    image: mongo:7
    container_name: mongodb_container
    restart: unless-stopped
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: Unsteady-Emphasis-Wildly-Staging
    ports:
      - "27017:27017"
    volumes:
      - mongo_data:/data/db

  minio:
    image: quay.io/minio/minio:RELEASE.2025-04-22T22-12-26Z
    container_name: minio_container
    restart: unless-stopped
    command: server /data --console-address ":9001"
    environment:
      MINIO_ROOT_USER: sqQuRPiRXCpvXjWJgkai
      MINIO_ROOT_PASSWORD: oX6eCMtBJ6rIrkW6Ugu9KKdNzkuSK4v7mT5OkpYH
    ports:
      - "9000:9000"
      - "9001:9001"
    volumes:
      - minio_data:/data

  minio-init:
    image: quay.io/minio/mc:RELEASE.2025-04-16T18-13-26Z
    depends_on:
      - minio
    entrypoint: >
      /bin/sh -c "
      until mc alias set local http://minio:9000 sqQuRPiRXCpvXjWJgkai oX6eCMtBJ6rIrkW6Ugu9KKdNzkuSK4v7mT5OkpYH; do sleep 2; done;
      mc mb --ignore-existing local/nvr-footage;
      exit 0;
      "

volumes:
  mongo_data:
  minio_data:
