Skip to content

Commit

Permalink
On branch master
Browse files Browse the repository at this point in the history
 Your branch is up to date with 'origin/master'.

 Changes to be committed:
	modified:   .gitignore
	modified:   Dockerfile
	new file:   docker-compose.yml
	new file:   docker-template.service
	new file:   docker.calibre-web-rpi.service
	new file:   init-env.sh
	new file:   init-service.sh

working version (v1.0)
working with ubuntu and apt install of calibre
  • Loading branch information
trasba committed Apr 13, 2020
1 parent 5071b69 commit e4cb755
Show file tree
Hide file tree
Showing 7 changed files with 329 additions and 86 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# .env file
.env
# Windows image file caches
Thumbs.db
ehthumbs.db
Expand Down
153 changes: 67 additions & 86 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,99 +1,80 @@
FROM lsiobase/alpine.python.armhf:3.8
FROM trasba/docker-baseimage-ubuntu-armhf

# set version label
ARG BUILD_DATE
ARG VERSION
LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}"
LABEL maintainer="chbmb"
LABEL build_version="version:- ${VERSION} Build-date:- ${BUILD_DATE}"
LABEL maintainer="trasba"

RUN \
echo "**** install build packages ****" && \
apk add --no-cache --virtual=build-dependencies \
file \
fontconfig-dev \
freetype-dev \
g++ \
gcc \
ghostscript-dev \
lcms2-dev \
libjpeg-turbo-dev \
libpng-dev \
libtool \
libwebp-dev \
libxml2-dev \
libxslt-dev \
make \
perl-dev \
python2-dev \
tiff-dev \
xz \
zlib-dev && \
echo "**** install runtime packages ****" && \
apk add --no-cache \
fontconfig \
freetype \
ghostscript \
lcms2 \
libjpeg-turbo \
libltdl \
libpng \
libwebp \
libxml2 \
libxslt \
tiff \
zlib && \
echo "**** compile imagemagic ****" && \
IMAGEMAGICK_VER=$(curl --silent http://www.imagemagick.org/download/digest.rdf \
| grep ImageMagick-6.*tar.gz | sed 's/\(.*\).tar.*/\1/' \
| sed 's/^.*ImageMagick-/ImageMagick-/') && \
mkdir -p \
/tmp/imagemagick && \
curl -o \
/tmp/imagemagick-src.tar.xz -L \
"http://www.imagemagick.org/download/${IMAGEMAGICK_VER}.tar.xz" && \
tar xf \
/tmp/imagemagick-src.tar.xz -C \
/tmp/imagemagick --strip-components=1 && \
cd /tmp/imagemagick && \
sed -i -e \
's:DOCUMENTATION_PATH="${DATA_DIR}/doc/${DOCUMENTATION_RELATIVE_PATH}":DOCUMENTATION_PATH="/usr/share/doc/imagemagick":g' \
configure && \
./configure \
--infodir=/usr/share/info \
--mandir=/usr/share/man \
--prefix=/usr \
--sysconfdir=/etc \
--with-gs-font-dir=/usr/share/fonts/Type1 \
--with-gslib \
--with-lcms2 \
--with-modules \
--without-threads \
--without-x \
--with-tiff \
--with-xml && \
make && \
make install && \
find / -name '.packlist' -o -name 'perllocal.pod' \
-o -name '*.bs' -delete && \
echo "**** install runtime packages & dev packages ****" && \
apt-get update && apt-get install -y \
python \
python-pip \
python-setuptools \
curl \
file \
libfontconfig1-dev \
libfreetype6-dev \
g++ \
gcc \
libgs-dev \
liblcms2-dev \
libturbojpeg0-dev \
libpng-dev \
libtool \
libwebp-dev \
libxml2-dev \
libxslt1-dev \
make \
libperl-dev \
python-dev \
libtiff5-dev \
zlib1g-dev && \
echo "**** install calibre ****" && \
apt-get install calibre --no-install-recommends -y && \
echo "**** install calibre-web ****" && \
mkdir -p \
/app/calibre-web && \
curl -o \
/tmp/calibre-web.tar.gz -L \
https://github.com/janeczku/calibre-web/archive/master.tar.gz && \
tar xf \
/tmp/calibre-web.tar.gz -C \
/app/calibre-web --strip-components=1 && \
mkdir -p /app/calibre-web && \
curl -L https://github.com/trasba/calibre-web/archive/master.tar.gz \
| tar xzv --strip-components=1 -C /app/calibre-web && \
cd /app/calibre-web && \
pip install --no-cache-dir -U -r \
requirements.txt && \
pip install --no-cache-dir -U -r \
optional-requirements.txt && \
pip install --no-cache-dir -U -r requirements.txt && \
sed -i 's/lxml==3.7.2/lxml>=3.8.0/g' optional-requirements.txt && \
pip install --no-cache-dir -U -r optional-requirements.txt && \
echo "**** cleanup ****" && \
apk del --purge \
build-dependencies && \
apt-get purge -y \
file libfontconfig1-dev libfreetype6-dev g++ gcc libgs-dev \
liblcms2-dev libturbojpeg0-dev libpng-dev libtool libwebp-dev \
libxml2-dev libxslt1-dev make libperl-dev python-dev libtiff5-dev \
zlib1g-dev python-dev autotools-dev binutils binutils-arm-linux-gnueabihf \
binutils-common cpp cpp-7 dirmngr fakeroot fonts-droid-fallback \
fonts-noto-mono g++-7 gcc-7 gcc-7-base gir1.2-harfbuzz-0.0 \
gnupg gnupg-l10n gnupg-utils gpg gpg-agent gpg-wks-client \
gpg-wks-server gpgconf gpgsm icu-devtools libalgorithm-diff-perl \
libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan4 \
libassuan0 libatomic1 libbinutils libc-dev-bin libc6-dev libcc1-0 \
libcilkrts5 libcupsfilters-dev libcupsfilters1 libcupsimage2 \
libdpkg-perl libelf1 libexpat1-dev libfakeroot \
libfile-fcntllock-perl libgcc-7-dev libgdbm-compat4 libgdbm5 \
libglib2.0-bin libglib2.0-dev-bin libgraphite2-dev libgs9 \
libgs9-common libharfbuzz-gobject0 libharfbuzz-icu0 libicu-le-hb0 \
libiculx60 libijs-0.35 libijs-dev libijs-doc libisl19 libjbig-dev \
libjbig2dec0 libjbig2dec0-dev libjpeg-dev libjpeg-turbo8-dev \
libjpeg8-dev libksba8 liblocale-gettext-perl libltdl-dev \
liblzma-dev libmagic-mgc libmagic1 libmpc3 libmpdec2 libmpfr6 \
libnpth0 libpaper-dev libpaper-utils libpaper1 libpcre16-3 \
libpcre3-dev libpcre32-3 libpcrecpp0v5 libperl5.26 libpng-tools \
libpython-all-dev libpython-dev libpython2.7-dev libpython3-stdlib \
libpython3.6-minimal libpython3.6-stdlib libstdc++-7-dev libtiffxx5 \
libturbojpeg libubsan0 linux-libc-dev manpages manpages-dev netbase \
patch perl perl-modules-5.26 pinentry-curses python-all \
python2.7-dev python3 python3-distutils python3-lib2to3 \
python3-minimal python3.6 && \
apt-get clean && \
rm -rf \
/tmp/*
/tmp/* \
/var/lib/apt/lists/* \
/var/tmp/*

# add local files
COPY root/ /
Expand Down
16 changes: 16 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: '3.4'

services:
calibre-web:
image: trasba/calibre-web-rpi:edge
build: .
environment:
- TZ=${TZ}
- PUID=${PUID}
- PGID=${PGID}
ports:
- "8089:8083"
volumes:
- ${volbooks}:/books
- ${volconfig}:/config
restart: unless-stopped
19 changes: 19 additions & 0 deletions docker-template.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[Unit]
Description=docker.docker-calibre-web daemon
After=network.target docker.service

[Service]
Type=simple
WorkingDirectory=~~WORK-DIR~~
ExecStart=~~DOCKER-COMPOSE-BIN~~/docker-compose -f ~~DOCKER-COMPOSE~~ up
ExecStop=~~DOCKER-COMPOSE-BIN~~/docker-compose -f ~~DOCKER-COMPOSE~~ down
Restart=always
User=~~USER~~
# Note RHEL/Fedora uses 'nobody', Debian/Ubuntu uses 'nogroup'
Group=~~USER~~
#paths also for other applications used by the libs, e.g awk & grep
#Environment=PATH=/bin:/usr/bin:/home/pi/.nvm/versions/node/v8.10.0/bin

[Install]
WantedBy=multi-user.target

1 change: 1 addition & 0 deletions docker.calibre-web-rpi.service
113 changes: 113 additions & 0 deletions init-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#!/bin/bash
configFile="/.env"
configPath="/.trasba/testing"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
bak=".bak"
### default values
def_PGID="1000"
def_PUID="1000"
def_TZ="TZ=CET-1CEST,M3.5.0/2,M10.5.0/3"
def_volbooks="~/.trasba/calibre-web/books"
def_volconfig="~/.trasba/calibre-web/config"
### define functions
function setconfig { #ask user for settings
echo "leave empty to use default"
read -p "PGID [1000]: " PGID
read -p "PUID [1000]: " PUID
read -p "TZ (timezone) [$def_TZ]: " TZ
read -p "volbooks [$def_volbooks]: " volbooks
read -p "volconfig [$def_volconfig]: " volconfig
if [ -z $PGID ]; then
echo "PGID=$def_PGID" > $hd$configPath$configFile
else
echo "PGID=$PGID" > $hd$configPath$configFile
fi
if [ -z $PUID ]; then
echo "PUID=$def_PUID" >> $hd$configPath$configFile
else
echo "PUID=$PUID" >> $hd$configPath$configFile
fi
if [ -z $TZ ]; then
echo "TZ=$def_TZ" >> $hd$configPath$configFile
else
echo "TZ=$TZ" >> $hd$configPath$configFile
fi
if [ -z $volbooks ]; then
echo "volbooks=$def_volbooks" >> $hd$configPath$configFile
else
echo "volbooks=$volbooks" >> $hd$configPath$configFile
fi
if [ -z $volconfig ]; then
echo "volconfig=$def_volconfig" >> $hd$configPath$configFile
else
echo "volconfig=$volconfig" >> $hd$configPath$configFile
fi
}

function checklocal { # true if file exists, false if not
if [ -f $DIR$configFile ]; then
existslocal=1
else
existslocal=0
fi
}

function create-symlink {
echo "Creating symlink $hd$configPath$configFile -> $DIR$configFile"
ln -s $hd$configPath$configFile $DIR$configFile
}
### get user home dir
hd=$( getent passwd "$USER" ) #hd => homedir
hdRC=$? #hdRC => homedir Return Code
if [ $hdRC == 0 ];
then
hd=$(echo $hd|cut -d: -f6)
elif [ $hdRC == 2 ];
then
echo "getent error: One or more supplied key could not be found in the database."
echo "Does the user exist?"
exit 1
fi
### echo remote dir and local dir
echo "Remote config path is: $hd$configPath"
echo "Local config path is: $DIR"
### check if file exists remotely, and create it if not
if [ ! -f $hd$configPath$configFile ]; then
echo "Config file does not exist."
echo "Creating config path"
mkdir -p $hd$configPath #make dir if it does not exist
setconfig
else
echo "Remote config file exists."
fi
### check if file exists locally
checklocal
if [ $existslocal == 1 ]; then
echo "Local config file exists."
realpath=$(readlink -f $DIR$configFile)
if [ $realpath == $hd$configPath$configFile ]; then
echo "Symlink already created."
while true; do
read -p "Recreate config file?(y/n) " recreate
case $recreate in
[Yy]* ) echo "Backing up old config file"; cp $DIR$configFile $DIR$configFile$bak; rm $DIR$configFile; setconfig; create-symlink; break;;
[Nn]* ) echo "Nothing to do."; break;;
* ) echo "Please answer yes or no.";;
esac
done
echo "Exiting."
exit 0
fi
while true; do
read -p "Overwrite local config file?(y/n) " overwrite
case $overwrite in
[Yy]* ) echo "Backing up old config file"; cp $DIR$configFile $DIR$configFile$bak; rm $DIR$configFile; create-symlink; break;;
[Nn]* ) echo "Aborting"; exit;;
* ) echo "Please answer yes or no.";;
esac
done
else
create-symlink
echo "Exiting."
fi
exit 0
Loading

0 comments on commit e4cb755

Please sign in to comment.