# Calibre-Web-Automated — all-in-one replacement for the old
# `calibre` + `calibre-web` pair. Upstream: https://github.com/crocodilestick/Calibre-Web-Automated
#
# The library lives on the NH3 / ESH NAS via NFS, so NETWORK_SHARE_MODE
# must be on (disables SQLite WAL, which corrupts on NFS).
#
# All tunables live in .env — edit that, not this file.

services:
  calibre-web-automated:
    image: crocodilestick/calibre-web-automated:${CWA_VERSION:-latest}
    container_name: calibre-web-automated
    restart: unless-stopped
    environment:
      - PUID=${PUID:-2000}
      - PGID=${PGID:-2000}
      - TZ=${TZ:-America/Los_Angeles}
      - NETWORK_SHARE_MODE=${NETWORK_SHARE_MODE:-true}
      - CWA_PORT_OVERRIDE=${CWA_PORT:-8083}
      - HARDCOVER_TOKEN=${HARDCOVER_TOKEN:-}
    ports:
      - "${CWA_PORT:-8083}:${CWA_PORT:-8083}"
    volumes:
      - ${CWA_CONFIG_DIR}:/config
      - ${CWA_INGEST_DIR}:/cwa-book-ingest
      - ${CWA_LIBRARY_DIR}:/calibre-library
    healthcheck:
      # CWA image ships curl (not wget). `-fsS` makes curl exit non-zero on
      # 4xx/5xx or connection failure while staying quiet on success. The
      # port substitution happens at compose-render time so custom CWA_PORT
      # values still work.
      test: ["CMD", "curl", "-fsS", "-o", "/dev/null", "http://localhost:${CWA_PORT:-8083}/"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 60s
    networks:
      - tnet
    labels:
      - homepage.group=Media
      - homepage.name=Calibre-Web-Automated
      - homepage.icon=si-calibreweb
      - homepage.description=eBook library + auto-ingest (esh)
      - homepage.href=http://10.0.50.45:${CWA_PORT:-8083}

networks:
  tnet:
    name: traefik-net
    external: true
