networks:
  photos-net:
    driver: bridge
  ix-databases_shared-databases:
    external: true
  pangolin:
    external: true

services:

  immich-server:
    container_name: ix-immich-immich-server-1
    image: ghcr.io/immich-app/immich-server:release
    restart: unless-stopped
    networks:
      - photos-net
      - ix-databases_shared-databases
      - pangolin
    ports:
      - "2283:2283"
    environment:
      TZ: ${TZ}
      DB_HOSTNAME: shared-postgres
      DB_PORT: 5432
      DB_DATABASE_NAME: ${IMMICH_DB_NAME}
      DB_USERNAME: ${IMMICH_DB_USER}
      DB_PASSWORD: ${IMMICH_DB_PASS}
      REDIS_HOSTNAME: shared-redis
      REDIS_PORT: 6379
      REDIS_PASSWORD: ${REDIS_PASSWORD}
      IMMICH_LOG_LEVEL: log
      NVIDIA_VISIBLE_DEVICES: all
      NVIDIA_DRIVER_CAPABILITIES: all
    volumes:
      - /mnt/unraid/immich:/data
      - /mnt/docker-ssd/docker/appdata/immich:/config
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu, video, compute]
    healthcheck:
      test: ["CMD-SHELL", "curl -sf http://127.0.0.1:2283/api/server/ping || exit 1"]
      interval: 30s
      timeout: 10s
      retries: 5
      start_period: 60s
    depends_on:
      immich-ml:
        condition: service_started

  immich-ml:
    container_name: ix-immich-immich-machine-learning-1
    image: ghcr.io/immich-app/immich-machine-learning:release
    restart: unless-stopped
    networks:
      - photos-net
      - ix-databases_shared-databases
    environment:
      TZ: ${TZ}
      DB_HOSTNAME: shared-postgres
      DB_PORT: 5432
      DB_DATABASE_NAME: ${IMMICH_DB_NAME}
      DB_USERNAME: ${IMMICH_DB_USER}
      DB_PASSWORD: ${IMMICH_DB_PASS}
      REDIS_HOSTNAME: shared-redis
      REDIS_PORT: 6379
      REDIS_PASSWORD: ${REDIS_PASSWORD}
      DEVICE: cuda
      NVIDIA_VISIBLE_DEVICES: all
      NVIDIA_DRIVER_CAPABILITIES: all
      TRANSFORMERS_CACHE: /cache
      MACHINE_LEARNING_CACHE_FOLDER: /cache
    volumes:
      - /mnt/docker-ssd/docker/appdata/immich-ml:/cache
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]
    healthcheck:
      test: ["CMD-SHELL", "cat /proc/net/tcp6 | grep -q BBB || exit 1"]
      interval: 30s
      timeout: 10s
      retries: 5
      start_period: 120s
