From 2a26e1f64262f10d5b0ca219cc4a1cf23fcd82f7 Mon Sep 17 00:00:00 2001 From: Joey Hafner Date: Tue, 12 Jul 2022 07:07:43 +0000 Subject: [PATCH 1/4] Copy CI and Dockerfile from jafner/docker-calibre-web --- .gitlab-ci.yml | 11 +++++++++ Dockerfile | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 .gitlab-ci.yml create mode 100644 Dockerfile diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..869f3401 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,11 @@ +build_image: + image: docker + stage: build + services: + - docker:dind + script: + - echo $CI_REGISTRY_USER + - echo $CI_REGISTRY + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + - docker build --no-cache -t $CI_REGISTRY/jafner/calibre-web/calibre-web:$CI_COMMIT_SHA -t $CI_REGISTRY/jafner/calibre-web/calibre-web:latest . + - docker push $CI_REGISTRY/jafner/calibre-web/calibre-web --all-tags diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..715f47ad --- /dev/null +++ b/Dockerfile @@ -0,0 +1,67 @@ +FROM ghcr.io/linuxserver/baseimage-ubuntu:focal + +RUN \ + echo "**** install build packages ****" && \ + apt-get update && \ + apt-get install -y \ + git \ + libldap2-dev \ + libsasl2-dev \ + python3-pip + +RUN \ + echo "**** install runtime packages ****" && \ + apt-get install -y \ + imagemagick \ + libnss3 \ + libxcomposite1 \ + libxi6 \ + libxslt1.1 \ + libldap-2.4-2 \ + libsasl2-2 \ + libxrandr2 \ + python3-minimal \ + python3-pkg-resources \ + unrar + +RUN \ + 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 + +RUN \ + echo "**** install calibre-web (a worse way than LSIO's method) ****" && \ + # this is my lazy alternative to lsio's pretty one: + git clone https://gitlab.jafner.net/Jafner/calibre-web.git /app/calibre-web && \ + cd /app/calibre-web && \ + pip3 install --no-cache-dir -U \ + pip && \ + pip install --no-cache-dir -U --ignore-installed --find-links https://wheel-index.linuxserver.io/ubuntu/ -r \ + requirements.txt -r \ + optional-requirements.txt + +RUN \ + echo "**** cleanup ****" && \ + apt-get -y purge \ + git \ + libldap2-dev \ + libsasl2-dev \ + python3-pip && \ + apt-get -y autoremove && \ + rm -rf \ + /tmp/* \ + /var/lib/apt/lists/* \ + /var/tmp/* \ + /root/.cache + +# add local files +COPY root/ / + +# ports and volumes +EXPOSE 8083 +VOLUME /config From 3e88c31c70a9d96d2a6438c6c464d58674ebf373 Mon Sep 17 00:00:00 2001 From: Joey Hafner Date: Tue, 12 Jul 2022 07:16:17 +0000 Subject: [PATCH 2/4] Install calibre-web properly --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 715f47ad..27cd359f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,10 +34,10 @@ RUN \ /usr/bin/kepubify -L \ https://github.com/pgaskin/kepubify/releases/download/${KEPUBIFY_RELEASE}/kepubify-linux-64bit +COPY . /app/calibre-web + RUN \ echo "**** install calibre-web (a worse way than LSIO's method) ****" && \ - # this is my lazy alternative to lsio's pretty one: - git clone https://gitlab.jafner.net/Jafner/calibre-web.git /app/calibre-web && \ cd /app/calibre-web && \ pip3 install --no-cache-dir -U \ pip && \ From dac96ba101206bbd2f873fd2f577c9cb5de332ee Mon Sep 17 00:00:00 2001 From: Joey Hafner Date: Tue, 12 Jul 2022 00:31:12 -0700 Subject: [PATCH 3/4] Add missing /root --- .gitignore | 1 - root/defaults/app.db | Bin 0 -> 81920 bytes root/defaults/policy.xml | 80 ++++++++++++++++++++++++++++ root/etc/cont-init.d/30-config | 49 +++++++++++++++++ root/etc/services.d/calibre-web/run | 6 +++ 5 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 root/defaults/app.db create mode 100644 root/defaults/policy.xml create mode 100644 root/etc/cont-init.d/30-config create mode 100644 root/etc/services.d/calibre-web/run diff --git a/.gitignore b/.gitignore index 14da8a03..a4b97f90 100644 --- a/.gitignore +++ b/.gitignore @@ -21,7 +21,6 @@ vendor/ .pylint.d # calibre-web -*.db *.log cps/cache diff --git a/root/defaults/app.db b/root/defaults/app.db new file mode 100644 index 0000000000000000000000000000000000000000..752e6916ddd7769ac4e43dd8447d2394fb340fd4 GIT binary patch literal 81920 zcmeI)?Qh%09S3kyPAtieqNGV63|ku3ZD0#g5?g+VlNM_fTS<*NcIt-(0g5pv@?>$Q zNQI>Q02mmYY$&jo+aIu3d$$++XZB|lMc*vIHlY0-MM|VhEA3JYt@;%#TjD+N?sIqK z-9^ggXRC(CmAdUTnWxN37bIDh?kkEUN%!b^nVx6qIYQ4eJuX%18aNetqpP zOUyKC4!`-7*FHM)+o{UYR)Zf^tfOV_94#CCXqmb6+B&Kl{*#Lr^mdsy>FN6Kn*MLM z__=%Ia^V}()|lC_T~Gd_sk7G4s9{l62tWV=5P$##AOHafKmY;|fB*y_009U<00Izz z00bZa0SG_<0uX?}unW)!9sKY1i|_g40Rad=00Izz00bZa0SG_<0uX?}kO_3Y|NmOb zzaFxRp*j$N00bZa0SG_<0uX=z1Rwwb2&CmR(xvS6Ti3<eAb|Bhx&j0s009U<00Izz z00bZa0SG`~_yw^3AO1E*4Iuyl2tWV=5P$##AOHafKmY<`f&kzDM@N7F1Rwwb2tWV= z5P$##AOHaf47C9M{eP&N7nOqm1Rwwb2tWV=5P$##AOHaf_ySn}qa#270uX=z1Rwwb z2tWV=5P$##hF<{d|KV?A)DQv?fB*y_009U<00Izz00bZ)*8i#ej+Fm`e&GQD2tWV= z5P$##AOHafK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DpSD) zNHjmQ%r~)yXX&!7~~pU{(CXUipR}Sf9mz>ra$!(*WM;`cEi8v*wiaL zI$-MMH(qaACMqaWsqsT~+o9V;*tp8l`s%8f;7zQpFI6_H6JaV*lKz`f65+%3jq1vy zHNiR+6riYVR3BD1s%uNtO+_5@y{W$E&!!94ugk}DsidhUO&AQi%K3ML=Q0j;7M(3l`n_Z_?0KSA{iPo(<}xj5eDq@}|KR+ea&zat9{=~aGFBS>IP>?+tIWGU zwV6E13jqi~00RFffmffOPZzFSk-zw*e?Jpqaj>EkNxfmnvNE2cl;ZF*{9u2|}PWiFVNP0f_2i>3IgI-Hn>sY<(srPG?r|EgUq zoj9F;F!$@LMsI#rd~$KLaN~yj ztg|on!Zc`&@6tq^TeP~2zr7r5^1i?+(U2udSKmj$h=`g~>_z)q8$_u*Gi0lVAZGdviY4 z7baq1bR9T#N7F3b9YPVNdZ&Fk9@i(Ya17C}Me-TtED{Sw|bRGB#S+zJ1!&CRoyno=w}WyWCP|P8=G4xtUEDZr_&w zuGJlN%tscl3(n7vz6wmu^X;4Rbu7Nf)kNlV9HTRdsvc68rIP_eD0Q z*gZTzFJW9IxV>o@4eV_+jy_DM3x$IGveO&rLl uzVzbX|KKSv0uX=z1Rwwb2tWV=5P$##AOL}(63ECSS7fo7kop!hptcVH literal 0 HcmV?d00001 diff --git a/root/defaults/policy.xml b/root/defaults/policy.xml new file mode 100644 index 00000000..5ec3385c --- /dev/null +++ b/root/defaults/policy.xml @@ -0,0 +1,80 @@ + + + + + + + + +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/root/etc/cont-init.d/30-config b/root/etc/cont-init.d/30-config new file mode 100644 index 00000000..4ca17b9e --- /dev/null +++ b/root/etc/cont-init.d/30-config @@ -0,0 +1,49 @@ +#!/usr/bin/with-contenv bash + +# create symlinks for imagemagick policy.xml +[[ -f /etc/ImageMagick-6/policy.xml ]] && \ + rm /etc/ImageMagick-6/policy.xml +[[ ! -L /etc/ImageMagick-6/policy.xml ]] && \ + ln -s /defaults/policy.xml /etc/ImageMagick-6/policy.xml + +# create symlinks for database and log +[[ ! -f /config/app.db ]] && \ + cp /defaults/app.db /config/app.db +[[ -f /app/calibre-web/app.db ]] && \ + rm /app/calibre-web/app.db +[[ ! -L /app/calibre-web/app.db ]] && \ + ln -s /config/app.db /app/calibre-web/app.db + +# create symlinks for log +[[ ! -f /config/calibre-web.log ]] && \ + touch /config/calibre-web.log +[[ -f /app/calibre-web/calibre-web.log ]] && \ + rm /app/calibre-web/calibre-web.log +[[ ! -L /app/calibre-web/calibre-web.log ]] && \ + ln -s /config/calibre-web.log /app/calibre-web/calibre-web.log + +# create Google drive client_secrets.json file +[[ ! -f /config/client_secrets.json ]] && \ + echo "{}" > /config/client_secrets.json +[[ -f /app/calibre-web/client_secrets.json ]] && + rm /app/calibre-web/client_secrets.json +[[ ! -L /app/calibre-web/client_secrets.json ]] && + ln -s /config/client_secrets.json /app/calibre-web/client_secrets.json + +# create Google drive symlinks for database +[[ ! -f /config/gdrive.db ]] && \ + cp /app/calibre-web/gdrive.db /config/gdrive.db +[[ -f /app/calibre-web/gdrive.db ]] && \ + rm /app/calibre-web/gdrive.db +[[ ! -L /app/calibre-web/gdrive.db ]] && \ + ln -s /config/gdrive.db /app/calibre-web/gdrive.db + +# check if kepubify is present and if so make executable +[[ -f /usr/bin/kepubify ]] && \ +[[ ! -x /usr/bin/kepubify ]] && \ + chmod +x /usr/bin/kepubify + +# permissions +chown -R abc:abc \ + /config \ + /app/calibre-web diff --git a/root/etc/services.d/calibre-web/run b/root/etc/services.d/calibre-web/run new file mode 100644 index 00000000..98523a39 --- /dev/null +++ b/root/etc/services.d/calibre-web/run @@ -0,0 +1,6 @@ +#!/usr/bin/with-contenv bash + +cd /app/calibre-web || exit + +exec \ + s6-setuidgid abc python3 /app/calibre-web/cps.py From 85327808322c460ea06a818b5efa611cd02b4f5f Mon Sep 17 00:00:00 2001 From: Joey Hafner Date: Tue, 12 Jul 2022 07:40:44 +0000 Subject: [PATCH 4/4] Switch to short sha tagging --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 869f3401..d3aa9468 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,5 +7,5 @@ build_image: - echo $CI_REGISTRY_USER - echo $CI_REGISTRY - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - - docker build --no-cache -t $CI_REGISTRY/jafner/calibre-web/calibre-web:$CI_COMMIT_SHA -t $CI_REGISTRY/jafner/calibre-web/calibre-web:latest . + - docker build --no-cache -t $CI_REGISTRY/jafner/calibre-web/calibre-web:$CI_COMMIT_SHORT_SHA -t $CI_REGISTRY/jafner/calibre-web/calibre-web:latest . - docker push $CI_REGISTRY/jafner/calibre-web/calibre-web --all-tags