Skip to content

Commit

Permalink
Trying a new approach to bundling universal calibre into the CWA image
Browse files Browse the repository at this point in the history
  • Loading branch information
crocodilestick committed Nov 8, 2024
1 parent b9764e6 commit b345c8d
Show file tree
Hide file tree
Showing 18 changed files with 44 additions and 219 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ cwa.db

# Dev files
dev_changelog.md
*.txz

# Distribution / packaging
.Python
Expand Down
53 changes: 32 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ RUN \
tar xf \
/tmp/calibre-web.tar.gz -C \
/app/calibre-web --strip-components=1 && \
# STEP 1.6 - Sets up a python virtual enviroment and installs pip and wheel packages
# STEP 1.6 - Sets up a python virtual environment and installs pip and wheel packages
cd /app/calibre-web && \
python3 -m venv /lsiopy && \
pip install -U --no-cache-dir \
Expand Down Expand Up @@ -107,7 +107,6 @@ RUN \
python3 \
python3-pip \
nano \
git \
sqlite3 && \
# STEP 2.2 - Install additional required python packages
pip install -r /app/calibre-web-automated/requirements.txt && \
Expand Down Expand Up @@ -135,43 +134,55 @@ RUN \
# STEP 2.4.6 - Remove the temp files
rm -R /app/calibre-web-automated/root/ && \
rm -R /tmp/lscw/root/ && \
# STEP 2.5 - ADD files referencing the verisons of the installed main packages
# CALIRBE_RELEASE is placed in root by universal calibre below and containers the calibre version being used
# STEP 2.5 - ADD files referencing the versions of the installed main packages
# CALIBRE_RELEASE is placed in root by universal calibre below and containers the calibre version being used
echo "$VERSION" >| /app/CWA_RELEASE && \
echo "$LSCW_RELEASE" >| /app/LSCW_RELEASE && \
echo "$KEPUBIFY_RELEASE" >| /app/KEPUBIFY_RELEASE && \
# STEP 2.6 - Run CWA install script to make required dirs, set script permissions and add alliases for CLI commands ect.
# STEP 2.6 - Run CWA install script to make required dirs, set script permissions and add aliases for CLI commands ect.
chmod +x /app/calibre-web-automated/scripts/setup-cwa.sh && \
/app/calibre-web-automated/scripts/setup-cwa.sh && \
# STEP 3 - Install Universal Calibre
# STEP 3.1 - Make a temporary directory for all the required files to download
# STEP 3.1 - Install additional required packages
apt-get update && \
apt-get install -y --no-install-recommends \
libxtst6 \
libxrandr2 \
libxkbfile1 \
libxcomposite1 \
libopengl0 \
libnss3 \
libxkbcommon0 \
libegl1 \
libxdamage1 \
libgl1 \
libglx-mesa0 \
xz-utils && \
# STEP 3.3 - Make a temporary directory for all the required files to download
mkdir -p \
/tmp/universal-calibre/root && \
# # STEP 3.2 - Download required files from the dockermod repo
# git clone https://github.com/linuxserver/docker-mods --branch universal-calibre /tmp/universal-calibre/root && \
# STEP 3.3 - Download the version of Calibre specified in the UNIVERSAL_CALIBRE_RELEASE arg variable
/app/calibre && \
# STEP 3.4 - Extract the version of Calibre dependent on the architecture of the build environment
if [ "$(uname -m)" == "x86_64" ]; then \
curl -o \
/tmp/universal-calibre/root/calibre.txz -L \
curl -o \
/calibre.txz -L \
"https://download.calibre-ebook.com/${UNIVERSAL_CALIBRE_RELEASE}/calibre-${UNIVERSAL_CALIBRE_RELEASE}-x86_64.txz"; \
elif [ "$(uname -m)" == "aarch64" ]; then \
curl -o \
/tmp/universal-calibre/root/calibre.txz -L \
curl -o \
/calibre.txz -L \
"https://download.calibre-ebook.com/${UNIVERSAL_CALIBRE_RELEASE}/calibre-${UNIVERSAL_CALIBRE_RELEASE}-arm64.txz"; \
fi && \
# STEP 3.4 - Store the UNIVERSAL_CALIBRE_RELEASE in the root of the image in CALIBRE_RELEASE
echo $UNIVERSAL_CALIBRE_RELEASE > /tmp/universal-calibre/root/CALIBRE_RELEASE && \
# STEP 3.5 - Copy all files from the /tmp/universal-calibre/root directory to the root of the image
cp -R /tmp/universal-calibre/root/* / && \
# STEP 3.6 - Remove the temp files
rm -R /tmp/universal-calibre/root/
# STEP 3.x - Extract the calibre files to /app/calibre
tar xf \
/calibre.txz -C \
/app/calibre && \
# STEP 3.5 - Store the UNIVERSAL_CALIBRE_RELEASE in the root of the image in CALIBRE_RELEASE
echo $UNIVERSAL_CALIBRE_RELEASE > /CALIBRE_RELEASE

# Removes packages that are no longer required, also emptying dirs used to build the image that are no longer needed
RUN \
echo "**** cleanup ****" && \
apt-get -y purge \
build-essential \
git \
libldap2-dev \
libsasl2-dev \
python3-dev && \
Expand Down
Empty file.
81 changes: 0 additions & 81 deletions root/etc/s6-overlay/s6-rc.d/universal-calibre-add-packages/run

This file was deleted.

This file was deleted.

This file was deleted.

Empty file.
Empty file.
103 changes: 0 additions & 103 deletions root/etc/s6-overlay/s6-rc.d/universal-calibre-package-install/run

This file was deleted.

This file was deleted.

This file was deleted.

Empty file.
19 changes: 11 additions & 8 deletions root/etc/s6-overlay/s6-rc.d/universal-calibre-setup/run
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ fi

export DEBIAN_FRONTEND="noninteractive"

if [[ -e /calibre.txz ]]; then
mkdir -p /app/calibre
tar xf \
/calibre.txz \
-C /app/calibre
echo "Installing Calibre version $(cat /CALIBRE_RELEASE)"
if [[ "$(calibredb --version)" != "calibredb (calibre 7.16)" ]]; then
echo "[universal-calibre-setup] Installing Calibre version $(cat /CALIBRE_RELEASE)..."
/app/calibre/calibre_postinstall
rm /calibre.txz
fi
if [[ $? == 0 ]]
then
echo "[universal-calibre-setup] Setup successful! Exiting now..."
else
echo "[universal-calibre-setup] Setup unsuccessful, 'calibre_postinstall' encountered an error. Exiting now..."
fi
else
echo "[universal-calibre-setup] Skipping setup, Calibre already installed. Exiting now..."
fi
Empty file.
Empty file.
2 changes: 0 additions & 2 deletions scripts/setup-cwa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ change_script_permissions () {
chmod +x /etc/s6-overlay/s6-rc.d/cwa-auto-library/run
chmod +x /etc/s6-overlay/s6-rc.d/cwa-auto-zipper/run
chmod +x /etc/s6-overlay/s6-rc.d/cwa-set-binary-paths/run
chmod +x /etc/s6-overlay/s6-rc.d/universal-calibre-add-packages/run
chmod +x /etc/s6-overlay/s6-rc.d/universal-calibre-package-install/run
chmod +x /etc/s6-overlay/s6-rc.d/universal-calibre-setup/run
chmod 775 /app/calibre-web/cps/editbooks.py
chmod 775 /app/calibre-web/cps/admin.py
Expand Down

0 comments on commit b345c8d

Please sign in to comment.