majorfi/immich-stackAutomatically groups similar photos into stacks within the Immich photo management system.
bash# Create a .env file cat > .env << EOL API_KEY=your_immich_api_key API_URL=[***] RUN_MODE=cron CRON_INTERVAL=60 EOL # Run with Docker (using Docker Hub) docker run -d --name immich-stack --env-file .env -v ./logs:/app/logs majorfi/immich-stack:latest # Or using GitHub Container Registry docker run -d --name immich-stack --env-file .env -v ./logs:/app/logs ghcr.io/majorfi/immich-stack:latest
| Variable | Description | Default |
|---|---|---|
API_KEY | Your Immich API key | (required) |
API_URL | Immich API URL | [***] |
RUN_MODE | Run mode (once or cron) | once |
CRON_INTERVAL | Interval in seconds for cron mode | 86400 |
DRY_RUN | Don't apply changes | false |
RESET_STACKS | Delete all existing stacks | false |
REPLACE_STACKS | Replace stacks for new groups | false |
PARENT_FILENAME_PROMOTE | Parent filename promote | edit |
PARENT_EXT_PROMOTE | Parent extension promote | .jpg,.dng |
WITH_ARCHIVED | Include archived assets | false |
WITH_DELETED | Include deleted assets | false |
yamlversion: "3.8" services: immich-stack: container_name: immich_stack # Use Docker Hub image (recommended for Portainer) image: majorfi/immich-stack:latest # Or use GitHub Container Registry # image: ghcr.io/majorfi/immich-stack:latest environment: - API_KEY=${API_KEY} - API_URL=${API_URL:-[***]} - DRY_RUN=${DRY_RUN:-false} - RESET_STACKS=${RESET_STACKS:-false} - REPLACE_STACKS=${REPLACE_STACKS:-false} - PARENT_FILENAME_PROMOTE=${PARENT_FILENAME_PROMOTE:-edit} - PARENT_EXT_PROMOTE=${PARENT_EXT_PROMOTE:-.jpg,.dng} - WITH_ARCHIVED=${WITH_ARCHIVED:-false} - WITH_DELETED=${WITH_DELETED:-false} - RUN_MODE=${RUN_MODE:-once} - CRON_INTERVAL=${CRON_INTERVAL:-86400} volumes: - ./logs:/app/logs restart: on-failure
bash# Build locally docker build -t immich-stack . # Run locally docker run -d \ --name immich-stack \ --env-file .env \ -v ./logs:/app/logs \ immich-stack
Immich Stack is a Go CLI tool and library for automatically grouping ("stacking") similar photos in the Immich photo management system. It provides configurable, robust, and extensible logic for grouping, sorting, and managing photo stacks via the Immich API. This project is heavily inspired by immich-auto-stack.
Clone the repository:
shgit clone [***] cd immich-stack
Build the binary:
shgo build -o immich-stack ./cmd/main.go
Move the binary to your PATH (optional):
shsudo mv immich-stack /usr/local/bin/
Clone the repository:
shgit clone [***] cd immich-stack
Create a .env file from the example:
shcp .env.example .env
Edit the .env file with your Immich credentials and preferences:
sh# Required API_KEY=your_immich_api_key API_URL=[***] # Optional - Default values shown DRY_RUN=false RESET_STACKS=false REPLACE_STACKS=false PARENT_FILENAME_PROMOTE=edit PARENT_EXT_PROMOTE=.jpg,.dng WITH_ARCHIVED=false WITH_DELETED=false # Run mode settings RUN_MODE=once # Options: once, cron CRON_INTERVAL=86400 # in seconds, only used if RUN_MODE=cron
Start the service:
shdocker compose up -d
To run in cron mode, set RUN_MODE=cron in your .env file and restart:
shdocker compose down docker compose up -d
To view logs:
shdocker compose logs -f
To stop the service:
shdocker compose down
To integrate with an existing Immich installation:
Copy the immich-stack service from our docker-compose.yml into your Immich's docker-compose.yml
Add these environment variables to your Immich's .env file (you can also add the optional ones):
sh# Immich Stack settings API_KEY=your_immich_api_key API_URL=[***] # Use internal Docker network RUN_MODE=once # Options: once, cron CRON_INTERVAL=86400 # in seconds, only used if RUN_MODE=cron
Add the service dependency in Immich's docker-compose.yml:
yamlimmich-stack: container_name: immich_stack image: ghcr.io/majorfi/immich-stack:latest environment: - API_KEY=${API_KEY} - API_URL=${API_URL:-[***]} - DRY_RUN=${DRY_RUN:-false} - RESET_STACKS=${RESET_STACKS:-false} - REPLACE_STACKS=${REPLACE_STACKS:-false} - PARENT_FILENAME_PROMOTE=${PARENT_FILENAME_PROMOTE:-edit} - PARENT_EXT_PROMOTE=${PARENT_EXT_PROMOTE:-.jpg,.dng} - WITH_ARCHIVED=${WITH_ARCHIVED:-false} - WITH_DELETED=${WITH_DELETED:-false} - RUN_MODE=${RUN_MODE:-once} - CRON_INTERVAL=${CRON_INTERVAL:-86400} volumes: - ./logs:/app/logs restart: on-failure depends_on: immich-server: condition: service_healthy
Restart your Immich stack:
shdocker compose down docker compose up -d
Create a .env file in your working directory with your Immich credentials:
shAPI_KEY=your_immich_api_key API_URL=[***]
Run the stacker:
sh# Using the binary ./immich-stack # Or if installed in PATH immich-stack
Optional: Configure additional options via environment variables or flags:
sh# Example with flags ./immich-stack --dry-run --parent-filename-promote=edit --parent-ext-promote=.jpg,.dng --with-archived --with-deleted # Or using environment variables export DRY_RUN=true export PARENT_FILENAME_PROMOTE=edit export PARENT_EXT_PROMOTE=.jpg,.dng export WITH_ARCHIVED=true export WITH_DELETED=true ./immich-stack
immich-auto-stack/ ├── cmd/ # CLI entrypoint (main.go) ├── pkg/ │ ├── stacker/ # Stacking logic, types, and tests │ ├── immich/ # Immich API client and integration │ └── utils/ # Utility helpers and logging
The main entrypoint is cmd/main.go, which provides a Cobra-based CLI:
shgo run ./cmd/main.go --api-key <API_KEY> --api-url <API_URL> [flags]
| Flag | Env Var | Description |
|---|---|---|
--api-key | API_KEY | Immich API key |
--api-url | API_URL | Immich API base URL |
--reset-stacks | RESET_STACKS | Delete all existing stacks before processing |
--replace-stacks | REPLACE_STACKS | Replace stacks for new groups |
--dry-run | DRY_RUN | Simulate actions without making changes |
--criteria | CRITERIA | Custom grouping criteria |
--parent-filename-promote | PARENT_FILENAME_PROMOTE | Substrings to promote as parent filenames |
--parent-ext-promote | PARENT_EXT_PROMOTE | Extensions to promote as parent files |
--with-archived | WITH_ARCHIVED | Include archived assets in processing |
--with-deleted | WITH_DELETED | Include deleted assets in processing |
--run-mode | RUN_MODE | Run mode: "once" (default) or "cron" |
--cron-interval | CRON_INTERVAL | Interval in seconds for cron mode |
--reset-stacks is set, user confirmation is required.--criteria flag or CRITERIA environment variable.--parent-filename-promote or PARENT_FILENAME_PROMOTE (comma-separated substrings) to promote files as stack parents.--parent-ext-promote or PARENT_EXT_PROMOTE (comma-separated extensions) to further prioritize..jpeg > .jpg > .png > others.For files: L***.JPG, L***.edit.jpg, L***.DNG
With PARENT_FILENAME_PROMOTE=edit and PARENT_EXT_PROMOTE=.jpg,.dng in your .env file, or with --parent-filename-promote=edit and --parent-ext-promote=.jpg,.dng, the order will be:
L***.edit.jpg L***.JPG L***.DNG
Asset, Stack, Criteria, etc.pkg/stacker/stacker_test.go and pkg/immich/client_test.go.shgo test ./pkg/...
--parent-filename-promote and/or --parent-ext-promote for your workflow.pkg/immich/client.go for new Immich endpoints.MIT


