forked from crocodilestick/Calibre-Web-Automated
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
161 lines (151 loc) · 6.74 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# syntax=docker/dockerfile:1
FROM ghcr.io/linuxserver/unrar:latest AS unrar
FROM ghcr.io/linuxserver/baseimage-ubuntu:jammy
# Set the default shell for the following RUN instructions to bash instead of sh
SHELL ["/bin/bash", "-c"]
# Old Example Build Command:
# docker build --tag crocodilestick/calibre-web-automated:dev --build-arg="BUILD_DATE=27-09-2024 12:06" --build-arg="VERSION=2.1.0-test-5" .
# New Example Build & Push Command:
# docker buildx build \
# --push \
# --platform linux/arm/v7,linux/arm64/v8,linux/amd64 \
# --build-arg="BUILD_DATE=02-08-2024 20:52" \
# --build-arg="VERSION=2.1.0" \
# --tag crocodilestick/calibre-web-automated:latest .
# set version label
ARG BUILD_DATE
ARG VERSION
ARG CALIBREWEB_RELEASE=0.6.23
ARG LSCW_RELEASE=0.6.23-ls291
LABEL build_version="Version:- ${VERSION}"
LABEL build_type="localbuild"
LABEL build_date="${BUILD_DATE}"
LABEL CW-Stock-version="${CALIBREWEB_RELEASE}"
LABEL maintainer="CrocodileStick"
# Copy local files into the container
COPY --chown=abc:abc . /app/calibre-web-automated/
# STEP 1 - Install stock Calibre-Web
RUN \
# STEP 1.1 - Installs required build & runtime packages
echo "**** install build packages ****" && \
apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
libldap2-dev \
libsasl2-dev \
python3-dev && \
echo "**** install runtime packages ****" && \
apt-get install -y --no-install-recommends \
imagemagick \
ghostscript \
libldap-2.5-0 \
libmagic1 \
libsasl2-2 \
libxi6 \
libxslt1.1 \
python3-venv && \
echo "**** install calibre-web ****" && \
# STEP 1.2 - Check that $CALIBREWEB_RELEASE ARG is not none and if it is, sets the variables value to the most recent tag name
if [ -z ${CALIBREWEB_RELEASE+x} ]; then \
CALIBREWEB_RELEASE=$(curl -sX GET "https://api.github.com/repos/janeczku/calibre-web/releases/latest" \
| awk '/tag_name/{print $4;exit}' FS='[""]'); \
fi && \
# STEP 1.3 - Downloads the tarball of the release stored in $CALIBREWEB_RELEASE from CW's GitHub Repo, saving it into /tmp
curl -o \
/tmp/calibre-web.tar.gz -L \
https://github.com/janeczku/calibre-web/archive/${CALIBREWEB_RELEASE}.tar.gz && \
# STEP 1.4 - Makes /app/calibre-web to extract the downloaded files from the repo to, -p to ignore potential errors that could arise if the folder already existed
mkdir -p \
/app/calibre-web && \
# STEP 1.5 - Extracts the contents of the tar.gz file downloaded from the repo to the /app/calibre-web dir previously created
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
cd /app/calibre-web && \
python3 -m venv /lsiopy && \
pip install -U --no-cache-dir \
pip \
wheel && \
# STEP 1.7 - Installing the required python packages listed in 'requirements.txt' and 'optional-requirements.txt'
# HOWEVER, they are not pulled from PyPi directly, they are pulled from linuxserver's Ubuntu Wheel Index
# This is essentially a repository of precompiled some of the most popular packages with C/C++ source code
# This provides the install maximum compatibility with multiple different architectures including: x86_64, armv71 and aarch64
# You can read more about python wheels here: https://realpython.com/python-wheels/
pip install -U --no-cache-dir --find-links https://wheel-index.linuxserver.io/ubuntu/ -r \
requirements.txt -r \
optional-requirements.txt && \
# STEP 1.8 - Installs the latest release of kepubify
echo "***install kepubify" && \
if [ -z ${KEPUBIFY_RELEASE+x} ]; then \
KEPUBIFY_RELEASE=$(curl -sX GET "https://api.github.com/repos/pgaskin/kepubify/releases/latest" \
| awk '/tag_name/{print $4;exit}' FS='[""]'); \
fi && \
curl -o \
/usr/bin/kepubify -L \
https://github.com/pgaskin/kepubify/releases/download/${KEPUBIFY_RELEASE}/kepubify-linux-64bit && \
# STEP 2 - Install Calibre-Web Automated
echo "~~~~ CWA Install - installing additional required packages ~~~~" && \
# STEP 2.1 - Install additional required packages
apt-get update && \
apt-get install -y --no-install-recommends \
xdg-utils \
inotify-tools \
python3 \
python3-pip \
nano \
sqlite3 && \
# STEP 2.2 - Install additional required python packages
pip install -r /app/calibre-web-automated/requirements.txt && \
# STEP 2.3 - Get required 'root' dir from the linuxserver/docker-calibre-web repo
echo "~~~~ Getting required files from linuxserver/docker-calibre-web... ~~~~" && \
# STEP 2.4.1 - Check the most recent release of linuxserver/docker-calibre-web and store it's tag in LSCW_RELEASE if one was not specified as an ARG
if [[ $LSCW_RELEASE == 'newest' ]]; then \
LSCW_RELEASE=$(curl -sX GET "https://api.github.com/repos/linuxserver/docker-calibre-web/releases/latest" \
| awk '/tag_name/{print $4;exit}' FS='[""]'); \
fi && \
# STEP 2.4.2 - Download the most recent LSCW release to /tmp
curl -o \
/tmp/lscw.tar.gz -L \
https://github.com/linuxserver/docker-calibre-web/archive/refs/tags/${LSCW_RELEASE}.tar.gz && \
# STEP 2.4.3 - Makes /app/calibre-web to extract the downloaded files from the repo to, -p to ignore potential errors that could arise if the folder already existed
mkdir -p \
/tmp/lscw && \
# STEP 2.4.4 - Extract contents of lscw.tat.gz to /tmp/lscw
tar xf \
/tmp/lscw.tar.gz -C \
/tmp/lscw --strip-components=1 && \
# STEP 2.4.5 - Move contents of 'root' dirs to root dir
cp -R /tmp/lscw/root/* / && \
cp -R /app/calibre-web-automated/root/* / && \
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 already exists at root and stock CW already has a method of determiniing it's verison built in
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.
chmod +x /app/calibre-web-automated/scripts/setup-cwa.sh && \
/app/calibre-web-automated/scripts/setup-cwa.sh
# 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 \
libldap2-dev \
libsasl2-dev \
python3-dev && \
apt-get -y autoremove && \
rm -rf \
/tmp/* \
/var/lib/apt/lists/* \
/var/tmp/* \
/root/.cache
# add unrar
COPY --from=unrar /usr/bin/unrar-ubuntu /usr/bin/unrar
# ports and volumes
EXPOSE 8083
VOLUME /config
VOLUME /cwa-book-ingest
VOLUME /calibre-library