Docker image for book management web server
1.0K
Docker image for book management web server.
Container runs as non-root user. This user owns calibre process and owns calibre files.
To run container next volumes should be mapped:
sudo groupadd -g 1195 calibre
useradd -u 1195 -g 1195 -M calibre
sudo useradd -r calibre
sudo groupmod -g 1195 calibre
sudo usermod -u 1195 calibre
sudo chmod u+x ./build
sudo ./build calibre
cd ~
mkdir conf
sudo chown calibre:calibre ~/conf
sudo docker run \
--rm \
-v ~/conf:/export \
dshap/calibre:9.11.0 export-assets
sudo mkdir /calibre
sudo mkdir /calibre/data
sudo chown -R calibre:calibre /calibre
sudo mkdir /var/log/calibre
sudo chown -R calibre:calibre /var/log/calibre
sudo mkdir /var/backups/calibre
sudo chown -R calibre:calibre /var/backups/calibre
sudo cp ~/conf/etc/init.d/calibre /etc/init.d
sudo chmod a+x /etc/init.d/calibre
sudo cp ~/conf/usr/sbin/calibre /usr/sbin
sudo chmod a+x /usr/sbin/calibre
sudo cp ~/conf/usr/bin/clutil /usr/bin
sudo chmod a+x /usr/bin/clutil
sudo rm -rf ~/conf
sudo update-rc.d calibre defaults
docker run ... -e LIBRARIES="<library_name>" ...
sudo service calibre start
sudo clutil manageusers
sudo service calibre restart
sudo service calibre (start|stop|status|restart)
sudo clutil manage-users
sudo clutil calibredb command [options] [arguments]
calibredb command is passed to the running docker container with clutil utility.
If calibredb command requires library path to be specified, then library name (as specified in the LIBRARIES environment variable) should be used. The clutil utility translates library name to the library path. For example, to list the specified book fields in the library <library_name>, next command can be used:
sudo clutil calibredb list --library-path <library_name> -f id,authors,author_sort,title,series,series_index,publisher,tags
sudo clutil backup <filename>
Backup file /var/backups/calibre/<filename>.tar.gz will be created.
sudo clutil restore <filename>
sudo clutil bash
Calibre web server can be located with another web applications. For example, mercurial, bugzilla, wiki etc can be run as docker containers on the same host. In this case apache server can be used to redirect requests to different docker containers.
sudo a2enmod deflate headers proxy proxy_ajp proxy_balancer proxy_connect proxy_html proxy_http rewrite
<VirtualHost *:80>
...
ProxyPreserveHost On
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
...
</VirtualHost>
sudo cp ~/conf/etc/apache2/sites-available/calibre.conf /etc/apache2/sites-available
sudo a2ensite calibre
sudo service apache2 restart
sudo service calibre stop
docker run ... -e LIBRARIES="library-1:library-2:library-3" ...
sudo service calibre start
sudo service calibre stop
docker run ... -e WITH_AUTH="false" ...
sudo service calibre start
Everyone can access the libraries, but no one can make changes. To upload new books, or to change the book metadata, the container environment variable WITH_AUTH should be true. After the changes are made, the container environment variable WITH_AUTH can be changed to false again.
sudo clutil clear-metadata <library> <column_name>
This command will clean the specified <column_name> for all books in the specified <library>.
The valid column names are:
To remove the book with id <id> from the library <library_name>, the next command can be used:
sudo clutil calibredb --library-path <library_name> remove <id>
Multiple book ids can be specified (with comma separator, or with range):
sudo clutil calibredb --library-path <library_name> remove <id1>,<id2>,<id3>
sudo clutil calibredb --library-path <library_name> remove <id1>-<id3>
Calibre gives 777 permit to all folders in the libraries. Calibre also gives execute permission to the log files. To remove excessive permissions, just restart calibre service:
sudo service calibre restart
sudo crontab -l | { cat; echo "minute hour * * * /usr/bin/clutil backup <filename>"; echo ""; } | sudo crontab -
Content type
Image
Digest
Size
424.6 MB
Last updated
about 5 years ago
docker pull dshap/calibre