version: "3.9"

services:
  kavita:
    container_name: kavita
    image: jvmilazz0/kavita:0.7.14
    ports:
      - ${APP_PORT}:5000
    volumes:
      - ${APP_DATA_DIR}/data/kavita-config:/kavita/config
      - ${ROOT_FOLDER_HOST}/media/data/books:/books
      - ${ROOT_FOLDER_HOST}/media/data/comics:/comics
      - ${ROOT_FOLDER_HOST}/media/data/manga:/manga
    environment:
      - TZ=${TZ}
    restart: unless-stopped
    networks:
      - tipi_main_network
    labels:
      # Main
      traefik.enable: true
      traefik.http.middlewares.kavita-web-redirect.redirectscheme.scheme: https
      traefik.http.services.kavita.loadbalancer.server.port: 5000
      # Web
      traefik.http.routers.kavita-insecure.rule: Host(`${APP_DOMAIN}`)
      traefik.http.routers.kavita-insecure.entrypoints: web
      traefik.http.routers.kavita-insecure.service: kavita
      traefik.http.routers.kavita-insecure.middlewares: kavita-web-redirect
      # Websecure
      traefik.http.routers.kavita.rule: Host(`${APP_DOMAIN}`)
      traefik.http.routers.kavita.entrypoints: websecure
      traefik.http.routers.kavita.service: kavita
      traefik.http.routers.kavita.tls.certresolver: myresolver
      # Local domain
      traefik.http.routers.kavita-local-insecure.rule: Host(`kavita.${LOCAL_DOMAIN}`)
      traefik.http.routers.kavita-local-insecure.entrypoints: web
      traefik.http.routers.kavita-local-insecure.service: kavita
      traefik.http.routers.kavita-local-insecure.middlewares: kavita-web-redirect
      # Local domain secure
      traefik.http.routers.kavita-local.rule: Host(`kavita.${LOCAL_DOMAIN}`)
      traefik.http.routers.kavita-local.entrypoints: websecure
      traefik.http.routers.kavita-local.service: kavita
      traefik.http.routers.kavita-local.tls: true
