services:
  yuvomi:
    image: ghcr.io/ulsklyc/yuvomi:latest
    build: .                          # optional: use --build to build locally instead
    container_name: yuvomi
    restart: unless-stopped
    ports:
      # Host-Port aus .env (OIKOS_HTTP_PORT); App im Container bleibt auf 3000.
      - "0.0.0.0:${OIKOS_HTTP_PORT:-3000}:3000"
    volumes:
      - ${DATA_DIR:-./data}:/data
      - ${BACKUP_DIR:-./backups}:/backups
      # Drop Yuvomi modules into ./modules, or set MODULES_DIR=/path/to/modules.
      - ${MODULES_DIR:-./modules}:/app/modules
      # Optional local documents folder: mount a host directory to /documents inside the container
      - ${DOCUMENT_STORAGE_LOCAL_DIR:-./documents}:/documents
    env_file:
      - .env
    environment:
      - NODE_ENV=production
      - DB_PATH=${DB_PATH:-/data/yuvomi.db}
      - BACKUP_DIR=/backups
      # Local document storage (optional): set to true to store uploaded documents on the mounted /documents folder.
      - DOCUMENT_STORAGE_LOCAL_ENABLED=${DOCUMENT_STORAGE_LOCAL_ENABLED:-false}
      - DOCUMENT_STORAGE_LOCAL_PATH=${DOCUMENT_STORAGE_LOCAL_PATH:-/documents}
      # Secure cookies come from .env (the installer sets them):
      #   - Reverse proxy + HTTPS → SESSION_SECURE=true, TRUST_PROXY=1
      #   - Direct HTTP access     → SESSION_SECURE=false, TRUST_PROXY=loopback
      # Default when unset (e.g. bare `docker compose up` without .env): false,
      # so direct HTTP login keeps working out of the box.
      - SESSION_SECURE=${SESSION_SECURE:-false}
    healthcheck:
      test: ["CMD", "node", "-e", "require('http').get('http://localhost:3000/health', r => process.exit(r.statusCode === 200 ? 0 : 1))"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 10s
