services:
  immich-server:
    extends:
      file: ${TEMPLATES_PATH}
      service: default
    container_name: immich_server
    image: ghcr.io/immich-app/immich-server:v2.6.3
    environment:
      DB_PASSWORD: ${IMMICH_DB_PASSWORD}
      DB_HOSTNAME: postgres-with-pg-vector
      DB_USERNAME: immich
      DB_DATABASE_NAME: immich
      REDIS_HOSTNAME: redis
    volumes:
      # to mount the trueNas external library: sudo mount 192.168.178.36:/mnt/hdd-storage/vm-external-storage/immich /mnt/external-storage/immich/
      - ${IMMICH_EXTERNAL_PATH}:/usr/src/app/external:ro
      - ${MEDIA_PATH}/immich/data/library:/usr/src/app/upload
      - /etc/localtime:/etc/localtime:ro
    ports:
      - 2283:3001
    networks:
      - ip6net
    labels:
      # Traefik
      - "traefik.enable=true"
      - "traefik.http.routers.immich-server.rule=Host(`immich.${PUBLIC_DOMAIN}`)"
      - "traefik.http.routers.immich-server.entrypoints=https"
      - "traefik.http.routers.immich-server.tls=true"

  immich-machine-learning:
    extends:
      file: ${TEMPLATES_PATH}
      service: default
    container_name: immich_machine_learning
    image: ghcr.io/immich-app/immich-machine-learning:v2.6.3
    ports:
      - 3003:3003
    volumes:
      - ${MEDIA_PATH}/immich/data/model-cache:/cache

  # https://github.com/Salvoxia/immich-folder-album-creator
  # one time run:
  # docker run -e -e API_URL="https://immich.${PUBLIC_DOMAIN}/api/" -e API_KEY="qTaebdVMtph9yD0pSJRJDQJkDEpexiXNMJ5V5HBEnA" -e ROOT_PATH="/usr/src/app/external" -e LOG_LEVEL="DEBUG" salvoxia/immich-folder-album-creator:latest /script/immich_auto_album.sh
  immich-folder-album-creator:
    extends:
      file: ${TEMPLATES_PATH}
      service: default
    container_name: immich_folder_album_creator
    image: salvoxia/immich-folder-album-creator:0.25.2
    environment:
      API_URL: https://immich.${PUBLIC_DOMAIN}/api
      API_KEY: qTaebdVMtph9yD0pSJRJDQJkDEpexiXNMJ5V5HBEnA
      ROOT_PATH: /usr/src/app/external
      CRON_EXPRESSION: "0 * * * *"
      LOG_LEVEL: DEBUG
      #RUN_IMMEDIATELY: true
      #UNATTENDED: 1
    volumes:
      - /usr/src/app/external:/usr/src/app/external
