Skip to content

Commit

Permalink
Merge pull request #302 from darodi/pipeline_test
Browse files Browse the repository at this point in the history
docker build pipeline
  • Loading branch information
Xonshiz authored Apr 9, 2022
2 parents ff49183 + 779a4a5 commit d9c0df9
Show file tree
Hide file tree
Showing 8 changed files with 195 additions and 159 deletions.
14 changes: 12 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
.git
.github
build
comic_dl.egg-info
comic_dl/dist
comics
.dockerignore
.gitattributes
.gitignore
Dockerfile*
docker-compose*
.spec
.travis.yml
Dockerfile
venv
README.md
LICENSE
MANIFEST
45 changes: 45 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Docker

on:
workflow_dispatch:
#schedule:
# - cron: '39 5 * * *'
push:
branches: [ master, pipeline_test ]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]

# Don't trigger if it's just a documentation update
paths-ignore:
- '**.md'
- '**.MD'
- '**.yml'
- 'LICENSE'
- '.gitattributes'
- '.gitignore'
- '.dockerignore'

pull_request:
branches: [ master ]

# Don't trigger if it's just a documentation update
paths-ignore:
- '**.md'
- '**.MD'
- '**.yml'
- 'LICENSE'
- '.gitattributes'
- '.gitignore'
- '.dockerignore'

