From 2e214219d05df25192f7223b22ed655cd70f9941 Mon Sep 17 00:00:00 2001 From: Commandcracker <49335821+Commandcracker@users.noreply.github.com> Date: Sun, 21 Jul 2024 22:47:42 +0200 Subject: [PATCH] Fixed #17 and made some other small changes to the docker files --- src/Dockerfile | 34 ++++++++++++++++++---------------- src/Dockerfile.nvidia | 33 ++++++++++++++++++++------------- src/requirements.txt | 2 +- 3 files changed, 39 insertions(+), 30 deletions(-) diff --git a/src/Dockerfile b/src/Dockerfile index 4ca720c..53c8a4b 100644 --- a/src/Dockerfile +++ b/src/Dockerfile @@ -2,18 +2,18 @@ FROM ghcr.io/commandcracker/ffmpeg:latest AS ffmpeg FROM ffmpeg AS sanjuuni -ENV SANJUUNI_VERSION=778644b164c8877e56f9f5512480dde857133815 +ENV SANJUUNI_VERSION=49cb275d4ef64d2bee3d5d2cbc5baf47787bedc2 -ARG SANJUUNI_SHA512SUM="353b97e53ec2daba3046b3062c8a389c75066ea410f9abe089467a4648e83afe926cd65ad0904a0d59eca0520e3174e0f3190987cfee3abbdc9141a04a80ef1a *sanjuuni.tar.gz" +ARG SANJUUNI_SHA512SUM="22c85f9a5c16c0acb4dde971b64f53e765a8d607065e7a25115103925124e33a0680da3790e85c4343b7d320a0170b6ae096ec7f2b48b22582cf96681fd3a78c *sanjuuni.tar.gz" SHELL ["/bin/ash", "-eo", "pipefail", "-c"] RUN set -eux; \ apk add --no-cache --update \ - g++=13.2.1_git20240309-r0 \ - zlib-dev=1.3.1-r1 \ - poco-dev=1.12.4-r0 \ - make=4.4.1-r2; \ + g++ \ + zlib-dev \ + poco-dev \ + make; \ wget -q --output-document=sanjuuni.tar.gz https://github.com/MCJack123/sanjuuni/archive/${SANJUUNI_VERSION}.tar.gz; \ echo "${SANJUUNI_SHA512SUM}" | sha512sum -c -; \ mkdir --parents sanjuuni; \ @@ -35,7 +35,7 @@ COPY youcube ./youcube COPY compile.py . RUN set -eux; \ - apk add --no-cache --update build-base=0.5-r3; \ + apk add --no-cache --update build-base; \ pip install --no-cache-dir -U setuptools -r requirements.txt; \ python3 compile.py; \ pip uninstall pip -y @@ -49,17 +49,17 @@ RUN set -eux; \ # CVE-2024-5535 TODO: remove when base image is updated openssl \ # pypy requirements - libffi=3.4.6-r0 libbz2=1.0.8-r6 \ + libffi libbz2 \ # sanjuuni requirements - poco=1.12.4-r0 \ + poco \ # ffmpeg requirements - libgcc=13.2.1_git20240309-r0 \ - libstdc++=13.2.1_git20240309-r0 \ - ca-certificates=20240226-r0 \ - libgomp=13.2.1_git20240309-r0 \ - expat=2.6.2-r0; \ + libgcc \ + libstdc++ \ + ca-certificates \ + libgomp \ + expat; \ apk add --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/v3.18/community libssl1.1=1.1.1u-r1 libcrypto1.1=1.1.1u-r1; \ - chown 1000 /opt/server/ + chown 1000:1000 /opt/server/ COPY --from=builder /opt/pypy /opt/pypy # add ffmpeg @@ -68,6 +68,8 @@ COPY --from=ffmpeg /usr/local /usr/local COPY --from=sanjuuni /sanjuuni/sanjuuni /usr/local/bin ENV \ + # Make sure, that the container is accessible from outside + HOST=0.0.0.0 \ # Make sure we use the virtualenv: PATH="/opt/pypy/bin:$PATH" \ # Use ffmpeg libs @@ -77,7 +79,7 @@ ENV \ # FIXME: Add UVLOOP support for alpine pypy SANIC_NO_UVLOOP=true -USER 1000 +USER 1000:1000 COPY --from=builder /youcube/__pycache__ /opt/server diff --git a/src/Dockerfile.nvidia b/src/Dockerfile.nvidia index 0b1baba..e8eba07 100644 --- a/src/Dockerfile.nvidia +++ b/src/Dockerfile.nvidia @@ -4,20 +4,20 @@ FROM ghcr.io/commandcracker/ubuntu-ffmpeg:latest AS ffmpeg FROM ffmpeg AS sanjuuni -ENV SANJUUNI_VERSION=778644b164c8877e56f9f5512480dde857133815 +ENV SANJUUNI_VERSION=49cb275d4ef64d2bee3d5d2cbc5baf47787bedc2 -ARG SANJUUNI_SHA512SUM="353b97e53ec2daba3046b3062c8a389c75066ea410f9abe089467a4648e83afe926cd65ad0904a0d59eca0520e3174e0f3190987cfee3abbdc9141a04a80ef1a *sanjuuni.tar.gz" +ARG SANJUUNI_SHA512SUM="22c85f9a5c16c0acb4dde971b64f53e765a8d607065e7a25115103925124e33a0680da3790e85c4343b7d320a0170b6ae096ec7f2b48b22582cf96681fd3a78c *sanjuuni.tar.gz" SHELL ["/bin/bash", "-o", "pipefail", "-c"] RUN set -eux; \ apt-get update; \ apt-get install -y --no-install-recommends \ - ocl-icd-opencl-dev=2.2.14-3 \ - wget=1.21.2-2ubuntu1.1 \ - clang=1:14.0-55~exp2 \ - make=4.3-4.1build1 \ - libpoco-dev=1.11.0-3; \ + ocl-icd-opencl-dev \ + wget \ + clang \ + make \ + libpoco-dev; \ wget --progress=dot:giga --output-document=sanjuuni.tar.gz https://github.com/MCJack123/sanjuuni/archive/${SANJUUNI_VERSION}.tar.gz; \ echo "${SANJUUNI_SHA512SUM}" | sha512sum -c -; \ mkdir --parents sanjuuni; \ @@ -36,7 +36,7 @@ WORKDIR /youcube COPY --from=sanjuuni /sanjuuni/sanjuuni /usr/local/bin COPY requirements.txt . -COPY youcube /youcube +COPY --chown=1000:1000 youcube/*.py /youcube SHELL ["/bin/bash", "-o", "pipefail", "-c"] @@ -44,16 +44,23 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"] RUN set -eux; \ apt-get update; \ apt-get install -y --no-install-recommends \ - libpoco-dev=1.11.0-3 \ - python3-pip=22.0.2+dfsg-1 \ + libpoco-dev \ + python3-pip \ ocl-icd-libopencl1; \ - pip install -U pip; \ - pip install --no-cache-dir -r requirements.txt; \ + pip install --break-system-packages --no-cache-dir -r requirements.txt; \ + rm requirements.txt __main__.py; \ + chown 1000:1000 /youcube/; \ mkdir -p /etc/OpenCL/vendors; \ echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd ENV \ NVIDIA_VISIBLE_DEVICES=all \ - NVIDIA_DRIVER_CAPABILITIES=compute,utility + NVIDIA_DRIVER_CAPABILITIES=compute,utility \ + # Make sure, that the container is accessible from outside + HOST=0.0.0.0 \ + # yt-dlp cache dir + XDG_CACHE_HOME="/youcube/.yt-dlp-cache" + +USER 1000:1000 ENTRYPOINT ["python3", "youcube.py"] diff --git a/src/requirements.txt b/src/requirements.txt index 28a0ad7..0273185 100644 --- a/src/requirements.txt +++ b/src/requirements.txt @@ -1,5 +1,5 @@ sanic~=24.6.0 #uvloop~=0.19.0; platform_system != "Windows" -yt-dlp~=2024.7.2 +yt-dlp~=2024.7.16 #orjson~=3.10.6 spotipy~=2.24.0