diff --git a/.github/workflows/docker-base-publish.yml b/.github/workflows/docker-base-publish.yml new file mode 100644 index 0000000..7c692a4 --- /dev/null +++ b/.github/workflows/docker-base-publish.yml @@ -0,0 +1,34 @@ +name: Docker base + +on: + workflow_dispatch: + push: + tags: [ 'docker-base-*' ] + + # Don't trigger if it's just a documentation update + paths-ignore: + - '**.md' + - '**.MD' + - '**.yml' + - 'docs/**' + - 'LICENSE' + - '.gitattributes' + - '.gitignore' + - '.dockerignore' + + +jobs: + build_and_push: + uses: sdr-enthusiasts/common-github-workflows/.github/workflows/build_and_push_image.yml@main + with: + docker_build_file: ./Dockerfile-base + platform_linux_arm32v7_enabled: true + platform_linux_arm64v8_enabled: true + platform_linux_amd64_enabled: true + push_enabled: true + build_nohealthcheck: false + ghcr_repo_owner: ${{ github.repository_owner }} + ghcr_repo: ${{ github.repository }} + build_latest: false + secrets: + ghcr_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 69468bb..be58fd2 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -2,10 +2,7 @@ name: Docker on: workflow_dispatch: - #schedule: - # - cron: '39 5 * * *' push: -# branches: [ master, pipeline_test, docker_test ] # Publish semver tags as releases. tags: [ 'v*.*.*' ] diff --git a/.github/workflows/package-linux.yml b/.github/workflows/package-linux.yml index 39c7354..2e31eed 100644 --- a/.github/workflows/package-linux.yml +++ b/.github/workflows/package-linux.yml @@ -34,7 +34,7 @@ jobs: - name: Install python dependencies run: | sudo apt-get update - sudo apt-get install -y libpng-dev libjpeg-dev p7zip-full python3-pyqt5 python3-pip squashfs-tools libfuse2 + sudo apt-get install -y libpng-dev libjpeg-dev p7zip-full p7zip-rar python3-pyqt5 python3-pip squashfs-tools libfuse2 python -m pip install --upgrade pip setuptools wheel certifi pyinstaller PyQt6 --no-binary pyinstaller python -m pip install -r requirements.txt - name: build binary diff --git a/Dockerfile b/Dockerfile index 235e4bf..731def0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,147 +1,5 @@ -FROM --platform=linux/amd64 python:3.11-slim-buster as compile-amd64 -ARG TARGETOS -ARG TARGETARCH -ARG TARGETVARIANT -RUN echo "I'm building for $TARGETOS/$TARGETARCH/$TARGETVARIANT" - - -COPY requirements.txt /opt/kcc/ -ENV PATH="/opt/venv/bin:$PATH" -RUN DEBIAN_FRONTEND=noninteractive apt-get update -y && apt-get -yq upgrade && \ - apt-get install -y libpng-dev libjpeg-dev p7zip-full unrar-free libgl1 python3-pyqt5 && \ - python -m pip install --upgrade pip && \ - python -m venv /opt/venv && \ - python -m pip install -r /opt/kcc/requirements.txt - - -###################################################################################### - -FROM --platform=linux/arm64 python:3.11-slim-buster as compile-arm64 -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"] - -RUN set -x && \ - TEMP_PACKAGES=() && \ - KEPT_PACKAGES=() && \ - # Packages only required during build - TEMP_PACKAGES+=(build-essential) && \ - TEMP_PACKAGES+=(cmake) && \ - TEMP_PACKAGES+=(libfreetype6-dev) && \ - TEMP_PACKAGES+=(libfontconfig1-dev) && \ - TEMP_PACKAGES+=(libpng-dev) && \ - TEMP_PACKAGES+=(libjpeg-dev) && \ - TEMP_PACKAGES+=(libssl-dev) && \ - TEMP_PACKAGES+=(libxft-dev) && \ - TEMP_PACKAGES+=(make) && \ - TEMP_PACKAGES+=(python3-dev) && \ - TEMP_PACKAGES+=(python3-setuptools) && \ - TEMP_PACKAGES+=(python3-wheel) && \ - # Packages kept in the image - KEPT_PACKAGES+=(bash) && \ - KEPT_PACKAGES+=(ca-certificates) && \ - KEPT_PACKAGES+=(chrpath) && \ - KEPT_PACKAGES+=(locales) && \ - KEPT_PACKAGES+=(locales-all) && \ - KEPT_PACKAGES+=(libfreetype6) && \ - KEPT_PACKAGES+=(libfontconfig1) && \ - KEPT_PACKAGES+=(p7zip-full) && \ - KEPT_PACKAGES+=(python3) && \ - KEPT_PACKAGES+=(python3-pip) && \ - KEPT_PACKAGES+=(python-pyqt5) && \ - KEPT_PACKAGES+=(qt5-default) && \ - KEPT_PACKAGES+=(unrar-free) && \ - # 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[@]} \ - && \ - # Install required python modules - python -m pip install --upgrade pip && \ -# python -m pip install -r /opt/kcc/requirements.txt && \ - python -m venv /opt/venv && \ - python -m pip install --upgrade pillow python-slugify psutil raven mozjpeg-lossless-optimization - - -###################################################################################### - -FROM --platform=linux/arm/v7 python:3.11-slim-buster as compile-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"] - -RUN set -x && \ - TEMP_PACKAGES=() && \ - KEPT_PACKAGES=() && \ - # Packages only required during build - TEMP_PACKAGES+=(build-essential) && \ - TEMP_PACKAGES+=(cmake) && \ - TEMP_PACKAGES+=(libffi-dev) && \ - TEMP_PACKAGES+=(libfreetype6-dev) && \ - TEMP_PACKAGES+=(libfontconfig1-dev) && \ - TEMP_PACKAGES+=(libpng-dev) && \ - TEMP_PACKAGES+=(libjpeg-dev) && \ - TEMP_PACKAGES+=(libssl-dev) && \ - TEMP_PACKAGES+=(libxft-dev) && \ - TEMP_PACKAGES+=(make) && \ - TEMP_PACKAGES+=(python3-dev) && \ - TEMP_PACKAGES+=(python3-setuptools) && \ - TEMP_PACKAGES+=(python3-wheel) && \ - # Packages kept in the image - KEPT_PACKAGES+=(bash) && \ - KEPT_PACKAGES+=(ca-certificates) && \ - KEPT_PACKAGES+=(chrpath) && \ - KEPT_PACKAGES+=(locales) && \ - KEPT_PACKAGES+=(locales-all) && \ - KEPT_PACKAGES+=(libfreetype6) && \ - KEPT_PACKAGES+=(libfontconfig1) && \ - KEPT_PACKAGES+=(p7zip-full) && \ - KEPT_PACKAGES+=(python3) && \ - KEPT_PACKAGES+=(python3-pip) && \ - KEPT_PACKAGES+=(python-pyqt5) && \ - KEPT_PACKAGES+=(qt5-default) && \ - KEPT_PACKAGES+=(unrar-free) && \ - # 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[@]} \ - && \ - # Install required python modules - python -m pip install --upgrade pip && \ -# python -m pip install -r /opt/kcc/requirements.txt && \ - python -m venv /opt/venv && \ - python -m pip install --upgrade pillow python-slugify psutil raven mozjpeg-lossless-optimization - - -###################################################################################### -FROM --platform=linux/amd64 python:3.11-slim-buster as build-amd64 -COPY --from=compile-amd64 /opt/venv /opt/venv - -FROM --platform=linux/arm64 python:3.11-slim-buster as build-arm64 -COPY --from=compile-arm64 /opt/venv /opt/venv - -FROM --platform=linux/arm/v7 python:3.11-slim-buster as build-armv7 -COPY --from=compile-armv7 /opt/venv /opt/venv -###################################################################################### - # Select final stage based on TARGETARCH ARG -FROM build-${TARGETARCH}${TARGETVARIANT} +FROM ghcr.io/ciromattia/kcc:docker-base-20230514 LABEL com.kcc.name="Kindle Comic Converter" LABEL com.kcc.author="Ciro Mattia Gonano, Paweł Jastrzębski and Darodi" LABEL org.opencontainers.image.description='Kindle Comic Converter' @@ -154,14 +12,8 @@ LABEL org.opencontainers.image.vendor='ciromattia' LABEL org.opencontainers.image.licenses='ISC' LABEL org.opencontainers.image.title="Kindle Comic Converter" - -ENV PATH="/opt/venv/bin:$PATH" -WORKDIR /app COPY . /opt/kcc -RUN DEBIAN_FRONTEND=noninteractive apt-get update -y && apt-get -yq upgrade && \ - apt-get install -y p7zip-full unrar-free && \ - ln -s /app/kindlegen /bin/kindlegen && \ - cat /opt/kcc/kindlecomicconverter/__init__.py | grep version | awk '{print $3}' | sed "s/'//g" > /IMAGE_VERSION +RUN cat /opt/kcc/kindlecomicconverter/__init__.py | grep version | awk '{print $3}' | sed "s/'//g" > /IMAGE_VERSION ENTRYPOINT ["/opt/kcc/kcc-c2e.py"] CMD ["-h"] \ No newline at end of file diff --git a/Dockerfile-base b/Dockerfile-base new file mode 100644 index 0000000..7013b8a --- /dev/null +++ b/Dockerfile-base @@ -0,0 +1,162 @@ +FROM --platform=linux/amd64 python:3.11-slim-bullseye as compile-amd64 +ARG TARGETOS +ARG TARGETARCH +ARG TARGETVARIANT +RUN echo "I'm building for $TARGETOS/$TARGETARCH/$TARGETVARIANT" + + +COPY requirements.txt /opt/kcc/ +ENV PATH="/opt/venv/bin:$PATH" +RUN DEBIAN_FRONTEND=noninteractive apt-get update -y && apt-get -yq upgrade && \ + apt-get install -y libpng-dev libjpeg-dev p7zip-full unrar-free libgl1 python3-pyqt5 && \ + python -m pip install --upgrade pip && \ + python -m venv /opt/venv && \ + python -m pip install -r /opt/kcc/requirements.txt + + +###################################################################################### + +FROM --platform=linux/arm64 python:3.11-slim-bullseye as compile-arm64 +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"] + +RUN set -x && \ + TEMP_PACKAGES=() && \ + KEPT_PACKAGES=() && \ + # Packages only required during build + TEMP_PACKAGES+=(build-essential) && \ + TEMP_PACKAGES+=(cmake) && \ + TEMP_PACKAGES+=(libfreetype6-dev) && \ + TEMP_PACKAGES+=(libfontconfig1-dev) && \ + TEMP_PACKAGES+=(libpng-dev) && \ + TEMP_PACKAGES+=(libjpeg-dev) && \ + TEMP_PACKAGES+=(libssl-dev) && \ + TEMP_PACKAGES+=(libxft-dev) && \ + TEMP_PACKAGES+=(make) && \ + TEMP_PACKAGES+=(python3-dev) && \ + TEMP_PACKAGES+=(python3-setuptools) && \ + TEMP_PACKAGES+=(python3-wheel) && \ + # Packages kept in the image + KEPT_PACKAGES+=(bash) && \ + KEPT_PACKAGES+=(ca-certificates) && \ + KEPT_PACKAGES+=(chrpath) && \ + KEPT_PACKAGES+=(locales) && \ + KEPT_PACKAGES+=(locales-all) && \ + KEPT_PACKAGES+=(libfreetype6) && \ + KEPT_PACKAGES+=(libfontconfig1) && \ + KEPT_PACKAGES+=(p7zip-full) && \ + KEPT_PACKAGES+=(python3) && \ + KEPT_PACKAGES+=(python3-pip) && \ + KEPT_PACKAGES+=(python3-pyqt5) && \ + KEPT_PACKAGES+=(unrar-free) && \ + # 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[@]} \ + && \ + # Install required python modules + python -m pip install --upgrade pip && \ +# python -m pip install -r /opt/kcc/requirements.txt && \ + python -m venv /opt/venv && \ + python -m pip install --upgrade pillow python-slugify psutil raven mozjpeg-lossless-optimization + + +###################################################################################### + +FROM --platform=linux/arm/v7 python:3.11-slim-bullseye as compile-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"] + +RUN set -x && \ + TEMP_PACKAGES=() && \ + KEPT_PACKAGES=() && \ + # Packages only required during build + TEMP_PACKAGES+=(build-essential) && \ + TEMP_PACKAGES+=(cmake) && \ + TEMP_PACKAGES+=(libffi-dev) && \ + TEMP_PACKAGES+=(libfreetype6-dev) && \ + TEMP_PACKAGES+=(libfontconfig1-dev) && \ + TEMP_PACKAGES+=(libpng-dev) && \ + TEMP_PACKAGES+=(libjpeg-dev) && \ + TEMP_PACKAGES+=(libssl-dev) && \ + TEMP_PACKAGES+=(libxft-dev) && \ + TEMP_PACKAGES+=(make) && \ + TEMP_PACKAGES+=(python3-dev) && \ + TEMP_PACKAGES+=(python3-setuptools) && \ + TEMP_PACKAGES+=(python3-wheel) && \ + # Packages kept in the image + KEPT_PACKAGES+=(bash) && \ + KEPT_PACKAGES+=(ca-certificates) && \ + KEPT_PACKAGES+=(chrpath) && \ + KEPT_PACKAGES+=(locales) && \ + KEPT_PACKAGES+=(locales-all) && \ + KEPT_PACKAGES+=(libfreetype6) && \ + KEPT_PACKAGES+=(libfontconfig1) && \ + KEPT_PACKAGES+=(p7zip-full) && \ + KEPT_PACKAGES+=(python3) && \ + KEPT_PACKAGES+=(python3-pip) && \ + KEPT_PACKAGES+=(python3-pyqt5) && \ + KEPT_PACKAGES+=(unrar-free) && \ + # 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[@]} \ + && \ + # Install required python modules + python -m pip install --upgrade pip && \ +# python -m pip install -r /opt/kcc/requirements.txt && \ + python -m venv /opt/venv && \ + python -m pip install --upgrade pillow python-slugify psutil raven mozjpeg-lossless-optimization + + +###################################################################################### +FROM --platform=linux/amd64 python:3.11-slim-bullseye as build-amd64 +COPY --from=compile-amd64 /opt/venv /opt/venv + +FROM --platform=linux/arm64 python:3.11-slim-bullseye as build-arm64 +COPY --from=compile-arm64 /opt/venv /opt/venv + +FROM --platform=linux/arm/v7 python:3.11-slim-bullseye as build-armv7 +COPY --from=compile-armv7 /opt/venv /opt/venv +###################################################################################### + +# Select final stage based on TARGETARCH ARG +FROM build-${TARGETARCH}${TARGETVARIANT} +LABEL com.kcc.name="Kindle Comic Converter base image" +LABEL com.kcc.author="Ciro Mattia Gonano, Paweł Jastrzębski and Darodi" +LABEL org.opencontainers.image.description='Kindle Comic Converter base image' +LABEL org.opencontainers.image.documentation='https://github.com/ciromattia/kcc' +LABEL org.opencontainers.image.source='https://github.com/ciromattia/kcc' +LABEL org.opencontainers.image.authors='darodi' +LABEL org.opencontainers.image.url='https://github.com/ciromattia/kcc' +LABEL org.opencontainers.image.documentation='https://github.com/ciromattia/kcc' +LABEL org.opencontainers.image.vendor='ciromattia' +LABEL org.opencontainers.image.licenses='ISC' +LABEL org.opencontainers.image.title="Kindle Comic Converter" + + +ENV PATH="/opt/venv/bin:$PATH" +WORKDIR /app +RUN DEBIAN_FRONTEND=noninteractive apt-get update -y && apt-get -yq upgrade && \ + apt-get install -y p7zip-full unrar-free && \ + ln -s /app/kindlegen /bin/kindlegen && \ + echo docker-base-20230514 > /IMAGE_VERSION +