Last active
September 16, 2025 20:53
-
-
Save carlchan/cb599b3c174d5cd2c1d927c93a9dbbd6 to your computer and use it in GitHub Desktop.
Scalable Docker Swarm compose file for Immich, workloads split between GPU and CPU nodes, each container running as non-root
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # WARNING: To install Immich, follow our guide: https://immich.app/docs/install/docker-compose | |
| # | |
| # Make sure to use the docker-compose.yml of the current release: | |
| # | |
| # https://github.com/immich-app/immich/releases/latest/download/docker-compose.yml | |
| # | |
| # The compose file on main may not be compatible with the latest release. | |
| services: | |
| immich-server: | |
| image: ghcr.io/immich-app/immich-server:release | |
| user: 2000001:2000001 | |
| volumes: | |
| - immich-upload:/data #Main Immich data | |
| - archives:/archives:ro #External Library | |
| - /etc/localtime:/etc/localtime:ro | |
| env_file: | |
| - immich.env | |
| environment: | |
| IMMICH_WORKERS_INCLUDE: 'api' | |
| #Exposed via traefik, no need to expose directly | |
| # ports: | |
| # - '2283:2283' | |
| depends_on: | |
| - redis | |
| healthcheck: | |
| disable: false | |
| networks: | |
| - traefik_proxy | |
| - immich | |
| deploy: | |
| mode: global | |
| # placement: | |
| # constraints: | |
| # - node.role == manager | |
| # - node.labels.gpu == true | |
| resources: | |
| reservations: | |
| memory: 2G | |
| cpus: '4' | |
| labels: | |
| - "traefik.enable=true" | |
| - "traefik.http.routers.immich-ui-https.tls.certresolver=letsencrypt" | |
| - "traefik.http.routers.immich-ui-https.rule=Host(`externalhostname.example.com`) || Host(`internalhostname.example.com`)" | |
| - "traefik.http.routers.immich-ui-https.entrypoints=websecure" | |
| - "traefik.http.routers.immich-ui-https.service=immich-ui" | |
| - "traefik.http.services.immich-ui.loadbalancer.server.port=2283" | |
| immich-server-microservices: | |
| image: ghcr.io/immich-app/immich-server:release | |
| user: 2000001:2000001 | |
| volumes: | |
| - immich-upload:/data | |
| - archives:/archives:ro | |
| - /etc/localtime:/etc/localtime:ro | |
| env_file: | |
| - immich.env | |
| environment: | |
| IMMICH_WORKERS_EXCLUDE: 'api' | |
| depends_on: | |
| - redis | |
| # restart: always | |
| healthcheck: | |
| disable: false | |
| networks: | |
| - traefik_proxy | |
| - immich | |
| deploy: | |
| mode: global | |
| placement: | |
| constraints: | |
| - node.role == worker | |
| - node.labels.gpu == true | |
| resources: | |
| reservations: | |
| memory: 4G | |
| cpus: '4' | |
| generic_resources: | |
| - discrete_resource_spec: | |
| kind: 'NVIDIA-GPU-ImmichServer' | |
| value: 0 | |
| #Cuda and CPU machine learning containers both aliased to "immich-ml" | |
| #Configure ML endpoint in Immich to http://immich-ml:3003 and it will loadbalance to both | |
| immich-machine-learning-cuda: | |
| image: ghcr.io/immich-app/immich-machine-learning:release-cuda | |
| user: 2000001:2000001 | |
| volumes: | |
| - model-cache:/cache | |
| env_file: | |
| - immich.env | |
| healthcheck: | |
| disable: false | |
| networks: | |
| immich: | |
| aliases: | |
| - immich-ml | |
| deploy: | |
| mode: replicated | |
| replicas: 1 | |
| placement: | |
| constraints: | |
| - node.labels.gpu == true | |
| resources: | |
| reservations: | |
| generic_resources: | |
| - discrete_resource_spec: | |
| kind: 'NVIDIA-GPU-ImmichML' | |
| value: 0 | |
| immich-machine-learning-cpu: | |
| # container_name: immich_machine_learning | |
| # For hardware acceleration, add one of -[armnn, cuda, rocm, openvino, rknn] to the image tag. | |
| # Example tag: release-cuda | |
| image: ghcr.io/immich-app/immich-machine-learning:release | |
| user: 2000001:2000001 | |
| volumes: | |
| - model-cache:/cache | |
| env_file: | |
| - immich.env | |
| healthcheck: | |
| disable: false | |
| networks: | |
| immich: | |
| aliases: | |
| - immich-ml | |
| deploy: | |
| mode: replicated | |
| replicas: 1 | |
| placement: | |
| constraints: | |
| - node.role == worker | |
| redis: | |
| image: docker.io/valkey/valkey:8-alpine | |
| user: 2000001:2000001 | |
| command: | |
| - "valkey-server" | |
| - "--io-threads 6" | |
| healthcheck: | |
| test: valkey-cli ping || exit 1 | |
| networks: | |
| - immich | |
| volumes: | |
| - immich-redis:/data | |
| deploy: | |
| mode: replicated | |
| replicas: 1 | |
| placement: | |
| constraints: | |
| - node.role == worker | |
| volumes: | |
| immich-upload: | |
| driver: local | |
| driver_opts: | |
| type: "nfs" | |
| o: "" | |
| device: "" | |
| immich-redis: | |
| driver: local | |
| driver_opts: | |
| type: "nfs" | |
| o: "" | |
| device: "" | |
| archives: | |
| driver: local | |
| driver_opts: | |
| type: "nfs" | |
| o: "" | |
| device: "" | |
| model-cache: | |
| driver: local | |
| driver_opts: | |
| type: "nfs" | |
| o: "" | |
| device: "" | |
| networks: | |
| immich: | |
| traefik_proxy: | |
| external: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment