services:
  immich-postgres:
    image: tensorchord/pgvecto-rs:pg16-v0.3.0
    restart: unless-stopped
    environment:
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: ${IMMICH_DB_NAME:-immich}
    volumes:
      - immich_postgres_data:/var/lib/postgresql/data
    networks:
      - ulti-net
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
      interval: 10s
      timeout: 5s
      retries: 5
      start_period: 20s

  immich-server:
    image: ghcr.io/immich-app/immich-server:v1.120.0
    restart: unless-stopped
    environment:
      - DB_HOSTNAME=immich-postgres
      - DB_USERNAME=${POSTGRES_USER}
      - DB_PASSWORD=${POSTGRES_PASSWORD}
      - DB_DATABASE_NAME=${IMMICH_DB_NAME:-immich}
      - REDIS_HOSTNAME=keydb
      - REDIS_PORT=6379
      - IMMICH_MACHINE_LEARNING_URL=http://immich-ml:3003
      - UPLOAD_LOCATION=/upload
    volumes:
      - immich_upload:/upload
    networks:
      - ulti-net
    depends_on:
      immich-postgres:
        condition: service_healthy
      keydb:
        condition: service_started

  immich-ml:
    image: ghcr.io/immich-app/immich-machine-learning:v1.120.0
    restart: unless-stopped
    volumes:
      - immich_model_cache:/cache
    networks:
      - ulti-net

volumes:
  immich_upload:
  immich_model_cache:
  immich_postgres_data:
