Prepare a Raspberry Pi to host a Booklore eBook library

Set up a Raspberry Pi with Docker, folders, permissions and a Compose file so it can run the Booklore eBook library around the clock.

Julian ReedElectronics restorer and tinkerer
3 min read

A Raspberry Pi board in a case next to an eReader showing a book library
Photo by özgür / Pexels
Skill
Beginner
Tools
Terminal, Docker, Nano
Requires
Raspberry Pi 3 or newer, 64-bit OS

A Raspberry Pi can run your eBook library all day without running up your power bill. In about an hour at the terminal, you will prepare the Pi for Booklore: update it, create the folders and permissions it needs, and start the Docker Compose file that runs it.

What Booklore does

Booklore is a self-hosted web app for organizing, managing and reading eBooks. It is a modern-looking alternative to Calibre. It fetches metadata for your books, and you can edit that metadata in the web interface. Its "magic shelves" sort your library for you automatically.

It is also an eBook reader. It tracks which books you are reading and how far you have got, and it can sync that progress with your devices if you use the Koreader app. The project continues under the name Grimmory, whose team is carrying on the original developer's work. This guide uses the Grimmory image but still calls the app Booklore.

64-bit only

Booklore needs a 64-bit operating system. No 32-bit builds are offered, so you need a Raspberry Pi 3 or newer. Check that your Pi runs a 64-bit system before you start.

What you will need

  • Raspberry Pi 3 or newer, running a 64-bit OS (this setup was tested on a Raspberry Pi 5 with Raspberry Pi OS Trixie, 64-bit)
  • Micro SD card
  • Power supply
  • Ethernet cable or Wi-Fi
  • Optional: case, USB mouse, USB keyboard, HDMI cable and monitor

Every step runs in the terminal. On a desktop version of Raspberry Pi OS, press CTRL + ALT + T to open one.

Step by step

  1. Update the Pi. The first command refreshes the package list. The second upgrades anything out of date.
    sudo apt update
    sudo apt upgrade -y
    
  2. Install Docker. Docker runs Booklore and makes updating it straightforward. Get it installed before going further.
  3. Make the stack folder. This holds Booklore's data and Compose file. You can choose another path, but the rest of the steps assume this one.
    sudo mkdir -p /opt/stacks/booklore/data
    
  4. Make the database folder. Creating it now stops Docker from making it as a file instead of a folder.
    sudo mkdir -p /opt/stacks/booklore/mariadb
    
  5. Hand the database folder to user 1000. The database is set up to use this user by default.
    sudo chown 1000:1000 /opt/stacks/booklore/mariadb
    
  6. Take ownership of the data folder. Use the account that will have access to your books, usually the one you log in with. Replace <USERNAME> with that name. For a user called "pi", it would be sudo chown pi: /opt/stacks/booklore/data.
    sudo chown <USERNAME>: /opt/stacks/booklore/data
    
  7. Create a books folder. Your eBook library lives here. If you put it somewhere other than your home directory, note the path because you will need it later.
    mkdir ~/books
    
  8. Create a Bookdrop folder. Copy books into this folder and Booklore processes them and adds them to your library.
    mkdir ~/bookdrop
    
  9. Note your user ID. Run this and write down the number it prints, usually 1000.
    id -u
    
  10. Note your group ID. This is often the same as the user ID, but check anyway. Label this number as the group ID.
    id -g
    
  11. Move into the stack folder. You need to be in this folder later to start Booklore.
    cd /opt/stacks/booklore
    
  12. Open a new Compose file in Nano. Nano is one of the friendliest command-line editors for beginners.
    sudo nano compose.yaml
    
  13. Define the Booklore container. The file describes two containers: Booklore itself, and a MariaDB server that stores your data. Replace <BOOKSDIR> with /home/<USERNAME>/books and <BOOKDROPDIR> with /home/<USERNAME>/bookdrop, using your own username in both.
    services:
      booklore:
        image: ghcr.io/grimmory-tools/grimmory:latest
        container_name: booklore
        environment:
          - USER_ID=${APP_USER_ID}
          - GROUP_ID=${APP_GROUP_ID}
          - TZ=${TZ}
          - DATABASE_URL=${DATABASE_URL}
          - DATABASE_USERNAME=${DB_USER}
          - DATABASE_PASSWORD=${DB_PASSWORD}
          - BOOKLORE_PORT=${BOOKLORE_PORT}
        depends_on:
          mariadb:
            condition: service_healthy
        ports:
          - "${BOOKLORE_PORT}:${BOOKLORE_PORT}"
        volumes:
          - ./data:/app/data
          - <BOOKSDIR>:/books
          - <BOOKDROPDIR>:/bookdrop
        restart: unless-stopped
    

Keep your notes handy

The user ID and group ID from steps 9 and 10 are what the USER_ID and GROUP_ID settings expect. Keep them with the paths to your books and Bookdrop folders.

What comes next

Below the Booklore section, the same file defines the database container. It uses the lscr.io/linuxserver/mariadb:11.4.5 image and stores its files in the mariadb folder you prepared. Once that section is complete and the settings referenced in the file have values, start Booklore from inside /opt/stacks/booklore.

Because the Pi draws little power, you can leave the library running all the time. It has enough performance for a decent-sized collection.

Filed underTechnologyElectronicsHomeBeginnerRaspberry Pi
Portrait of Julian Reed

Written by

Julian Reed

A vintage electronics restorer and hobbyist tinkerer who walks readers through soldering basics, retro console repairs, and fun weekend gadget builds.

Previous articleCast a polished concrete coffee table with crushed glassNext articlePhotograph wildlife without disturbing it or misleading viewers

You may also like

0 comments

    Join the conversation

    Be kind and be specific. Comments are moderated before they appear.