jobs:
build_and_push:
uses: sdr-enthusiasts/common-github-workflows/.github/workflows/build_and_push_image.yml@main
with:
platform_linux_arm32v7_enabled: true
platform_linux_arm64v8_enabled: false
push_enabled: true
ghcr_repo_owner: ${{ github.repository_owner }}
ghcr_repo: ${{ github.repository }}
secrets:
ghcr_token: ${{ secrets.GITHUB_TOKEN }}
31 changes: 1 addition & 30 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,49 +62,20 @@ Temporary Items
/idea
/dist
*.log
*.xml
*.xml
*.iml
*.spec
comic_dl/Logo.ico
comic_dl/build/__main__/warn__main__.txt
*.old
*.pdf
*.old2
comic_dl/build/__main__/xref-__main__.html
*.xml___jb_tmp___
comic_dl/Manga_Eden_Data.json
*.mri
comic_dl/dist/decryptor.py
comic_dl/dist/libwebp-0.6.1-windows-x64/include/webp/decode.h
comic_dl/dist/libwebp-0.6.1-windows-x64/include/webp/demux.h
comic_dl/dist/libwebp-0.6.1-windows-x64/include/webp/encode.h
comic_dl/dist/libwebp-0.6.1-windows-x64/include/webp/mux.h
comic_dl/dist/libwebp-0.6.1-windows-x64/include/webp/mux_types.h
comic_dl/dist/libwebp-0.6.1-windows-x64/include/webp/types.h
comic_dl/dist/libwebp-0.6.1-windows-x64/Readme-mux.txt
comic_dl/dist/libwebp-0.6.1-windows-x64/Readme.txt
comic_dl/dist/libwebp-0.6.1-windows-x64/test.webp
comic_dl/dist/libwebp-0.6.1-windows-x64/test_ref.ppm
comic_dl/dist/out.webp
comic_dl/dist/upx394w/BUGS
comic_dl/dist/upx394w/COPYING
comic_dl/dist/upx394w/LICENSE
comic_dl/dist/upx394w/Manga_Eden_Data.json
comic_dl/dist/Manga_Eden_Data.json
comic_dl/dist/upx394w/NEWS
comic_dl/dist/upx394w/README
comic_dl/dist/upx394w/README.1ST
comic_dl/dist/upx394w/THANKS
comic_dl/dist/upx394w/upx.1
comic_dl/dist/upx394w/upx.doc
comic_dl/dist/upx394w/upx.html
comic_dl/config.json*
comic_dl/build/__main__/localpycos/struct.pyo
comic_dl/__main__.spec,old
comic_dl/build/__main__/warn-__main__.txt
venv/*
build/*
dist/*
comic_dl/build/*
comic_dl/dist/*
/comic_dl.egg-info
113 changes: 90 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,99 @@
# 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

ENV OWNER_UID=1000
ENV OWNER_GID=1000
# alias comic_dl="docker run -it --rm -e PGID=$(id -g) -e PUID=$(id -u) -v $(pwd):/directory:rw -w /directory comic-dl:py3.8-buster comic_dl -dd /directory"

# for armv7,
# cross build it (it takes a few hours on x86_64), or be prepared to wait an eternity
# build with command:
# docker build -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 -e PGID=$(id -g) -e PUID=$(id -u) -v $(pwd):/directory:rw -w /directory comic-dl:py3.8-buster-armv7 comic_dl -dd /directory"

FROM --platform=linux/amd64 python:3.8-slim-buster as stage-amd64
RUN DEBIAN_FRONTEND=noninteractive apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -yq upgrade
ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT
RUN echo "I'm building for $TARGETOS/$TARGETARCH/$TARGETVARIANT"

FROM --platform=linux/arm/v7 python:3.8-slim-buster as stage-armv7
ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT
RUN echo "I'm building for $TARGETOS/$TARGETARCH/$TARGETVARIANT"

ENV LC_ALL=C.UTF-8 \
LANG=C.UTF-8 \
LANGUAGE=en_US:en

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

## qpdf and pikepdf need to be built from source on armv7
RUN set -x && \
TEMP_PACKAGES=() && \
KEPT_PACKAGES=() && \
# Packages only required during build
TEMP_PACKAGES+=(git) && \
TEMP_PACKAGES+=(make) && \
TEMP_PACKAGES+=(build-essential) && \
TEMP_PACKAGES+=(libssl-dev) && \
TEMP_PACKAGES+=(libfreetype6-dev) && \
TEMP_PACKAGES+=(libfontconfig1-dev) && \
TEMP_PACKAGES+=(libjpeg-dev) && \
TEMP_PACKAGES+=(libqpdf-dev) && \
TEMP_PACKAGES+=(libxft-dev) && \
TEMP_PACKAGES+=(libxml2-dev) && \
TEMP_PACKAGES+=(libxslt1-dev) && \
TEMP_PACKAGES+=(zlib1g-dev) && \
# Packages kept in the image
KEPT_PACKAGES+=(bash) && \
KEPT_PACKAGES+=(ca-certificates) && \
KEPT_PACKAGES+=(locales) && \
KEPT_PACKAGES+=(locales-all) && \
KEPT_PACKAGES+=(python3) && \
TEMP_PACKAGES+=(python3-dev) && \
KEPT_PACKAGES+=(python3-pip) && \
KEPT_PACKAGES+=(chrpath) && \
KEPT_PACKAGES+=(libfreetype6) && \
KEPT_PACKAGES+=(libfontconfig1) && \
KEPT_PACKAGES+=(python3-wheel) && \
# Install packages
DEBIAN_FRONTEND=noninteractive apt-get update -y && apt-get -yq upgrade && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
${KEPT_PACKAGES[@]} \
${TEMP_PACKAGES[@]} \
&& \
git config --global advice.detachedHead false && \
# Install required python modules
python -m pip install --upgrade pip && \
python -m pip install --no-cache-dir pybind11 && \
## qpdf and pikepdf need to be built from source on armv7
cd /opt \
&& git clone --branch release-qpdf-10.6.3 https://github.com/qpdf/qpdf.git \
&& git clone --branch v5.1.1 https://github.com/pikepdf/pikepdf.git \
&& cd /opt/qpdf \
&& ./configure \
&& make \
&& make install \
&& cd /opt/pikepdf \
&& pip install . && \
# Clean-up
DEBIAN_FRONTEND=noninteractive apt-get remove -y ${TEMP_PACKAGES[@]} && \
DEBIAN_FRONTEND=noninteractive apt-get autoremove -y && \
DEBIAN_FRONTEND=noninteractive apt-get clean -y && \
rm -rf /var/lib/apt/lists/* /tmp/* /src /opt/qpdf /opt/pikepdf

# Select final stage based on TARGETARCH ARG
FROM stage-${TARGETARCH}${TARGETVARIANT} as final

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/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
cat /opt/comic-dl/comic_dl/__version__.py | grep version | awk '{print $3}' | sed 's/"//g' > /IMAGE_VERSION
53 changes: 0 additions & 53 deletions Dockerfile.armv7

This file was deleted.

60 changes: 12 additions & 48 deletions ReadMe.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
[![N|Solid](https://raw.githubusercontent.com/Xonshiz/comic-dl/master/Images/Icon.png)](https://github.com/Xonshiz/comic-dl)
# Comic-DL | [![Build Status](https://travis-ci.com/Xonshiz/comic-dl.svg?branch=master)](https://travis-ci.com/Xonshiz/comic-dl) [![Documentation Status](https://readthedocs.org/projects/comic-dl/badge/?version=latest)](http://comic-dl.readthedocs.io/en/latest/?badge=latest) | [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/xonshiz) | [![GitHub release](https://img.shields.io/github/release/xonshiz/comic-dl.svg?style=flat-square)](https://github.com/xonshiz/comic-dl/releases/latest) | [![Github All Releases](https://img.shields.io/github/downloads/xonshiz/comic-dl/total.svg?style=flat-square)](https://github.com/xonshiz/comic-dl/releases)
# Comic-DL
[![Build Status](https://travis-ci.com/Xonshiz/comic-dl.svg?branch=master)](https://travis-ci.com/Xonshiz/comic-dl) [![Documentation Status](https://readthedocs.org/projects/comic-dl/badge/?version=latest)](http://comic-dl.readthedocs.io/en/latest/?badge=latest) |
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/xonshiz) |
[![GitHub release](https://img.shields.io/github/release/xonshiz/comic-dl.svg?style=flat-square)](https://github.com/xonshiz/comic-dl/releases/latest) |
[![Github All Releases](https://img.shields.io/github/downloads/xonshiz/comic-dl/total.svg?style=flat-square)](https://github.com/xonshiz/comic-dl/releases) |
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/xonshiz/comic-dl/Docker?label=docker%20build)](https://github.com/xonshiz/comic-dl/pkgs/container/comic-dl/)


Comic-dl is a command line tool to download Comics and Manga from various Manga and Comic sites easily. You can search Manga from this tool as well. Idea from [youtube-dl](https://github.com/rg3/youtube-dl).

Expand All @@ -24,8 +30,6 @@ If you're looking for an application, or a UI for this, please move to : [CoMang
* [List of Arguments](#list-of-arguments)
* [Language Codes](#language-codes)
* [Using The Search](#using-the-search)
* [
Tutorial]()
* [Usage](#usage)
* [Windows](#windows)
* [Linux/Debian](#linuxdebian)
Expand Down Expand Up @@ -101,32 +105,17 @@ With docker, you can get the whole dependencies enclosed in a container and use

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. 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.
[Docker images are available here](https://github.com/Xonshiz/comic-dl/pkgs/container/comic-dl/)

```bash
docker build -t comic-dl:py3.8-buster .
```
Define a handy alias on your system with some docker tricks. This mounts the local directory under `/directory` in the container. This works on *NIX systems, and also under Windows Linux subsystem.

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).
You can change the value of PGID and PUID with the value for the user needed in your download directory.

```bash
alias comic_dl="docker run -it --rm -v $(pwd):/directory -w /directory comic-dl:py3.8-buster comic_dl -dd /directory"
alias comic_dl="docker run -it --rm -e PGID=$(id -g) -e PUID=$(id -u) -v $(pwd):/directory:rw -w /directory ghcr.io/Xonshiz/comic-dl:latest comic_dl -dd /directory"
```

5. Run it on your system. This actually starts a container on request and stop&delete it when finish.
Run it on your system. This actually starts a container on request and stop&delete it when finished.

```bash
usage: comicdl [-h] [--version] [-s SORTING] [-a] [-c]
Expand All @@ -139,28 +128,6 @@ 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 Expand Up @@ -332,9 +299,6 @@ Our example command for One Piece, chapter 2 would be : `comic_dl.exe --page-id
* If you download the chapter separately, you will need to provide the `Manga Name` and `Chapter Number` yourself. Because MangaEden's API doesn't list those values in their JSON reply (weird).


## Youtube Tutorial
[![Check The YouTube Tutorial](https://img.youtube.com/vi/TmQYhLHEZxA/0.jpg)]()

## Usage
With this script, you have to pass arguments in order to be able to download anything. Passing arguments in a script is pretty easy. Since the script is pretty basic, it doesn't have too many arguments. Go check the [`ARGUMENTS SECTION`](https://github.com/Xonshiz/comic-dl#list-of-arguments) to know more about which arguments the script offers.

Expand Down
2 changes: 1 addition & 1 deletion comic_dl/__version__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

__version__ = "2021.09.05"
__version__ = "2022.04.09"
Loading

0 comments on commit d9c0df9

Please sign in to comment.