services: postgres: # Plain Postgres: Lifer only needs pgcrypto, pg_trgm and unaccent, which it ships with. Pin the # major version: a new major can't open an older one's data without a dump and restore. # Pinned by digest like the Dockerfile; Dependabot bumps the tag and digest together. image: postgres:18-alpine@sha256:77f585114c32fbca283dc835b0596f4e52b51b4c6662d7810b2f4084f60a1873 restart: unless-stopped # Time to finish writing on shutdown, instead of Docker's 10 seconds, after which it's killed. stop_grace_period: 1m # Docker's default 64 MB of shared memory is too little for Postgres's parallel queries on a # large catalog ("could not resize shared memory segment"). shm_size: 256mb environment: POSTGRES_USER: lifer # Only the first start uses this default: Lifer then moves the database onto a generated # password kept in its app-data volume (docker/db-password.mjs). Nothing to set. POSTGRES_PASSWORD: ${DB_PASSWORD:-lifer} POSTGRES_DB: lifer # No host port: only Lifer talks to the database, over the compose network. volumes: # Postgres 18 images keep their data under /var/lib/postgresql//, so the volume is # mounted one level up from where older images expected it. - lifer-db:/var/lib/postgresql # -h 127.0.0.1 waits for the real TCP listener, not the socket-only init phase on first boot. healthcheck: test: ["CMD-SHELL", "pg_isready -h 127.0.0.1 -U lifer -d lifer"] interval: 2s timeout: 3s retries: 30 # One-shot, runs as root: creates the folders Lifer writes to and gives them to PUID:PGID # (only entries whose owner differs), since the api container runs as that non-root user. permissions: image: ghcr.io/sparklysparkspark/lifer-app:${LIFER_VERSION:-release} user: "0:0" network_mode: none restart: "no" entrypoint: ["/usr/local/bin/lifer-fix-permissions"] command: ["/data", "/app-data"] environment: PUID: ${PUID:-568} PGID: ${PGID:-568} volumes: - ${LIFER_STORAGE_DIR:-./data/lifer}:/data - lifer-app-data:/app-data # Serves the API and the built web UI on one port. Put your own reverse proxy in front for TLS. api: # "release" is the newest stable version. Pin one (LIFER_VERSION=0.10.0 in .env) to update on # your own schedule. image: ghcr.io/sparklysparkspark/lifer-app:${LIFER_VERSION:-release} # Reaps the ExifTool and ffmpeg helper processes Lifer starts. init: true # Brings Lifer back after a crash or a freeze-watchdog restart (LIFER_FREEZE_RESTART_SECONDS). restart: unless-stopped # Non-root; the permissions service above makes the volumes writable for this user. user: "${PUID:-568}:${PGID:-568}" depends_on: postgres: condition: service_healthy permissions: condition: service_completed_successfully environment: DATABASE_URL: postgres://lifer:${DB_PASSWORD:-lifer}@postgres:5432/lifer NODE_ENV: production PORT: ${PORT:-4000} DATA_DIR: /data APP_DATA_DIR: /app-data # The reverse proxy in front of Lifer, by address or range; unset trusts none. Set it when # Lifer is behind a proxy (see the docs, reverse-proxy). TRUST_PROXY: ${TRUST_PROXY:-} # Extra folders Lifer may read and write besides /data: reimporting an existing library, # building trips, and saving uploads to another disk. Comma-separated, each # "Label=/container/path" or just "/container/path". Every entry must also be mounted # below. Anything outside /data and these roots is refused (403). LIFER_LIBRARY_ROOTS: ${LIFER_LIBRARY_ROOTS:-} LIFER_FREEZE_RESTART_SECONDS: ${LIFER_FREEZE_RESTART_SECONDS:-120} # Upload and image limits (see .env.example). Empty means Lifer's own default. MAX_UPLOAD_BYTES: ${MAX_UPLOAD_BYTES:-} LIFER_MAX_IMAGE_PIXELS: ${LIFER_MAX_IMAGE_PIXELS:-} LIFER_UPLOAD_WORK_DIR: ${LIFER_UPLOAD_WORK_DIR:-} LIFER_MAX_JSON_BODY_BYTES: ${LIFER_MAX_JSON_BODY_BYTES:-} # Species matching uses a GPU on its own when one is passed in below and is faster. # "off" keeps it on the CPU, for troubleshooting only. LIFER_GPU: ${LIFER_GPU:-} ports: - "${PORT:-4000}:${PORT:-4000}" volumes: # Your photo library. Stop Lifer before moving or renaming it: a running server keeps # the old folder open and every upload fails until it restarts. - ${LIFER_STORAGE_DIR:-./data/lifer}:/data # Lifer's own files (previews, offline map, models, catalog downloads), kept out of the # photo library so they never clutter it. - lifer-app-data:/app-data # Example library root (pair with LIFER_LIBRARY_ROOTS=NAS=/library/nas): # - /srv/nas/photos:/library/nas # Optional GPU for faster species matching: download hwaccel.yml next to this file, uncomment # these lines and set `service` to nvidia or intel-amd. See the docs, hardware-acceleration. # extends: # file: hwaccel.yml # service: nvidia volumes: lifer-db: lifer-app-data: