Skip to content

Commit

Permalink
Merge pull request #296 from darodi/master
Browse files Browse the repository at this point in the history
docker files: define UID/GID for downloaded files, armv7 Dockerfile
  • Loading branch information
Xonshiz committed Oct 17, 2021
2 parents 5ca4c24 + 1e75232 commit a790e7a
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 29 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
git
.gitignore
Dockerfile*
docker-compose*
README.md
LICENSE
45 changes: 24 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
53 changes: 53 additions & 0 deletions Dockerfile.armv7
Original file line number Diff line number Diff line change
@@ -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
47 changes: 39 additions & 8 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,36 +87,45 @@ 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/).

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]
Expand All @@ -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.

Expand Down
2 changes: 2 additions & 0 deletions docker-init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
python /opt/comic-dl/cli.py "$@"

0 comments on commit a790e7a

Please sign in to comment.