Skip to content

Commit

Permalink
Update docker images, fixed docker nvidia opencl support, updated all…
Browse files Browse the repository at this point in the history
… requirements
  • Loading branch information
Commandcracker committed Jul 5, 2024
1 parent 848fa63 commit a6ee163
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 54 deletions.
28 changes: 15 additions & 13 deletions src/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
FROM ghcr.io/commandcracker/ffmpeg:latest AS ffmpeg

FROM ffmpeg as sanjuuni
FROM ffmpeg AS sanjuuni

ENV SANJUUNI_VERSION=ed34c266cd489e4db796ca803e247b48b43853e0
ENV SANJUUNI_VERSION=778644b164c8877e56f9f5512480dde857133815

ARG SANJUUNI_SHA512SUM="9e482e3b8f8885e8f458856f11d5ee4c27a0aa469b8c54abe1aef943f630ca27eb148c8779ba7a053c1abcce298513e98b614747a77ae1c0cbc86a0a7c95a6d8 *sanjuuni.tar.gz"
ARG SANJUUNI_SHA512SUM="353b97e53ec2daba3046b3062c8a389c75066ea410f9abe089467a4648e83afe926cd65ad0904a0d59eca0520e3174e0f3190987cfee3abbdc9141a04a80ef1a *sanjuuni.tar.gz"

SHELL ["/bin/ash", "-eo", "pipefail", "-c"]

RUN set -eux; \
apk add --no-cache --update \
g++=13.2.1_git20231014-r0 \
zlib-dev=1.3.1-r0 \
g++=13.2.1_git20240309-r0 \
zlib-dev=1.3.1-r1 \
poco-dev=1.12.4-r0 \
make=4.4.1-r2; \
wget -q --output-document=sanjuuni.tar.gz https://github.com/MCJack123/sanjuuni/archive/${SANJUUNI_VERSION}.tar.gz; \
Expand All @@ -26,7 +26,7 @@ RUN set -eux; \
./configure; \
make

FROM ghcr.io/commandcracker/alpine-pypy3.10-pip:3.19.0-pypy-7.3.14-pip-23.3.2 AS builder
FROM ghcr.io/commandcracker/alpine-pypy3.10-pip:3.20.1-pypy-7.3.14-pip-24.1.1 AS builder

WORKDIR /

Expand All @@ -40,22 +40,24 @@ RUN set -eux; \
python3 compile.py; \
pip uninstall pip -y

FROM alpine:3.19.0
FROM alpine:3.20.1

WORKDIR /opt/server

RUN set -eux; \
apk add --no-cache --update \
# CVE-2024-5535 TODO: remove when base image is updated
openssl \
# pypy requirements
libffi=3.4.4-r3 libbz2=1.0.8-r6 \
libffi=3.4.6-r0 libbz2=1.0.8-r6 \
# sanjuuni requirements
poco=1.12.4-r0 \
# ffmpeg requirements
libgcc=13.2.1_git20231014-r \
libstdc++=13.2.1_git20231014-r0 \
ca-certificates=20230506-r0 \
libgomp=13.2.1_git20231014-r0 \
expat=2.5.0-r2; \
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; \
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/

Expand Down
36 changes: 17 additions & 19 deletions src/Dockerfile.nvidia
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
#!/usr/bin/env dockerfile-shebang

FROM ghcr.io/commandcracker/ubuntu-ffmpeg:latest AS ffmpeg

FROM ffmpeg as sanjuuni
FROM ffmpeg AS sanjuuni

ENV SANJUUNI_VERSION=0.4
ENV SANJUUNI_VERSION=778644b164c8877e56f9f5512480dde857133815

ARG SANJUUNI_SHA512SUM="952a6c608d167f37faad53ee7f2e0de8090a02bf73b6455fae7c6b6f648dd6a188e7749fe26caeee85126b2a38d7391389c19afb0100e9962dc551188b9de6ae *sanjuuni.tar.gz"
ARG SANJUUNI_SHA512SUM="353b97e53ec2daba3046b3062c8a389c75066ea410f9abe089467a4648e83afe926cd65ad0904a0d59eca0520e3174e0f3190987cfee3abbdc9141a04a80ef1a *sanjuuni.tar.gz"

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

RUN set -eux; \
apt-get update; \
apt-get install \
apt-get install -y --no-install-recommends \
ocl-icd-opencl-dev=2.2.14-3 \
wget=1.21.2-2ubuntu1 \
wget=1.21.2-2ubuntu1.1 \
clang=1:14.0-55~exp2 \
make=4.3-4.1build1 \
libpoco-dev=1.11.0-3 -y --no-install-recommends; \
libpoco-dev=1.11.0-3; \
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; \
Expand All @@ -41,21 +43,17 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# hadolint ignore=SC1091
RUN set -eux; \
apt-get update; \
apt-get install \
apt-get install -y --no-install-recommends \
libpoco-dev=1.11.0-3 \
python3-pip=22.0.2+dfsg-1 \
gnupg=2.2.27-3ubuntu2.1 \
libcurl4=7.81.0-1 \
curl=7.81.0-1 -y --no-install-recommends; \
ocl-icd-libopencl1; \
pip install -U pip; \
pip install --no-cache-dir -r requirements.txt; \
curl -s -L "https://nvidia.github.io/nvidia-container-runtime/gpgkey" | apt-key add -; \
distribution=$(. /etc/os-release;echo "$ID$VERSION_ID"); \
curl -s -L "https://nvidia.github.io/nvidia-container-runtime/$distribution/nvidia-container-runtime.list" | tee /etc/apt/sources.list.d/nvidia-container-runtime.list; \
apt-get update; \
apt-get install \
nvidia-opencl-dev=11.5.1-1ubuntu1 \
nvidia-container-runtime=3.13.0-1 -y --no-install-recommends; \
apt-get clean; \
rm -rf /var/lib/apt/lists/*
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

ENTRYPOINT ["python3", "youcube.py"]
10 changes: 5 additions & 5 deletions src/docker-compose.nvidia.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
version: "2.0"
---
services:
youcube:
build: .
build:
context: .
dockerfile: Dockerfile.nvidia
image: youcube:nvidia
restart: always
hostname: youcube
ports:
- 5000:5000
#env_file: .env
runtime: nvidia
environment:
- NVIDIA_VISIBLE_DEVICES=all
- NVIDIA_DRIVER_CAPABILITIES=compute
...
3 changes: 2 additions & 1 deletion src/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "2.0"
---
services:
youcube:
build: .
Expand All @@ -8,3 +8,4 @@ services:
ports:
- 5000:5000
#env_file: .env
...
10 changes: 5 additions & 5 deletions src/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
sanic~=23.12.1
#uvloop~=0.19.0; platform_system != "Windows"
yt-dlp~=2023.12.30
ujson~=5.9.0
spotipy~=2.23.0
sanic~=24.6.0
#uvloop~=0.19.0; platform_system != "Windows"
yt-dlp~=2024.7.2
#orjson~=3.10.6
spotipy~=2.24.0
2 changes: 1 addition & 1 deletion src/youcube/yc_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

# optional pip modules
try:
from ujson import dumps
from orjson import dumps
except ModuleNotFoundError:
from json import dumps

Expand Down
5 changes: 1 addition & 4 deletions src/youcube/yc_spotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
from spotipy import MemoryCacheHandler, SpotifyClientCredentials
from spotipy.client import Spotify

# https://github.com/spotipy-dev/spotipy/issues/1071
# pylint: disable-next=line-too-long
REGEX_SPOTIFY_URL = r"^(http[s]?:\/\/)?open.spotify.com\/.*(?P<type>track|artist|album|playlist|show|episode|user)\/(?P<id>[0-9A-Za-z]+)(\?.*)?$"

# pylint: disable=missing-function-docstring
# pylint: disable=missing-class-docstring
Expand Down Expand Up @@ -116,7 +113,7 @@ def auto(self, url: str) -> Union[str, list]:
# pylint: disable=protected-access
for match in [
re_match(Spotify._regex_spotify_uri, url),
re_match(REGEX_SPOTIFY_URL, url),
re_match(Spotify._regex_spotify_url, url),
]:
# pylint: enable=protected-access
if match:
Expand Down
12 changes: 6 additions & 6 deletions src/youcube/youcube.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

# optional pip module
try:
from ujson import JSONDecodeError, dumps
from ujson import loads as load_json
from orjson import JSONDecodeError, dumps
from orjson import loads as load_json
except ModuleNotFoundError:
from json import dumps
from json import loads as load_json
Expand Down Expand Up @@ -237,7 +237,7 @@ async def get_chunk(message: dict, _unused, request: Request):
file = join(DATA_FOLDER, file_name)

request.app.shared_ctx.data[file_name] = datetime.now()
chunk = await get_chunk(file, chunkindex)
chunk = await getchunk(file, chunkindex)

return {"action": "chunk", "chunk": b64encode(chunk).decode("ascii")}
logger.warning("User tried to use special Characters")
Expand Down Expand Up @@ -307,7 +307,7 @@ def default(self, request: Request, exception: Union[SanicException, Exception])
return super().default(request, exception)


app = Sanic(__name__)
app = Sanic("youcube")
app.error_handler = CustomErrorHandler()
# FIXME: The Client is not Responsing to Websocket pings
app.config.WEBSOCKET_PING_INTERVAL = 0
Expand Down Expand Up @@ -378,10 +378,10 @@ async def main_start(app: Sanic):

@app.route("/dfpwm/<id:str>/<chunkindex:int>")
async def stream_dfpwm(request: Request, id: str, chunkindex: int):
return raw(await get_chunk(join(DATA_FOLDER, get_audio_name(id)), chunkindex))
return raw(await getchunk(join(DATA_FOLDER, get_audio_name(id)), chunkindex))


@app.route("/32vid/<id:str>/<width:int>/<height:int>/<tracker:int>", stream=True)
@app.route("/32vid/<id:str>/<width:int>/<height:int>/<tracker:int>") # , stream=True
async def stream_32vid(
request: Request, id: str, width: int, height: int, tracker: int
):
Expand Down

0 comments on commit a6ee163

Please sign in to comment.