services:
  immich-database:
    image: tensorchord/pgvecto-rs:pg14-v0.2.0
    environment:
      POSTGRES_DB: immich
      POSTGRES_PASSWORD: wuwwxyxg49s0zdvl
      POSTGRES_USER: immich
    volumes:
     - immich-postgres:/var/lib/postgresql/data
    networks:
     - dokploy-network
    deploy:
      restart_policy:
        condition: on-failure

  immich-machine-learning:
    image: ghcr.io/immich-app/immich-machine-learning:v2.3.0
    volumes:
     - immich-model-cache:/cache
    networks:
     - dokploy-network
    deploy:
      restart_policy:
        condition: on-failure

  immich-redis:
    image: redis:6.2-alpine
    volumes:
     - immich-redis-data:/data
    networks:
     - dokploy-network
    deploy:
      restart_policy:
        condition: on-failure

  immich-server:
    image: ghcr.io/immich-app/immich-server:v2.3.0
    environment:
      DB_DATABASE_NAME: immich
      DB_HOSTNAME: immich-database
      DB_PASSWORD: wuwwxyxg49s0zdvl
      DB_PORT: '5432'
      DB_USERNAME: immich
      FRONT_BASE_URL: https://immich.bendtstudio.com
      REDIS_DBINDEX: '0'
      REDIS_HOSTNAME: immich-redis
      REDIS_PORT: '6379'
      SERVER_URL: https://immich.bendtstudio.com
      IMMICH_HOST: 0.0.0.0
    volumes:
     - /mnt/synology-data/immich:/usr/src/app/upload
     - /mnt/photos:/var/photos
     - /etc/localtime:/etc/localtime:ro
    networks:
     - dokploy-network
    deploy:
      restart_policy:
        condition: on-failure
        delay: 10s
        max_attempts: 10
      placement:
        constraints:
         - node.labels.type == nas
      labels:
        - traefik.enable=true
        - traefik.http.routers.immich-web.rule=Host(`immich.bendtstudio.com`)
        - traefik.http.routers.immich-web.entrypoints=web
        - traefik.http.services.immich-web.loadbalancer.server.port=2283
        - traefik.http.routers.immich-web.service=immich-web
        - traefik.http.routers.immich-web.middlewares=redirect-to-https@file
        - traefik.http.routers.immich-websecure.rule=Host(`immich.bendtstudio.com`)
        - traefik.http.routers.immich-websecure.entrypoints=websecure
        - traefik.http.services.immich-websecure.loadbalancer.server.port=2283
        - traefik.http.routers.immich-websecure.service=immich-websecure
        - traefik.http.routers.immich-websecure.tls.certresolver=letsencrypt
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:2283/api/server/ping"]
      interval: 30s
      timeout: 20s
      retries: 10
      start_period: 120s

volumes:
  immich-redis-data:
  immich-postgres:
  immich-model-cache:

networks:
  dokploy-network:
    external: true
