diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..24b2a73 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +git +.gitignore +Dockerfile* +docker-compose* +README.md +LICENSE \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 8df25b4..339eae2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,29 +1,32 @@ -# this buld the base image to run comic_dl -FROM python:3.6.5-slim-stretch AS base +# build with command: +# docker build -t comic-dl:py3.8-buster . +# run with alias +# alias comic_dl="docker run -it --rm -v $(pwd):/directory -w /directory comic-dl:py3.8-buster comic_dl -dd /directory" + +# this builds the base image to run comic_dl +FROM python:3.8-slim-buster AS base RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get -yq upgrade # update system & install basisc stuff # and dependencies for phantomjs -RUN DEBIAN_FRONTEND=noninteractive apt-get install -yq \ - build-essential \ - chrpath \ - libssl-dev \ - libxft-dev \ - libfreetype6 \ - libfreetype6-dev \ - libfontconfig1 \ - libfontconfig1-dev - #wget nodejs-legacy +# RUN DEBIAN_FRONTEND=noninteractive apt-get install -yq \ +# build-essential \ +# chrpath \ +# libssl-dev \ +# libxft-dev \ +# libfreetype6 \ +# libfreetype6-dev \ +# libfontconfig1 \ +# libfontconfig1-dev -# We're not using PhantomJS anymore. So, this step should be removed for now. -# install phantomjs and symlink to /usr/local/bin/ -#RUN wget -q https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 && \ -# tar xvjf phantomjs-2.1.1-linux-x86_64.tar.bz2 -C /usr/local/share/ && \ -# ln -s /usr/local/share/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin/ +ENV OWNER_UID=1000 +ENV OWNER_GID=1000 -# This install comic-dl and symlink to comic_dl command -ENV PYTHONPATH "${PYTHONPATH}:/opt/comic-dl/comic_dl/" COPY / /opt/comic-dl RUN python -m pip install --upgrade pip && \ python -m pip install -r /opt/comic-dl/requirements.txt && \ - chmod +x /opt/comic-dl/comic_dl/__main__.py && \ - cp /opt/comic-dl/comic_dl/__main__.py /usr/local/bin/comic_dl + chmod +x /opt/comic-dl/docker-init.sh && \ + ln -s /opt/comic-dl/docker-init.sh /usr/local/bin/comic_dl && \ + addgroup --gid ${OWNER_GID} comic-dl && \ + adduser --disabled-password -home /home/comic-dl --gid ${OWNER_GID} --uid ${OWNER_UID} --gecos "" comic-dl + +USER comic-dl \ No newline at end of file diff --git a/Dockerfile.armv7 b/Dockerfile.armv7 new file mode 100644 index 0000000..ec9def5 --- /dev/null +++ b/Dockerfile.armv7 @@ -0,0 +1,53 @@ +# cross build it (it takes a few hours on x86_64), or be prepared to wait an eternity +# build with command: +# docker build -f Dockerfile.armv7 -t comic-dl:py3.8-buster-armv7 --platform linux/arm/v7 . +# export with command +# docker save -o comic-dl.tar comic-dl:py3.8-buster-armv7 +# import on arm machine with command: +# docker load --input comic-dl.tar +# run with alias: +# alias comic_dl="docker run -it --rm -v $(pwd):/directory -w /directory comic-dl:py3.8-buster-armv7 comic_dl -dd /directory" + +FROM python:3.8-slim-buster AS builder +RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get -yq upgrade \ + && apt-get install -yq \ + build-essential \ + chrpath \ + git \ + libssl-dev \ + libfreetype6 \ + libfreetype6-dev \ + libfontconfig1 \ + libfontconfig1-dev \ + libjpeg-dev \ + libqpdf-dev \ + libxft-dev \ + libxml2-dev \ + libxslt1-dev \ + python3-wheel \ + zlib1g-dev + +## qpdf and pikepdf need to be built from source on armv7 +RUN python -m pip install --upgrade pip \ + && pip install pybind11 \ + && cd /opt \ + && git clone https://github.com/qpdf/qpdf.git \ + && git clone https://github.com/pikepdf/pikepdf.git \ + && cd /opt/qpdf \ + && ./configure \ + && make \ + && make install \ + && cd /opt/pikepdf \ + && pip install . + +ENV OWNER_UID=1000 +ENV OWNER_GID=1000 + +COPY / /opt/comic-dl +RUN python -m pip install -r /opt/comic-dl/requirements.txt && \ + chmod +x /opt/comic-dl/docker-init.sh && \ + ln -s /opt/comic-dl/docker-init.sh /usr/local/bin/comic_dl && \ + addgroup --gid ${OWNER_GID} comic-dl && \ + adduser --disabled-password -home /home/comic-dl --gid ${OWNER_GID} --uid ${OWNER_UID} --gecos "" comic-dl + +USER comic-dl \ No newline at end of file diff --git a/ReadMe.md b/ReadMe.md index 40fd2ce..b58a11b 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -87,16 +87,16 @@ The instructions for all the OS would remain same. Download [`THIS REPOSITORY`]( **Linux/Debian** users make sure that this script is executable.just run this command, if you run into problem(s) : -`chmod +x __main__.py` +`chmod +x cli.py` and then, execute with this : -`./__main__.py` +`./cli.py` ### Docker -With docker you can get the whole dependencies enclosed in a container and use the `comic_dl` from your system. +With docker, you can get the whole dependencies enclosed in a container and use the `comic_dl` from your system. You need an up and running Docker client running, follow the [Docker Documentation](https://docs.docker.com/install/). @@ -104,19 +104,28 @@ A minimal example is here, you can change each step as you wish. 1. Clone this repo with `git clone [REPOSITORY URL.git]` -2. Build the image and give a name and a tag in the format `name:tag`. Here we are using `python:3.6.5-stretch` as base image, hence he tag. +2. edit the OWNER_UID and OWNER_GID in the Dockerfile with the user needed in your download directory + +you can determine the UID GID with the command `id` + +```bash +user@DESKTOP:/home/user$ id +uid=1000(user) gid=1000(user) +``` + +3. Build the image and give a name and a tag in the format `name:tag`. Here we are using `python:3.6.5-stretch` as base image, hence he tag. ```bash -docker build -t comic-dl:py3.6.5-stretch . +docker build -t comic-dl:py3.8-buster . ``` -3. Define an handy alias on your system with some docker tricks. This mounts the local directory under `/directory` in the container. This works on *NIX sistem, maybe also under Windows Linux subsystem (we need to Check). +4. Define an handy alias on your system with some docker tricks. This mounts the local directory under `/directory` in the container. This works on *NIX sistem, maybe also under Windows Linux subsystem (we need to Check). ```bash -alias comic_dl="docker run -it --rm -v $(pwd):/directory -w /directory comic-dl:py3.6.5-stretch comic_dl -dd /directory" +alias comic_dl="docker run -it --rm -v $(pwd):/directory -w /directory comic-dl:py3.8-buster comic_dl -dd /directory" ``` -4. Run it on your system. This actually starts a container on request and stop&delete it when finish. +5. Run it on your system. This actually starts a container on request and stop&delete it when finish. ```bash usage: comicdl [-h] [--version] [-s SORTING] [-a] [-c] @@ -129,6 +138,28 @@ usage: comicdl [-h] [--version] [-s SORTING] [-a] [-c] [...] ``` +### Docker armv7 + +It is recommended to cross build it. It takes a few hours on x86_64. + +qpdf and pikepdf need to be built from source on armv7. + +```bash +docker build -f Dockerfile.armv7 -t comic-dl:py3.8-buster-armv7 --platform linux/arm/v7 . +docker save -o comic-dl.tar comic-dl:py3.8-buster-armv7 +``` + +and then import it on your arm machine. +```bash +docker load --input comic-dl.tar +``` + +and then use the correct alias: + +```bash +alias comic_dl="docker run -it --rm -v $(pwd):/directory -w /directory comic-dl:py3.8-buster-armv7 comic_dl -dd /directory" +``` + ## Python Support This script supports python 3. You can run this on python 2 as well, as long as you have all the dependencies installed. diff --git a/docker-init.sh b/docker-init.sh new file mode 100644 index 0000000..2214847 --- /dev/null +++ b/docker-init.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +python /opt/comic-dl/cli.py "$@" \ No newline at end of file