services:
  calibre:
    extends:
      file: ${TEMPLATES_PATH}
      service: default
    image: lscr.io/linuxserver/calibre:9.3.1
    container_name: calibre
    environment:
      - PASSWORD= #optional
      - CLI_ARGS= #optional
    volumes:
      - ${EXTERNAL_STORAGE}/media/books:/config/library
      - ${MEDIA_PATH}/data/downloaded/books:/config/tosync
    ports:
      - 2005:8080 # gui
      - 2006:8181 # gui https
      - 2007:8081 # webserver ui
    networks:
      - ip4net
    labels:
      # Traefik
      - "traefik.enable=true"
      - "traefik.http.routers.calibre.rule=Host(`calibre.${LOCAL_DOMAIN}`)"
      - "traefik.http.routers.calibre.entrypoints=https"
      - "traefik.http.routers.calibre.tls=true"
      - "traefik.http.services.calibre.loadbalancer.server.port=8080"

  calibre-web:
    extends:
      file: ${TEMPLATES_PATH}
      service: default
    image: lscr.io/linuxserver/calibre-web:0.6.26
    container_name: calibre-web
    environment:
      - DOCKER_MODS=linuxserver/mods:universal-calibre #optional
      #      - OAUTHLIB_RELAX_TOKEN_SCOPE=1 #optional
    volumes:
      - ${EXTERNAL_STORAGE}/media/books:/books
      - ${MEDIA_PATH}/calibre/data:/config
    ports:
      - 2008:8083
    networks:
      - ip6net
    labels:
      # Traefik
      - "traefik.enable=true"
      - "traefik.http.routers.calibre-web.rule=Host(`calibre-web.${LOCAL_DOMAIN}`)"
      - "traefik.http.routers.calibre-web.entrypoints=https"
      - "traefik.http.routers.calibre-web.tls=true"
