π Installing Calibre¶

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¶
π 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 serviceDOCKER_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.frby 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
- Go to: Settings β Edit Calibre Database Configuration
- Set Location of Calibre database to the folder containing Calibre library (
metadata.db, ex:/books) - Click Save
Enable uploads for admin
- Go to: Admin β Edit Basic Configuration
- Under Feature Configuration, enable Allow Uploads
- Click Save
βοΈ Configure Calibre-Desktop
Use the title for sorting
- Open Preferences β Ajustements
- Find Contrôler le tri des titres et séries dans l'affichage de la bibliothèque
- Set:
title_series_sorting = 'strictly_alphabetic' - Click Appliquer les changements Γ cet ajustement
- Restart Calibre