Files
immich-redaktions-plugin/compose.yaml
Leon Tonhäuser dd60fd6ee6 feat: auto-assign new Immich albums via keyword rules
Auto-assignment rules were only applied when an admin clicked
"Regeln jetzt anwenden". New albums created in Immich therefore
never reached editorials automatically.

- applyAllRules() syncs every active editorial's keywords against the
  full album list in one pass and grants matches as system actor
- in-process scheduler (src/instrumentation.ts) runs the sync every
  AUTO_RULE_SYNC_INTERVAL_SECONDS (default 120s)
- POST /api/cron/album-sync allows external triggers via CRON_SECRET
- overlapping sync runs coalesce to avoid duplicate grants/emails
2026-08-25 01:05:04 +02:00

115 lines
3.4 KiB
YAML

# Shared application environment. Services with `environment: *portal-env` below
# all receive the same vars, so migrations, seeding and preflight run against the
# same config as the live app.
x-portal-env: &portal-env
DATABASE_URL: ${DATABASE_URL:-postgres://portal:change-me@portal-db:5432/portal}
BETTER_AUTH_SECRET: ${BETTER_AUTH_SECRET}
BETTER_AUTH_URL: ${BETTER_AUTH_URL:-https://redaktionen.leon-tonhaeuser.de}
IMMICH_BASE_URL: ${IMMICH_BASE_URL}
IMMICH_API_KEY: ${IMMICH_API_KEY}
SMTP_HOST: ${SMTP_HOST}
SMTP_PORT: ${SMTP_PORT:-587}
SMTP_USER: ${SMTP_USER}
SMTP_PASSWORD: ${SMTP_PASSWORD}
SMTP_FROM: ${SMTP_FROM}
LEGAL_IMPRINT_URL: ${LEGAL_IMPRINT_URL:-https://leon-tonhaeuser.de/impressum}
LEGAL_PRIVACY_URL: ${LEGAL_PRIVACY_URL:-https://leon-tonhaeuser.de/datenschutz}
LEGAL_TERMS_URL: ${LEGAL_TERMS_URL:-https://leon-tonhaeuser.de/agb}
CRON_SECRET: ${CRON_SECRET:-}
AUTO_RULE_SYNC_INTERVAL_SECONDS: ${AUTO_RULE_SYNC_INTERVAL_SECONDS:-}
services:
portal-db:
image: postgres:17-alpine
container_name: portal-db
restart: unless-stopped
environment:
POSTGRES_DB: ${POSTGRES_DB:-portal}
POSTGRES_USER: ${POSTGRES_USER:-portal}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-change-me}
volumes:
- portal-db-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER:-portal} -d $${POSTGRES_DB:-portal}"]
interval: 5s
timeout: 5s
retries: 5
networks:
- portal-internal
portal-app:
build:
context: .
dockerfile: Dockerfile
container_name: portal-app
restart: unless-stopped
ports:
- "3000:3000"
environment: *portal-env
depends_on:
portal-db:
condition: service_healthy
networks:
- portal-internal
- immich_default
# One-shot: apply Drizzle migrations. Runs in the builder stage (which has the
# source + drizzle-kit) on the internal network so it can reach portal-db.
# docker compose --profile ops run --rm migrate
migrate:
build:
context: .
dockerfile: Dockerfile
target: builder
environment: *portal-env
command: ["pnpm", "exec", "drizzle-kit", "migrate"]
depends_on:
portal-db:
condition: service_healthy
networks:
- portal-internal
profiles: ["ops"]
# One-shot: seed the first admin. Override the command to pass credentials:
# docker compose --profile ops run --rm seed \
# pnpm tsx scripts/create-admin.ts admin@example.de "Password!" "Name"
seed:
build:
context: .
dockerfile: Dockerfile
target: builder
environment: *portal-env
command: ["pnpm", "tsx", "scripts/create-admin.ts"]
depends_on:
portal-db:
condition: service_healthy
networks:
- portal-internal
profiles: ["ops"]
# One-shot: smoke test env + DB + Better Auth + SMTP + Immich connectivity.
# docker compose --profile ops run --rm preflight
preflight:
build:
context: .
dockerfile: Dockerfile
target: builder
environment: *portal-env
command: ["pnpm", "tsx", "scripts/preflight.ts"]
depends_on:
portal-db:
condition: service_healthy
networks:
- portal-internal
- immich_default
profiles: ["ops"]
volumes:
portal-db-data:
networks:
portal-internal:
internal: true
immich_default:
external: true