安裝 Immich (取代 Google 相簿)
- VM : 2vCore / 4GRAM / 32GSSD
- OS : Alpine 3 參考 - 在 Alpine Linux 3 底下安裝 docker + docker-compose
安裝程序
- 採用 nfs 方式將 LocalPhotos
//192.168.11.252/pbs-zpool/nfsshare/immich掛入
/nfs-immich- 處理程序:
apk add nfs-utils mkdir -p /nfs-immich mount -o nfsvers=4 -t nfs 192.168.11.252:/pbs-zpool/immich /nfs-immich
- 如果可以正確掛上 /nfs-immich 看到 NAS 內的檔案, 就可以設定開機自動掛上
rc-update add nfsmount default echo "192.168.11.252:/pbs-zpool/immich /nfs-immich nfs rw 0 0" >> /etc/fstab
- 使用 Docker Compose 進行安裝
wget https://raw.githubusercontent.com/tryweb/docker-compose/refs/heads/main/immich/docker-compose.yml wget https://raw.githubusercontent.com/tryweb/docker-compose/refs/heads/main/immich/.env
docker-compose.yml
services: immich-server: container_name: immich_server image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release} volumes: - ${UPLOAD_LOCATION}:/usr/src/app/upload #- /nas-246-Photos:/mnt/media/nas-246-Photos:ro env_file: - .env ports: - 2283:2283 depends_on: redis: condition: service_started database: condition: service_healthy restart: always immich-machine-learning: container_name: immich_machine_learning image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release} volumes: - model-cache:/cache env_file: - .env restart: always redis: container_name: immich_redis image: redis:alpine environment: TZ: 'Asia/Taipei' healthcheck: test: redis-cli ping || exit 1 restart: always database: container_name: immich_postgres image: ghcr.io/immich-app/postgres:14-vectorchord0.4.2-pgvectors0.2.0 env_file: - .env environment: TZ: 'Asia/Taipei' POSTGRES_PASSWORD: ${DB_PASSWORD} POSTGRES_USER: ${DB_USERNAME} POSTGRES_DB: ${DB_DATABASE_NAME} POSTGRES_INITDB_ARGS: '--data-checksums' volumes: - pgdata:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U ${DB_USERNAME} -d ${DB_DATABASE_NAME}"] interval: 10s timeout: 5s retries: 5 restart: always volumes: pgdata: model-cache:https://raw.githubusercontent.com/tryweb/docker-compose/refs/heads/main/immich/docker-compose.yml
.env
# Immich Environment Variables TZ=Asia/Taipei # Upload location UPLOAD_LOCATION=./upload # Database Configuration DB_HOSTNAME=database DB_USERNAME=immich DB_PASSWORD=immich DB_DATABASE_NAME=immich # Redis Configuration REDIS_HOSTNAME=redis # Machine Learning Configuration MACHINE_LEARNING_WORKER_ENABLED=true MACHINE_LEARNING_CACHE_FOLDER=/cache MACHINE_LEARNING_HOSTNAME=immich-machine-learning # Server Configuration NODE_ENV=production LOG_LEVEL=info # JWT Secret JWT_SECRET=your_jwt_secret_key_here
https://raw.githubusercontent.com/tryweb/docker-compose/refs/heads/main/immich/.env
- 修改 .env 內的密碼與網址設定
: UPLOAD_LOCATION=/nfs-immich/upload : DB_USERNAME=immich DB_PASSWORD=MyDb_Password DB_DATABASE_NAME=immich : JWT_SECRET=your_jwt_xxxxxxxxxxx-secret_key_here
- 啟動服務
docker-compose up -d
常見問題
1. 中文搜尋結果不理想問題
- 主要是預設的 CLIP 模型 ViT-B-32__openai 中文支援度低, 需要更換支援多語言的模型 Exp. XLM-Roberta-Large-Vit-B-16Plus
- 處理方式如下
- 找到 immich 的模型存放目錄 Exp. /var/lib/docker/volumes/root_model-cache/_data/
- 找到 Hugging Face 模型頁面 Exp. https://huggingface.co/immich-app/XLM-Roberta-Large-Vit-B-16Plus
- 透過 git 方式將模型下載到存放目錄 Exp.
cd clip git clone https://huggingface.co/immich-app/XLM-Roberta-Large-Vit-B-16Plus
- 重起服務
docker compose down && docker compose up -d - 進入 immich 管理介面修改使用模型設定
- 設定 → 機器學習設定 → 智慧搜尋 → CLIP 模型 改成 XLM-Roberta-Large-Vit-B-16Plus
- 重新執行全部智慧搜尋項目 : 任務 → 智慧搜尋 → 全部
2. 設定 Google oAuth 認證方式
- Google 端設定
- 建立或選擇一個專案 Exp. ichiayi → 選擇 API 和服務 → oAuth 同意畫面
- Google Auth Platform → 用戶端 → 建立用戶端
- 應用程式類型 : 網頁應用程式
- 名稱 : Exp. immich
- 已授權的 JavaScript 來源 : Exp. https://your-server-domain-name
- 已授權的重新導向 URI : Exp. https://your-server-domain-name/auth/login 與 https://your-server-domain-name/user-settings (如果要支援行動 APP 還要加上 https://your-server-domain-name/api/oauth/mobile-redirect )
- 將產生的 ClientID 與 ClientSecret 記錄下來
- Immich 端系統管理設定
- admin → 設定 → 驗證設定 → oAuth
- 使用 OAuth 登入 : 開啟
- ISSUER_URL : https://accounts.google.com
- CLIENT_ID : 填上 Google 端產生的 ClientID Exp. 51xxxxxxx0-9xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxv.apps.googleusercontent.com
- CLIENT_SECRET : 填上 Google 端產生的 ClientSecret Exp. Gxxxxx-UxxxxxxxxxxPB_4xxxxxxxxxxxxz
- TOKEN_ENDPOINT_AUTH_METHOD : 選 client_secret_post
- SCOPE : openid email profile
- ID_TOKEN_SIGNED_RESPONSE_ALG : RS256
- USERINFO_SIGNED_RESPONSE_ALG : none
- 請求逾時 : 30000
- 儲存標籤宣告 : preferred_username
- 角色宣告 : immich_role
- 儲存配額宣告 : immich_quota
- 按鈕文字 : Login with OAuth
- 自動註冊 : 關閉 (避免閒雜人等加入使用) → 表示系統管理者需要先建立使用者 Exp. Google 帳號 [email protected] 後, 這 Google 帳號才能透過 Google oAuth 方式登入 Immich
- 自動啟動 : 關閉
- 覆蓋行動端重新導向 URI : 啟用 (如果要支援行動 APP)
- 行動端重新導向 URI : https://your-server-domain-name/api/oauth/mobile-redirect (如果要支援行動 APP)
3. 已經存在的使用者設定連結 Google oAuth 認證方式
- 之前已經建立的使用者 Exp. [email protected] 想要使用 Google oAuth 帳號 Exp. [email protected] 登入
- 先使用原本 [email protected] 登入 Immich 網站
- 點右上角 ICON → 帳號設定
- 2FR OAuth → 點連接 OAuth
- 會跳出 Google oAuth 帳號登入畫面進行登入 Exp. [email protected]
- 登出後, 在登入畫面選 Login with OAuth
- 跳出 Google oAuth 帳號登入畫面進行登入 Exp. [email protected]
- 登入後看到的是原本 [email protected] 的照片資料

