From c3e3180191e8cea73c5e20375734f96e98ca7975 Mon Sep 17 00:00:00 2001 From: nyyu Date: Sat, 6 Jan 2024 22:12:55 +0100 Subject: [PATCH] feat: py 3.12 & cleanup --- Dockerfile | 32 +++++++++---------- py3-12.patch | 57 ++++++++++++++++++++++++++++++++++ root/etc/services.d/pyload/run | 4 --- root/start.sh | 14 +++++++++ 4 files changed, 86 insertions(+), 21 deletions(-) create mode 100644 py3-12.patch delete mode 100644 root/etc/services.d/pyload/run create mode 100755 root/start.sh diff --git a/Dockerfile b/Dockerfile index faa7e2c..2a119fd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,11 @@ -FROM ghcr.io/linuxserver/baseimage-alpine:3.19 +FROM python:3.12.1-alpine # set version label ARG DOCKER_IMAGE_CREATED ARG VERSION LABEL build_version="pyload docker version:- ${VERSION} Build-date:- ${DOCKER_IMAGE_CREATED}" -ENV HOME="/config" +# add local files +COPY *.patch root/ / RUN \ wget https://nexus.nyyu.dev/repository/files/alpine/7zip-23.01-r0.apk && \ @@ -14,35 +15,32 @@ RUN \ apk add --no-cache --virtual=build-dependencies \ build-base \ curl-dev \ - libffi-dev \ - libjpeg-turbo-dev \ - openssl-dev \ - python3-dev \ - zlib-dev && \ + patch && \ echo "**** install packages ****" && \ apk add --no-cache \ + tini su-exec shadow \ curl \ - ffmpeg \ - libjpeg-turbo \ - python3 \ - py3-pip \ - sqlite \ tesseract-ocr && \ echo "**** install pyload ****" && \ PYLOAD='https://github.com/pyload/pyload/archive/develop.zip#[all]' && \ if [[ -n "${VERSION}" && "${VERSION}" != "dev" ]]; then \ PYLOAD="pyload-ng[all]==${VERSION}"; \ fi && \ - pip3 install --break-system-packages -U "${PYLOAD}" && \ + pip3 install --no-cache-dir --break-system-packages -U "${PYLOAD}" && \ + pip uninstall -y Js2Py && \ + cd /usr/local/lib/python3.12/site-packages/ && patch -Np1 < /py3-12.patch && cd / \ echo "**** cleanup ****" && \ apk del --purge \ build-dependencies && \ rm -rf \ - /tmp/* - -# add local files -COPY root/ / + /tmp/* \ + /*.patch && \ + echo "**** add user abc ****" && \ + adduser -D -u 911 -h /config abc # ports and volumes EXPOSE 8000 VOLUME /config + +ENTRYPOINT ["/sbin/tini", "--"] +CMD ["/start.sh"] diff --git a/py3-12.patch b/py3-12.patch new file mode 100644 index 0000000..e999b13 --- /dev/null +++ b/py3-12.patch @@ -0,0 +1,57 @@ +diff --git a/pyload/core/utils/check.py b/pyload/core/utils/check.py +index 3c98fd490..4f135cf0b 100644 +--- a/pyload/core/utils/check.py ++++ b/pyload/core/utils/check.py +@@ -1,6 +1,5 @@ + # -*- coding: utf-8 -*- + +-import imp + from collections.abc import Iterable, Mapping, Sequence + + +@@ -54,17 +53,6 @@ def is_mapping(obj): + return isinstance(obj, Mapping) + + +-def is_module(name, path=None): +- """Check if exists a module with given name.""" +- try: +- fp, _, _ = imp.find_module(name, path) +- if fp is not None: +- fp.close() +- return True +- except ImportError: +- return False +- +- + def missing(iterable, start=None, end=None): + """List all the values between 'start' and 'stop' that are missing from 'iterable'.""" + iter_seq = set(map(int, iterable)) +diff --git a/pyload/core/utils/misc.py b/pyload/core/utils/misc.py +index 6d2f23cc5..96d931108 100644 +--- a/pyload/core/utils/misc.py ++++ b/pyload/core/utils/misc.py +@@ -3,11 +3,6 @@ + import random + import string + +-import js2py +- +-js2py.disable_pyimport() +- +- + def random_string(length): + seq = string.ascii_letters + string.digits + string.punctuation + return "".join(random.choice(seq) for _ in range(length)) +@@ -23,8 +18,7 @@ def is_plural(value): + + def eval_js(script, es6=False): + # return requests_html.HTML().render(script=script, reload=False) +- return (js2py.eval_js6 if es6 else js2py.eval_js)(script) +- ++ return None + + def accumulate(iterable, to_map=None): + """ +-- + diff --git a/root/etc/services.d/pyload/run b/root/etc/services.d/pyload/run deleted file mode 100644 index bcc4e2e..0000000 --- a/root/etc/services.d/pyload/run +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/with-contenv bash - -exec \ - s6-setuidgid abc pyload --userdir /config --storagedir /downloads diff --git a/root/start.sh b/root/start.sh new file mode 100755 index 0000000..1a26032 --- /dev/null +++ b/root/start.sh @@ -0,0 +1,14 @@ +#!/bin/sh +set -e + +PUID=${PUID:-911} +PGID=${PGID:-911} + +groupmod -o -g "$PGID" abc 2>/dev/null +usermod -o -u "$PUID" abc 2>/dev/null + +for f in /etc/cont-init.d/*; do + sh "$f" +done + +exec su-exec abc pyload --userdir /config --storagedir /downloads