Deploying an Immich App
Introduction
Immich is an open-source, self-hosted photo and video backup platform built with NestJS and TypeScript. Deploying Immich with a Dockerfile on Klutch.sh delivers reproducible builds, managed secrets, and persistent storage for media—all from klutch.sh/app. This guide covers installation, repository prep, a production-ready Dockerfile, deployment steps, Nixpacks overrides, and best practices for performance and durability.
Prerequisites
- A Klutch.sh account (create one)
- A GitHub repository containing your Immich code/config (GitHub is the only supported git source)
- Docker familiarity and Node.js 18+ for local testing
- PostgreSQL (with PostGIS) and Redis credentials
- Adequate persistent storage for photo/video uploads
For platform onboarding, see the Quick Start.
Architecture and ports
- Immich’s API and web UI run over HTTP; set the internal container port to
3001(common for the NestJS server). - PostgreSQL + PostGIS and Redis should run as separate Klutch.sh TCP apps. Expose them on port
8000and connect internally on5432(Postgres) and6379(Redis). - Persistent storage is required for
upload(media) and recommended for cache/thumbnails.
Repository layout
immich/├── apps/server/ # NestJS backend├── apps/web/ # Next.js web client├── upload/ # Media storage (mount as volume)├── Dockerfile # Must be at repo root for auto-detection├── package.json├── pnpm-lock.yaml # or yarn.lock / package-lock.json├── .env.example # Template only; no secrets└── README.mdKeep secrets out of Git; store them in Klutch.sh environment variables.
Installation (local) and starter commands
Install dependencies and test locally before pushing to GitHub:
pnpm installpnpm buildpnpm start --filter @immich/server -- --port 3001If you use migrations, add:
pnpm prisma migrate deployOptional helper start.sh for portability and Nixpacks fallback:
#!/usr/bin/env bashset -euo pipefailpnpm prisma migrate deploy || truepnpm start --filter @immich/server -- --port 3001Make it executable with chmod +x start.sh.
Dockerfile for Immich (production-ready)
Place this Dockerfile at the repo root; Klutch.sh auto-detects it (no Docker toggle in the UI):
FROM node:18-alpine AS buildWORKDIR /app
COPY package.json pnpm-lock.yaml* yarn.lock* package-lock.json* ./RUN corepack enableRUN pnpm install --frozen-lockfile
COPY . .RUN pnpm build
FROM node:18-alpineWORKDIR /appENV NODE_ENV=production PORT=3001
COPY --from=build /app /appRUN corepack enable && pnpm install --prod --frozen-lockfile
EXPOSE 3001CMD ["pnpm", "start", "--filter", "@immich/server", "--", "--port", "3001"]Notes:
- If you need native dependencies (e.g.,
sharp), add build tools in the build stage:apk add --no-cache python3 make g++. - Keep
upload/writable and mount it as a volume for media durability.
Environment variables (Klutch.sh)
Set these in the Klutch.sh app settings (Secrets tab) before deploying:
NODE_ENV=productionPORT=3001APP_BASE_URL=https://example-app.klutch.shDATABASE_URL=postgres://<user>:<password>@<host>:<port>/<db>REDIS_URL=redis://<user>:<password>@<host>:<port>IMMICH_UPLOAD_LOCATION=/app/uploadJWT_SECRET=<jwt-secret>IMMICH_ENABLE_MAP=true(optional feature flag)
If you deploy without the Dockerfile and need Nixpacks overrides:
NIXPACKS_BUILD_CMD=pnpm install --frozen-lockfile && pnpm buildNIXPACKS_START_CMD=pnpm start --filter @immich/server -- --port 3001NIXPACKS_NODE_VERSION=18
These keep Immich compatible with Nixpacks defaults when a Dockerfile is absent.
Attach persistent volumes
In Klutch.sh storage settings, add mount paths and sizes (no names required):
/app/upload— required for photos/videos./app/.cache— optional for cached thumbnails if your build writes there.
Ensure these paths are writable inside the container.
Deploy Immich on Klutch.sh (Dockerfile workflow)
- Push your repository (with the Dockerfile at the root) to GitHub.
- Open klutch.sh/app, create a project, and add an app.
- Connect the GitHub repository; Klutch.sh automatically detects the Dockerfile.
- Choose HTTP traffic for Immich.
- Set the internal port to
3001. - Add the environment variables above (database, Redis, upload path, JWT secret, and any
NIXPACKS_*overrides if you temporarily deploy without the Dockerfile). - Attach persistent volumes for
/app/upload(and/app/.cacheif used), selecting sizes that fit your media retention plan. - Deploy. Your Immich instance will be reachable at
https://example-app.klutch.sh; attach a custom domain if desired.
For PostgreSQL/PostGIS or Redis on Klutch.sh, create separate TCP apps, expose them on port 8000, and point DATABASE_URL or REDIS_URL to those endpoints (internal ports 5432/6379).
Health checks and production tips
- Add a lightweight
/healthendpoint that checks DB/Redis connectivity. - Enable HTTPS at the edge; forward HTTP to port 3001 internally.
- Monitor volume usage for
/app/uploadand resize before it fills. - Keep lockfiles committed and Node versions pinned for reproducible builds.
- Back up your database and media regularly; do not rely on container filesystems for durability.
Immich on Klutch.sh combines reproducible Docker builds with managed secrets, persistent media storage, and flexible HTTP/TCP routing. With the Dockerfile at the repo root and ports set to 3001 for the app (8000 externally for TCP databases or caches), you can deliver a reliable, self-hosted photo and video experience without extra YAML or workflow overhead.