services:
  immich-server:
    container_name: immich-server
    image: ghcr.io/immich-app/immich-server:v2.7.5
    restart: unless-stopped
    networks:
      - homelab-network
    security_opt:
      - no-new-privileges:true
    devices:
      - /dev/dri:/dev/dri
    volumes:
      - ~/docker-volumes/immich/images:/usr/src/app/upload
      - /etc/localtime:/etc/localtime:ro
    ports:
      - 2090:2283
    depends_on:
      - immich-redis
      - immich-postgres
    environment:
      - IMMICH_VERSION=v2.3.1
      - TZ=Africa/Nairobi
      - REDIS_HOSTNAME=immich-redis
      - REDIS_PORT=6379
      - REDIS_PASSWORD=${IMMICH_REDIS_PASSWORD}
      - DB_HOSTNAME=immich-postgres
      - DB_PORT=5432
      - DB_USERNAME=${IMMICH_POSTGRES_USER}
      - DB_PASSWORD=${IMMICH_POSTGRES_PASSWORD}
      - DB_DATABASE_NAME=${IMMICH_POSTGRES_DB}
    deploy:
      resources:
        limits:
          memory: 4G
        reservations:
          memory: 2G
    healthcheck:
      disable: false

  immich-machine-learning:
    container_name: immich-machine-learning
    image: ghcr.io/immich-app/immich-machine-learning:v2.7.5
    restart: unless-stopped
    networks:
      - homelab-network
    security_opt:
      - no-new-privileges:true
    volumes:
      - ~/docker-volumes/immich/cache:/cache
    healthcheck:
      disable: false
    devices:
      - /dev/dri:/dev/dri

  immich-postgres:
    container_name: immich-postgres
    image: ghcr.io/immich-app/postgres:14-vectorchord0.4.3-pgvectors0.2.0
    restart: unless-stopped
    networks:
      - homelab-network
    security_opt:
      - no-new-privileges:true
    environment:
      - POSTGRES_PASSWORD=${IMMICH_POSTGRES_PASSWORD}
      - POSTGRES_USER=${IMMICH_POSTGRES_USER}
      - POSTGRES_DB=${IMMICH_POSTGRES_DB}
      - POSTGRES_INITDB_ARGS="--data-checksums"
      - DB_STORAGE_TYPE=HDD
    volumes:
      - ~/docker-volumes/immich/postgres-data:/var/lib/postgresql/data

  immich-redis:
    container_name: immich-redis
    image: redis:7.2.5
    restart: unless-stopped
    networks:
      - homelab-network
    security_opt:
      - no-new-privileges:true
    command: /bin/sh -c "redis-server --requirepass ${IMMICH_REDIS_PASSWORD}"
    volumes:
      - ~/docker-volumes/immich/redis:/data
    ports:
      - 6379:6379
    environment:
      - REDIS_PASSWORD=${IMMICH_REDIS_PASSWORD}
