version: '3.9'

services:
  immich_server:
    image: ghcr.io/immich-app/immich-server:v1.119.0
    environment:
      DB_HOST: postgresql_primary
      DB_PORT: 5432
      DB_USERNAME: postgres
      DB_PASSWORD_FILE: /run/secrets/pg_root_password
      DB_DATABASE_NAME: immich
    secrets:
      - pg_root_password
    networks:
      - traefik-public
      - database-network
    volumes:
      - immich_data:/usr/src/app/upload
    deploy:
      labels:
        - traefik.enable=true
        - traefik.http.routers.immich.rule=Host(`immich.localhost`)
        - traefik.http.routers.immich.entrypoints=websecure
        - traefik.http.routers.immich.tls=true
        - traefik.http.services.immich.loadbalancer.server.port=3001

  immich_machine_learning:
    image: ghcr.io/immich-app/immich-machine-learning:v1.119.0
    deploy:
      resources:
        reservations:
          devices:
          - capabilities: [gpu]
            device_ids: ["0"]
    volumes:
      - immich_ml:/cache

volumes:
  immich_data:
    driver: local
    driver_opts:
      type: nfs
      o: addr=omv800.local,nolock,soft,rw
      device: :/export/immich/data
  immich_ml:
    driver: local

secrets:
  pg_root_password:
    external: true

networks:
  traefik-public:
    external: true
  database-network:
    external: true
