Files
immich-redaktions-plugin/docs/operations.md
T

4.2 KiB

Operations Runbook: Immich Redaktionsportal

This guide documents production deployment, operations, security practices, backup/restore procedures, and maintenance for the Immich Redaktionsportal.


1. Production Architecture Overview

The portal runs as a self-hosted Next.js standalone container alongside a dedicated PostgreSQL 17 database.

  • App Server: Next.js 16 (Node.js 24 LTS, standalone output).
  • Database: PostgreSQL 17 (isolated database, separate from Immich).
  • Immich Integration: Isolated via server-only Immich API adapter using an administrator API key.
  • Mail: Nodemailer via SMTP (TLS / STARTTLS).

2. Environment Configuration

All production configuration is provided via environment variables (e.g. .env or Docker secrets).

Variable Description Example / Notes
DATABASE_URL PostgreSQL connection string postgres://portal:pass@portal-db:5432/portal
BETTER_AUTH_SECRET 32+ character random secret openssl rand -hex 32
BETTER_AUTH_URL Public base URL of the portal https://presse.example.de
IMMICH_BASE_URL Internal URL to Immich server http://immich-server:2283
IMMICH_API_KEY Restricted Immich API key API key of dedicated Immich service user
SMTP_HOST Outbound mail server hostname smtp.infomaniak.com
SMTP_PORT Outbound mail server port 587 (STARTTLS) or 465 (SSL)
SMTP_USER SMTP username portal@example.de
SMTP_PASSWORD SMTP password Confidential
SMTP_FROM Default From email address Leon Tonhäuser Presse <portal@example.de>
LEGAL_IMPRINT_URL Public Impressum link https://example.de/impressum
LEGAL_PRIVACY_URL Public Datenschutz link https://example.de/datenschutz
LEGAL_TERMS_URL Public Nutzungsbedingungen link https://example.de/terms

3. Reverse Proxy & Streaming Configuration

When placing Nginx or Traefik in front of the portal:

  1. Proxy Buffering: Disable response buffering for the download stream endpoint (/api/downloads/[downloadId]/file) to support direct streaming of original high-resolution photo files:
    location /api/downloads/ {
        proxy_pass http://localhost:3000;
        proxy_buffering off;
        proxy_read_timeout 600s;
        proxy_send_timeout 600s;
    }
    
  2. Body Size Limits: Unused (portal handles photo downloads only, not uploads).
  3. Security Headers: Managed by Next.js (next.config.ts), including restrictive CSP, frame denial (DENY), and strict Referrer-Policy.

4. Immich Service-User Permissions & API Key Setup

  1. Create a dedicated service user in Immich (e.g. redaktion-service@example.de).
  2. Share only administrator-approved editorial albums read-only with this user.
  3. Generate an API Key for the user with only the following scopes:
    • album.read
    • asset.read
    • asset.view
    • asset.download
  4. Test API access against Immich endpoints before deploying.

5. Database Migrations

Database schema migrations are managed via Drizzle Kit.

  • Apply Migrations:
    pnpm drizzle-kit migrate
    
  • Migrations must be executed prior to starting a new app container version.

6. Backup & Restore Procedures

Nightly Backup Drill

Use scripts/backup-db.sh in a daily cron job:

0 2 * * * /path/to/portal/scripts/backup-db.sh /var/backups/immich-portal >> /var/log/portal-backup.log 2>&1

Restore Procedure

To restore from a .dump file created by backup-db.sh:

# 1. Stop the application container to prevent writes
docker compose stop portal-app

# 2. Restore database from dump file
docker exec -i portal-db pg_restore -U portal -d portal --clean --if-exists < /path/to/backup.dump

# 3. Restart application container
docker compose start portal-app

7. Operational Maintenance Tasks

  • API Key Rotation: Generate a new key in Immich, update IMMICH_API_KEY in environment/secrets, and restart portal-app.
  • Health Verification:
    • GET /api/health/live -> 200 OK (Process liveness).
    • GET /api/health/ready -> 200 OK (Database & Immich connectivity).
  • Audit Log Inspection: Accessible in portal UI under /admin/audit (Admin role required).