diff --git a/Dockerfile b/Dockerfile index d054dd1..ddbde1a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,88 +1,116 @@ # syntax=docker/dockerfile:1 -FROM alpine:3.20 +FROM debian:trixie-slim AS build # 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 + LABEL build_version="petite-maison-orange.fr version:- ${VERSION} Build-date:- ${BUILD_DATE}" -LABEL maintainer="eric@petite-maison-orange.fr" +LABEL maintainer="Eric Coissac " + +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 RUN \ echo "**** install build packages ****" 1>&2 \ - && apk add build-base \ - && apk add --update --no-cache linux-headers \ - && apk add --update --no-cache calibre \ - --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing/ \ - && apk add --update --no-cache tzdata \ - && apk add --update --no-cache zeromq-dev \ - && apk add --update --no-cache libldap \ - && apk add --update --no-cache openldap-dev \ - && apk add --update --no-cache libsasl \ - && apk add --update --no-cache imagemagick \ - && apk add --update --no-cache git \ - && apk add --update --no-cache curl + && apt update \ + && apt install -y build-essential \ + && apt install -y tzdata \ + && apt install -y libghc-zeromq4-haskell-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 -RUN \ + RUN echo "**** create tmp dir ****" 1>&2 \ + && mkdir -p /tmp + + RUN \ echo "**** install Unrar from source" 1>&2 \ + && cd /tmp \ && 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 \ - && make -f Makefile install \ - && cd .. + && make -f Makefile install -RUN echo "**** install python3" 1>&2 +RUN echo "**** install python3 ****" 1>&2 ENV PYTHONUNBUFFERED=1 -RUN apk add --update --no-cache python3 \ - && apk add --update --no-cache python3-dev \ - && ln -sf /usr/bin/python3 /usr/bin/python \ - && apk add --update --no-cache py3-pip \ - && apk add --update --no-cache py3-virtualenv \ - && python -m venv /app \ - && source /app/bin/activate \ +RUN python3 -m venv /app \ + && . /app/bin/activate \ && pip3 install --no-cache cryptography \ && pip3 install --no-cache ldap3 \ && pip3 install --no-cache flask-ldap3-login \ && pip3 install --no-cache --upgrade pip setuptools \ - && pip3 install --no-cache netifaces-plus \ - && pip3 install --no-cache --upgrade tzdata + && pip3 install --no-cache --upgrade cython \ + && pip3 install --no-cache --upgrade tzdata \ + && pip3 install --no-cache --upgrade netifaces-plus + +COPY patches /tmp/patches -RUN echo "**** download calibre-web" 1>&2 \ - && if [ -z ${CALIBREWEB_RELEASE+x} ]; then \ +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 + + + +RUN echo "**** download calibre-web ****" 1>&2 \ + && if [ -z ${CALIBREWEB_RELEASE} ]; then \ 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 \ - && https://api.github.com/repos/janeczku/calibre-web/releases/latest - && git clone --depth 1 --branch ${CALIBREWEB_RELEASE} https://github.com/janeczku/calibre-web.git /calibreweb \ - && mkdir -p calibreweb/src \ - && ln -s /calibreweb /calibreweb/src/calibreweb + && git clone --depth 1 --branch ${CALIBREWEB_RELEASE} https://github.com/janeczku/calibre-web.git /tmp/calibreweb \ + && cd /tmp/calibreweb \ + && mkdir -p src \ + && ln -s /tmp/calibreweb /tmp/calibreweb/src/calibreweb -COPY patches calibreweb/src RUN echo "**** apply calibre-web patches ****" 1>&2 \ - && cd calibreweb/src/calibreweb \ - && for p in ../patches/* ; do \ - patch -p1 < ${p} ; \ + && cd /tmp/calibreweb/src/calibreweb \ + && for p in /tmp/patches/calibre-web/* ; do \ + patch -p0 < ${p} ; \ done RUN echo "**** build & install calibre-web ****" 1>&2 \ - && source /app/bin/activate \ - && cd calibreweb \ + && . /app/bin/activate \ + && cd /tmp/calibreweb/src/calibreweb \ && pip3 install -U --no-cache-dir \ -r requirements.txt \ -r optional-requirements.txt \ && cd .. \ - && pip3 install /calibreweb + && pip3 install /tmp/calibreweb RUN echo "***install kepubify" 1>&2 && \ - if [ -z ${KEPUBIFY_RELEASE+x} ]; then \ + if [ -z ${KEPUBIFY_RELEASE} ]; then \ KEPUBIFY_RELEASE=$(curl -sX GET "https://api.github.com/repos/pgaskin/kepubify/releases/latest" \ | awk '/tag_name/{print $4;exit}' FS='[""]'); \ fi \ @@ -105,8 +133,8 @@ echo "**** Setting timezone ****" \ && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \ && echo $TZ > /etc/timezone -RUN if [[ ! -f /config ]] ; then mkdir -p /config ; fi -RUN chown -R ${PUID}:${PGID} /config +RUN mkdir -p /config \ + && chown -R ${PUID}:${PGID} /config USER ${PUID}:${PGID} diff --git a/README.md b/README.md index 99c399f..8a31153 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,8 @@ ```bash diff -c cps/templates/remote_login.html ../calibre-web/cps/templates/remote_login.html > remote_login.patch +``` + +Build the image on mac OS with orbstack docker: +```bash +docker build . --platform linux/amd64 --debug ``` \ No newline at end of file diff --git a/patches/remote_login_py.patch b/patches/calibre-web/remote_login_py.patch similarity index 100% rename from patches/remote_login_py.patch rename to patches/calibre-web/remote_login_py.patch diff --git a/patches/remote_login_template.patch b/patches/calibre-web/remote_login_template.patch similarity index 100% rename from patches/remote_login_template.patch rename to patches/calibre-web/remote_login_template.patch