services: shelfbridge: image: ghcr.io/rohit-purandare/shelfbridge:latest # Uncomment the line below and comment the image line above to build locally # build: . container_name: shelfbridge # Restart policy: "no" prevents restart loops during configuration setup # Container stays stopped when configuration is invalid, requiring manual restart restart: 'no' volumes: # Named volumes for zero-setup - no local directories required - shelfbridge-config:/app/config - shelfbridge-data:/app/data # ALTERNATIVE: Use local directories for easier config editing # Uncomment the lines below and comment the named volumes above # This creates local ./config and ./data directories you can easily access # - ./config:/app/config # - ./data:/app/data # - ./logs:/app/logs # Optional: access logs locally # Environment variables for configuration (recommended for Docker) # Uncomment and customize the values below to use environment variable configuration # # 🚀 CONFIGURATION MODES: # 1. Environment Variables (no config.yaml needed) - Perfect for Docker! # 2. YAML Configuration (create config/config.yaml manually) - Advanced features # # 📋 PRIORITY ORDER (if both exist): # 1. config.yaml values (highest) - if config.yaml exists # 2. Environment variables (fallback) - fills missing config.yaml values # 3. Built-in defaults (lowest) # # ⚠️ LIMITATIONS: Some advanced features require config.yaml: # - Library filtering (include/exclude arrays) # - Reread detection configuration (nested settings) # - Per-user library filtering # # 💡 Recommendation: Use environment variables for most setups - no file editing needed! environment: # Default environment - prevents empty environment mapping error NODE_ENV: 'production' # Optional: specify the user and group id that the docker container should use # PUID: 1000 # PGID: 1000 # ============================================================================= # REQUIRED USER CONFIGURATION (Must be set if not using config.yaml) # ============================================================================= # User 0 configuration - PRIMARY USER (REQUIRED) # SHELFBRIDGE_USER_0_ID: "your_username" # REQUIRED: User identifier # SHELFBRIDGE_USER_0_ABS_URL: "https://your-abs-server.com" # REQUIRED: Audiobookshelf URL # SHELFBRIDGE_USER_0_ABS_TOKEN: "your_audiobookshelf_token" # REQUIRED: ABS API token # SHELFBRIDGE_USER_0_HARDCOVER_TOKEN: "your_hardcover_token" # REQUIRED: Hardcover API token # Additional users for multi-user setups (OPTIONAL) # SHELFBRIDGE_USER_1_ID: "second_user" # User identifier for second user # SHELFBRIDGE_USER_1_ABS_URL: "https://your-abs-server.com" # Audiobookshelf URL for second user # SHELFBRIDGE_USER_1_ABS_TOKEN: "second_user_abs_token" # ABS API token for second user # SHELFBRIDGE_USER_1_HARDCOVER_TOKEN: "second_user_hardcover_token" # Hardcover API token for second user # Add more users as needed (USER_2, USER_3, etc.) # ============================================================================= # OPTIONAL GLOBAL CONFIGURATION (All have sensible defaults) # ============================================================================= # Core sync settings # SHELFBRIDGE_MIN_PROGRESS_THRESHOLD: "5.0" # Minimum progress % to sync (0-100, default: 5.0) # SHELFBRIDGE_WORKERS: "3" # Number of parallel workers (1-10, default: 3) # SHELFBRIDGE_PARALLEL: "true" # Enable parallel processing (true/false, default: true) # SHELFBRIDGE_TIMEZONE: "UTC" # Timezone for scheduling (default: UTC) # Safety and testing # SHELFBRIDGE_DRY_RUN: "false" # Run without making changes (true/false, default: false) # SHELFBRIDGE_FORCE_SYNC: "false" # Force sync even if unchanged (true/false, default: false) # SHELFBRIDGE_MAX_BOOKS_TO_PROCESS: "" # Limit books processed per sync (optional, no default) # Automation # SHELFBRIDGE_SYNC_SCHEDULE: "0 3 * * *" # Cron schedule (default: daily at 3 AM) # SHELFBRIDGE_AUTO_ADD_BOOKS: "false" # Auto-add books to Hardcover (true/false, default: false) # Session-based delayed updates (reduces API calls) # SHELFBRIDGE_DELAYED_UPDATES_ENABLED: "false" # Enable delayed updates (true/false, default: false) # SHELFBRIDGE_DELAYED_UPDATES_SESSION_TIMEOUT: "900" # Session timeout in seconds (60-7200, default: 900 = 15 min) # SHELFBRIDGE_DELAYED_UPDATES_MAX_DELAY: "3600" # Max delay before forcing sync (300-86400, default: 3600 = 1 hour) # SHELFBRIDGE_DELAYED_UPDATES_IMMEDIATE_COMPLETION: "true" # Always sync book completion immediately (true/false, default: true) # Progress protection # SHELFBRIDGE_PREVENT_PROGRESS_REGRESSION: "true" # Prevent progress loss (true/false, default: true) # Rate limiting and performance # SHELFBRIDGE_HARDCOVER_SEMAPHORE: "1" # Max concurrent Hardcover requests (1-10, default: 1) # SHELFBRIDGE_HARDCOVER_RATE_LIMIT: "55" # Hardcover requests per minute (10-60, default: 55) # SHELFBRIDGE_AUDIOBOOKSHELF_SEMAPHORE: "5" # Max concurrent ABS requests (1-10, default: 5) # SHELFBRIDGE_AUDIOBOOKSHELF_RATE_LIMIT: "600" # ABS requests per minute (60-1200, default: 600) # Library fetching # SHELFBRIDGE_MAX_BOOKS_TO_FETCH: "" # Max books to fetch from ABS (optional, no default) # SHELFBRIDGE_PAGE_SIZE: "100" # Books per API request (25-200, default: 100) # Debugging # SHELFBRIDGE_DUMP_FAILED_BOOKS: "true" # Create error reports (true/false, default: true) # ============================================================================= # EXAMPLE CONFIGURATIONS # ============================================================================= # Basic Single User Setup - Uncomment and modify: # SHELFBRIDGE_USER_0_ID: "alice" # SHELFBRIDGE_USER_0_ABS_URL: "https://audiobookshelf.mydomain.com" # SHELFBRIDGE_USER_0_ABS_TOKEN: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." # SHELFBRIDGE_USER_0_HARDCOVER_TOKEN: "hc_sk_1234567890abcdef..." # Family Setup Example - Multiple users with custom settings: # SHELFBRIDGE_MIN_PROGRESS_THRESHOLD: "3.0" # Lower threshold for family # SHELFBRIDGE_AUTO_ADD_BOOKS: "true" # Auto-add books # SHELFBRIDGE_SYNC_SCHEDULE: "0 */6 * * *" # Sync every 6 hours # SHELFBRIDGE_TIMEZONE: "America/New_York" # Family timezone # # SHELFBRIDGE_USER_0_ID: "mom" # SHELFBRIDGE_USER_0_ABS_URL: "https://family-audiobooks.com" # SHELFBRIDGE_USER_0_ABS_TOKEN: "mom_abs_token" # SHELFBRIDGE_USER_0_HARDCOVER_TOKEN: "mom_hardcover_token" # # SHELFBRIDGE_USER_1_ID: "dad" # SHELFBRIDGE_USER_1_ABS_URL: "https://family-audiobooks.com" # SHELFBRIDGE_USER_1_ABS_TOKEN: "dad_abs_token" # SHELFBRIDGE_USER_1_HARDCOVER_TOKEN: "dad_hardcover_token" # Reduced API Usage Example - Delayed updates for frequent readers: # SHELFBRIDGE_DELAYED_UPDATES_ENABLED: "true" # Enable session-based delayed updates # SHELFBRIDGE_DELAYED_UPDATES_SESSION_TIMEOUT: "1800" # 30 minutes timeout # SHELFBRIDGE_DELAYED_UPDATES_MAX_DELAY: "7200" # 2 hours max delay # SHELFBRIDGE_DELAYED_UPDATES_IMMEDIATE_COMPLETION: "true" # Still sync completions immediately # SHELFBRIDGE_SYNC_SCHEDULE: "0 */1 * * *" # Check every hour (with delayed updates) # # Benefits: Reduces Hardcover API calls while maintaining accuracy # Use case: Active readers who listen continuously for long sessions command: ['npm', 'start'] healthcheck: test: ['CMD', 'npm', 'run', 'test:native'] interval: 30s timeout: 10s retries: 3 start_period: 10s labels: - 'com.docker.compose.project=shelfbridge' - 'com.docker.compose.service=shelfbridge' networks: - shelfbridge-network volumes: shelfbridge-config: driver: local shelfbridge-data: driver: local networks: shelfbridge-network: driver: bridge