Skip to content

πŸ“™ Installing Calibre

calibre_banner

Calibre-Web is a self-hosted web application that provides a clean, browser-based interface to browse, read, download, and manage your existing Calibre eBook library.

Features:

  • πŸ—‚οΈ It connects to an existing Calibre database (your metadata.db)
  • πŸ” Lets you browse, search, read, and download eBooks via a browser
  • πŸ‘₯ Includes user management, OPDS feed for e-readers, metadata editing

Info

The project is open-source and can be downloaded here: https://github.com/janeczku/calibre-web.


πŸ“₯ Installation

πŸ“‹ Requirements

Info

Calibre requires the installation of


πŸ“™ Install Calibre

The use of Docker Compose will automate the installation of calibre container.

πŸ”§ Setup Calibre Parameters

Before deployment, define the following environment variables. These values will be used throughout the setup and configuration process.

  • HOST_PORT: external port used by NGINX to route traffic to the service
  • DOCKER_DIR: path to the directory where all Docker containers are defined
# example of configuration for environment parameters
HOST_PORT=10025
βš™οΈ Configure Calibre for Docker Compose

Calibre can be deployed using Docker Compose. The compose.yml file will automatically incorporate the environment variables configured in the previous step. You can copy, paste, and run all of the following commands directly in your terminal.

# create docker directory
mkdir calibre && cd calibre
mkdir data data/calibre data/library

# copy to library Calibre database, download a sample from
wget -P data/library/ https://github.com/janeczku/calibre-web/raw/master/library/metadata.db
# setup of Dockerfile
tee Dockerfile > /dev/null <<EOF
#############################################
##### Build stage: apply Calibre-Web customization
#############################################
FROM lscr.io/linuxserver/calibre-web:latest AS build

# Reverse order for downloaded file names:
# From: "{title} - {author}"
#   To: "{author} - {title}"
#
# This patches the helper responsible for building the download file name
RUN set -eux; \\
    sed -i -E \\
      "s/^([[:space:]]*)file_name = file_name \+ ' - ' \+ book\.authors\[0\]\.name/\\
\1file_name = book.authors[0].name + ' - ' + file_name/" \\
      /app/calibre-web/cps/helper.py

#############################################
##### Final image: base image + patched helper
#############################################
FROM lscr.io/linuxserver/calibre-web:latest

# Copy the patched helper from the build stage into the final image
COPY --from=build /app/calibre-web/cps/helper.py /app/calibre-web/cps/helper.py
EOF
# setup of compose.yml
tee compose.yml > /dev/null <<EOF
services:
  calibre-web:
    build: .
    image: calibre-web
    container_name: calibre-web
    volumes:
      - ./data/calibre:/config:rw
      - ./data/library:/books:rw
    environment:
      - TZ=Etc/UTC
      - PUID=\${PUID}
      - PGID=\${PGID}
    ports:
      - \${HOST_PORT}:8083
    healthcheck:
      test: ["CMD", "curl", "-fsS", "-o", "/dev/null", "http://localhost:8083/"]
      start_period: 60s
      start_interval: 5s
      interval: 60s
      timeout: 1s
      retries: 3
    restart: unless-stopped
EOF
# setup of .env file
tee .env > /dev/null <<EOF
###################################################################################
# Run as non-root user
###################################################################################
PUID=`id -u`
PGID=`id -g`

###################################################################################
# NGINX Proxy Configuration
###################################################################################
HOST_PORT=${HOST_PORT}
EOF

Save the .env informations

All the secret informations are defined in the .env file.

🐳 Install Calibre with Docker Compose

Now that the compose.yml file has been generated, it's time to install all the containers.

# install and start the container
docker compose up -d

πŸš€ Deploy Calibre

Install NGINX

NGINX needs to be installed, follow the NGINX section.

Configure NGINX

NGINX needs to be configured using a file in /etc/nginx/sites-available directory.
This configuration file specify the documentation path:

server {
  server_name books.fum-server.fr;

  # setup 404 error_page
  error_page 404 /404.html;
  include snippets/error-404.conf;

  # reverse proxy
  location / {
    proxy_pass http://127.0.0.1:10025;

    # keep it HTTP/1.1
    proxy_http_version 1.1;

    # forwarded headers
    include proxy_params;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Port $server_port;

    # application-specific tuning
    proxy_read_timeout 600s;
    proxy_send_timeout 600s;
    client_max_body_size 100M;
  }
}
# enable site for production
sudo ln -s /etc/nginx/sites-available/calibre.domain.fr /etc/nginx/sites-enabled/calibre.domain.fr

# restart NGINX
sudo nginx -t && sudo service nginx restart

Replace calibre.domain.fr by the name of your website.

Activate HTTPS

To activate HTTPS protocol, follow theΒ Let's Encrypt section.


βš™οΈ Configure Calibre

Update Calibre-Web admin account

For security reasons, you must change the default administrator password immediately.
Log in using the factory credentials, then update the password in the admin settings:

  • Username: admin
  • Password: admin123

βš™οΈ Configure Calibre-Web

Configure Calibre database location

  1. Go to: Settings β†’ Edit Calibre Database Configuration
  2. Set Location of Calibre database to the folder containing Calibre library (metadata.db, ex: /books)
  3. Click Save

Enable uploads for admin

  1. Go to: Admin β†’ Edit Basic Configuration
  2. Under Feature Configuration, enable Allow Uploads
  3. Click Save

βš™οΈ Configure Calibre-Desktop

Use the title for sorting

  1. Open Preferences β†’ Ajustements
  2. Find Contrôler le tri des titres et séries dans l'affichage de la bibliothèque
  3. Set:
    title_series_sorting = 'strictly_alphabetic'
    
  4. Click Appliquer les changements Γ  cet ajustement
  5. Restart Calibre