探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
在 Linux 系统配置镜像服务
在 Docker Desktop 配置镜像
Docker Compose 项目配置
Kubernetes 集群配置 Containerd
K3s 轻量级 Kubernetes 镜像加速
在宝塔面板一键配置镜像
Synology 群晖 NAS 配置
飞牛 fnOS 系统配置镜像
极空间 NAS 系统配置服务
爱快 iKuai 路由系统配置
绿联 NAS 系统配置镜像
QNAP 威联通 NAS 配置
Podman 容器引擎配置
HPC 科学计算容器配置
ghcr、Quay、nvcr 等镜像仓库
无需登录使用专属域名
需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单
免费版仅支持 Docker Hub 访问,不承诺可用性和速度;专业版支持更多镜像源,保证可用性和稳定速度,提供优先客服响应。
专业版支持 docker.io、gcr.io、ghcr.io、registry.k8s.io、nvcr.io、quay.io、mcr.microsoft.com、docker.elastic.co 等;免费版仅支持 docker.io。
当返回 402 Payment Required 错误时,表示流量已耗尽,需要充值流量包以恢复服务。
通常由 Docker 版本过低导致,需要升级到 20.x 或更高版本以支持 V2 协议。
先检查 Docker 版本,版本过低则升级;版本正常则验证镜像信息是否正确。
使用 docker tag 命令为镜像打上新标签,去掉域名前缀,使镜像名称更简洁。
来自真实用户的反馈,见证轩辕镜像的优质服务