Selfhosted eBook Library

DMA

I recently got a new eReader (Onyx Boox Palma). Having already used KOReader on my phone, I wanted to read the same books on my new device. My goal was to access my books across all devices, sync reading progress, and export highlights to Readwise, which then syncs to my Obsidian vault.

All the services I selfhost run in their own Docker containers. I’ll provide the compose files for each, which you can use and customize as needed. My selfhost infrastructure includes an Nginx Proxy Manager for exposing services and creating SSL certificates, accessible only through VPN. My books are stored on a local NAS, accessible via an NFS share, which is mounted to the machine running the containers.

In this guide I will only cover the setup of the eBook library related services.
Here's how I set everything up.

Calibre Web

For hosting my library, I use Calibre Web. This web interface makes it easy to add and manage books and provides access to multiple users. It also supports the OPDS catalog, which KOReader can access.

Setup

1. Copy the compose file to your host and run docker-compose up -d

2. You’ll need an existing Calibre database. The Calibre Web project requires this and doesn’t
   create one by default, so you’ll need to download Calibre and export a metadata.db file. It
   can be empty.

3. Once you've created or obtained this file and have run the container at least once to
   create the necessary file structure, copy the database to your hosting device and place it
   in the mounted books folder (in my case, this is on my NAS). Make sure the books folder is
   initially empty and contains only the metadata.db file. Later, you’ll be able to add books
   via the web UI.

4. Start the container, access the web UI and you will be greeted with the database selection
   menu. Here navigate to /books, where the books folder from the host system is mounted,
   and select the metadata.db file

5. You should now be able to fully use Calibre Web. Create a new user, grant them permissions
   to upload and download books (I granted all permissions), and upload your books.

version: '3'

services:
  calibre-web:
    image: lscr.io/linuxserver/calibre-web:latest
    container_name: calibre-web
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Etc/UTC
      - DOCKER_MODS=linuxserver/mods:universal-calibre
      - OAUTHLIB_RELAX_TOKEN_SCOPE=1
    volumes:
      - ./config:/config
      - ./books:/books
    ports:
      - 8083:8083
    restart: unless-stopped
calibre-web - docker-compose.yml

KOReader Sync

KOReader Sync is a sync server which offers multiple endpoints to register, login and sync the progress on your books in your KOReader app.

Setup

1. Copy the compose file to your host and run docker-compose up -d

version: '3'

services:
  kosync:
    image: koreader/kosync:latest
    container_name: kosync
    ports:
      - "7200:7200"
      - "17200:17200"
    volumes:
      - ./logs/app:/app/koreader-sync-server/logs
      - ./logs/redis:/var/log/redis
      - ./data/redis:/var/lib/redis
koreader-sync - docker-compose.yml

KOReader Setup

Now, let’s set up KOReader, connect to the Calibre Web OPDS catalog, and log into the sync server. Here are the setup steps:

Connect to OPDS catalog

1. KOReader App -> Topbar magnifying glass icon -> select OPDS catalog and press the plus (+)
   icon at the top left to add a new OPDS server.

2. Enter your OPDS URL (e.g., https://domain.net/opds/), including  the trailing slash,
   or it won’t connect. Use the credentials you set in Calibre Web.

3. After adding the OPDS catalog, you’ll be able to download books to your device. I use the
   "Alphabetical Catalog" and then "All." Some categories might not work or may not align
   perfectly with Calibre Web categories.

Sync

1. In KOReader, open a book, find progress sync in the top bar, select "custom sync server",
   provide the URL to your own sync server instance and then register and login.

2. When you have a book open you can manually sync it (topbar menu). Also you configure how
   often it should sync automatically.

Export Highlights

1. Go to "Export highlights," choose formats and services, select Readwise, and add the
   API key from your Readwise account.

2. When you have a book selected you export the highlights from the topbar to your
   Readwise account.

Happy Reading!

For free and public domain eBooks, Project Gutenberg is a great resource, offering thousands of classics and more, all freely available in various formats. Enjoy building your digital library!