Files
calibre-web/Dockerfile

187 lines
5.7 KiB
Docker
Raw Normal View History

FROM debian:trixie-slim AS build
2024-12-26 12:00:07 +01:00
# set version label
ARG BUILD_DATE
ARG VERSION
ARG CALIBREWEB_RELEASE
ARG CALIBRE_INSTALLER_SOURCE_CODE_URL=https://raw.githubusercontent.com/kovidgoyal/calibre/master/setup/linux-installer.py
ARG NETIFACES_PLUS_RELEASE
ARG KEPUBIFY_RELEASE
2024-12-26 12:00:07 +01:00
LABEL build_version="petite-maison-orange.fr version:- ${VERSION} Build-date:- ${BUILD_DATE}"
LABEL maintainer="Eric Coissac <eric@petite-maison-orange.fr>"
2024-12-26 12:00:07 +01:00
RUN cp /etc/apt/sources.list.d/debian.sources \
/etc/apt/sources.list.d/debian.sources.save \
&& sed -e "s/contrib main/contrib main non-free-firmware/g" \
/etc/apt/sources.list.d/debian.sources.save > /etc/apt/sources.list.d/debian.sources
2024-12-26 12:00:07 +01:00
RUN \
echo "**** install build packages ****" 1>&2 \
&& apt update \
&& apt install -y build-essential \
&& apt install -y tzdata \
2024-12-27 16:19:12 +01:00
&& apt install -y libzmq3-dev \
&& apt install -y libldap-dev \
&& apt install -y libsasl2-dev \
&& apt install -y imagemagick \
&& apt install -y git \
&& apt install -y jq \
&& apt install -y curl \
&& apt install -y wget \
&& apt install -y xz-utils \
&& apt install -y bash \
&& apt install -y python3-pip \
&& apt install -y python3-venv \
&& apt install -y python3-dev \
&& apt install -y python3-setuptools \
&& apt install -y golang-go
RUN echo "**** create tmp dir ****" 1>&2 \
&& mkdir -p /tmp
RUN \
2024-12-26 12:00:07 +01:00
echo "**** install Unrar from source" 1>&2 \
&& cd /tmp \
2024-12-26 12:00:07 +01:00
&& curl https://www.rarlab.com/rar/unrarsrc-7.0.9.tar.gz \
| tar zxvf - \
&& cd unrar \
&& sed 's/^DEFINES=/DEFINES=-DUSE_FALLOCATE /' \
makefile > Makefile \
&& make -f Makefile \
2024-12-27 16:19:12 +01:00
&& make -f Makefile install
2024-12-26 12:00:07 +01:00
RUN echo "***install kepubify from source" 1>&2 \
2024-12-27 16:19:12 +01:00
&& go install github.com/pgaskin/kepubify@latest
2024-12-26 12:00:07 +01:00
RUN echo "**** install python3 ****" 1>&2
2024-12-26 12:00:07 +01:00
ENV PYTHONUNBUFFERED=1
RUN python3 -m venv /app \
&& . /app/bin/activate \
&& pip3 install --no-cache --upgrade pip \
&& pip3 install --no-cache --upgrade setuptools \
&& pip3 install --no-cache --upgrade poetry \
2024-12-26 12:00:07 +01:00
&& pip3 install --no-cache cryptography \
&& pip3 install --no-cache ldap3 \
&& pip3 install --no-cache flask-ldap3-login \
&& pip3 install --no-cache --upgrade tzdata \
&& pip3 install --no-cache --upgrade netifaces-plus
COPY patches /tmp/patches
RUN echo "**** install calibre ****" 1>&2 \
# install calibre binary
ENV LD_LIBRARY_PATH=/usr/lib:/opt/calibre/lib
ENV PATH=$PATH:/opt/calibre/bin
ENV LC_ALL=C
ENV CALIBRE_INSTALLER=https://download.calibre-ebook.com/linux-installer.sh
RUN apt install -y libopengl0 \
&& apt install -y libegl1 \
&& apt install -y libxcb-cursor0 \
&& curl -L ${CALIBRE_INSTALLER} \
| sh /dev/stdin
2024-12-26 12:00:07 +01:00
RUN echo "**** download calibre-web ****" 1>&2 \
&& if [ -z ${CALIBREWEB_RELEASE} ]; then \
2024-12-26 12:00:07 +01:00
CALIBREWEB_RELEASE=$(curl -sX GET "https://api.github.com/repos/janeczku/calibre-web/releases/latest" \
| awk '/tag_name/{print $4;exit}' FS='[""]'); \
fi \
&& echo " ---> install version ${CALIBREWEB_RELEASE}" 1>&2 \
&& git clone --depth 1 --branch ${CALIBREWEB_RELEASE} https://github.com/janeczku/calibre-web.git /app/calibreweb
2024-12-26 12:00:07 +01:00
RUN echo "**** apply calibre-web patches ****" 1>&2 \
&& cd /app/calibreweb \
&& for p in /tmp/patches/calibre-web/* ; do \
patch -p0 < ${p} ; \
2024-12-26 12:00:07 +01:00
done
RUN echo "**** build & install calibre-web ****" 1>&2 \
&& . /app/bin/activate \
&& cd /app/calibreweb \
&& pip3 install --no-cache \
-r requirements.txt \
-r optional-requirements.txt
2024-12-27 16:19:12 +01:00
run echo "**** copy unrar and kepubify to app folder ****" 1>&2 \
&& mv /usr/bin/unrar /app/bin \
&& mv ./root/go/bin/kepubify /app/bin
2024-12-26 12:00:07 +01:00
# ports and volumes
EXPOSE 8083
VOLUME /config
VOLUME /books
ENV PUID=1000
ENV PGID=1000
ENV TZ=Europe/Paris
RUN \
echo "**** Setting timezone ****" \
&& ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
&& echo $TZ > /etc/timezone
RUN mkdir -p /config \
&& chown -R ${PUID}:${PGID} /config
2024-12-26 12:00:07 +01:00
2024-12-27 16:19:12 +01:00
FROM debian:trixie-slim AS production
2024-12-27 17:43:55 +01:00
# ports and volumes
EXPOSE 8083
VOLUME /config
VOLUME /books
ENV PUID=1000
ENV PGID=1000
ENV TZ=Europe/Paris
2024-12-27 16:19:12 +01:00
RUN \
echo "**** install production packages ****" 1>&2 \
&& apt update \
&& apt install -y tzdata \
&& apt install -y libzmq5 \
&& apt install -y libldap-2.5-0 \
&& apt install -y libsasl2-2 \
2024-12-27 17:08:01 +01:00
&& apt install -y libnspr4 \
&& apt install -y libnss3 \
2024-12-27 16:19:12 +01:00
&& apt install -y imagemagick \
&& apt install -y bash \
&& apt install -y sudo \
&& apt install -y python3
COPY --from=build /app /app
2024-12-27 17:08:01 +01:00
COPY --from=build /opt/calibre/bin /app/bin
COPY --from=build /opt/calibre/lib/libcalibre-launcher.so /usr/lib/libcalibre-launcher.so
COPY --from=build /opt/calibre/lib/libjpeg.so.8 /usr/lib/libjpeg.so.8
COPY --from=build /opt/calibre/lib/libpython3.11.so.1.0 /usr/lib/libpython3.11.so.1.0
COPY --from=build /opt/calibre/lib/libpoppler.so.130 /usr/lib/libpoppler.so.130
2024-12-27 16:19:12 +01:00
2024-12-27 17:43:55 +01:00
RUN apt-get clean
RUN rm -rf /var/lib/apt/lists/* \
/tmp/* \
/var/tmp/* \
/usr/share/doc/*
RUN yes | /app/bin/pip3 uninstall google-api-python-client
RUN yes | /app/bin/pip3 uninstall gevent
RUN yes | /app/bin/pip3 uninstall greenlet
RUN yes | /app/bin/pip3 uninstall httplib2
RUN yes | /app/bin/pip3 uninstall oauth2client
RUN yes | /app/bin/pip3 uninstall uritemplate
RUN yes | /app/bin/pip3 uninstall pyasn1-modules
RUN yes | /app/bin/pip3 uninstall pyasn1
RUN yes | /app/bin/pip3 uninstall PyDrive2
RUN yes | /app/bin/pip3 uninstall PyYAML
RUN yes | /app/bin/pip3 uninstall rsa
WORKDIR /app
2024-12-26 12:00:07 +01:00
USER ${PUID}:${PGID}
CMD /app/bin/python3 /app/calibreweb/cps.py -p /config/app.db -g /config/gdrive.db -o /config/calibre-web.log