Improvment of UID management

This commit is contained in:
Totonyus 2024-06-01 13:44:18 +02:00
parent 6aab025321
commit bb5e08e850
5 changed files with 15 additions and 33 deletions

View File

@ -9,20 +9,19 @@ VOLUME ["/app/params", "/app/data", "/app/downloads", "/app/logs"]
EXPOSE 80
COPY --chmod=755 entrypoint.sh ./
COPY *.py pip_requirements_$TARGET_ARCH ./
COPY *.py pip_requirements ./
COPY params/*.py params/*.ini params/userscript.js params/hooks_requirements ./setup/
COPY params/params_docker.ini ./setup/params.ini
RUN if [ "$TARGET_ARCH" = "arm" ] ; then apt update && apt install gcc python3-dev -y && apt-get autoremove && apt-get -y clean && rm -rf /var/lib/apt/lists/*; fi
RUN if [ "$TARGET_ARCH" = "arm" ] ; then apt update && apt install gcc python3-dev -y; fi
RUN apt update && apt install wget xz-utils -y && apt-get autoremove && apt-get -y clean && rm -rf /var/lib/apt/lists/*
RUN apt update && apt install wget xz-utils -y
RUN ARCH=$(arch | sed s/aarch64/arm64/ | sed s/x86_64/amd64/) && \
wget https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-${ARCH}-static.tar.xz -O /ffmpeg.tar.xz && \
RUN ARCH=$(arch | sed s/aarch64/linuxarm64/ | sed s/x86_64/linux64/) && \
wget https://github.com/yt-dlp/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-${ARCH}-gpl.tar.xz -O /ffmpeg.tar.xz && \
tar -xf /ffmpeg.tar.xz -C /tmp && \
install --mode=777 /tmp/ffmpeg-*-static/ffmpeg /usr/bin && \
install --mode=777 /tmp/ffmpeg-*-static/ffprobe /usr/bin && \
rm /ffmpeg.tar.xz /tmp/ffmpeg-*-static -rf && \
pip3 install --disable-pip-version-check -q --root-user-action=ignore -r pip_requirements_$TARGET_ARCH
install --mode=777 /tmp/ffmpeg-*/bin/ffmpeg /usr/bin && \
install --mode=777 /tmp/ffmpeg-*/bin/ffprobe /usr/bin && \
rm /ffmpeg.tar.xz /tmp/ffmpeg-* -rf && \
pip3 install --disable-pip-version-check -q --root-user-action=ignore -r pip_requirements
ENTRYPOINT ["/app/entrypoint.sh"]

View File

@ -7,17 +7,13 @@ echo ~~~ Docker image generated : $DATE
mkdir -p /app/logs /app/downloads /app/params /app/tmp /app/data /root/yt-dlp-plugins /app/cookies/ /home/ydl_api_ng
getent group $GID >/dev/null
if [ $? -eq 0 ]; then
groupmod $(id --name --group $GID) -n ydl_api_ng
else
if [ ! $? -eq 0 ]; then
addgroup --gid $GID ydl_api_ng
fi
getent passwd $UID >/dev/null
if [ $? -eq 0 ]; then
usermod $(id --name --user $UID) -l ydl_api_ng
else
useradd --uid $UID --gid ydl_api_ng ydl_api_ng
if [ ! $? -eq 0 ]; then
useradd --uid $UID --gid $GID ydl_api_ng -b /home/ydl_api_ng
fi
# If params.ini exists, assume setup has been run. Don't copy extra files the user may have removed.
@ -58,7 +54,7 @@ fi
if [ "$DEBUG" == "DEBUG" ]; then
echo ~~~ Launching DEBUG mode ~~~
su ydl_api_ng -c "uvicorn main:app --reload --port 80 --host 0.0.0.0"
su "$(id -un $UID)" -c "uvicorn main:app --reload --port 80 --host 0.0.0.0"
else
su ydl_api_ng -c "python3 main.py"
su "$(id -un $UID)" -c "python3 main.py"
fi

View File

@ -2,7 +2,7 @@
logfile=/app/logs/supervisord.log
pidfile=/app/tmp/supervisord_pid
loglevel=%(ENV_LOG_LEVEL)s
user= ydl_api_ng
user=%(ENV_UID)s
; You can remove this block if you don't plan to use the programmation function
[program:programmation]

View File

@ -1,13 +0,0 @@
cronsim
fastapi
ffmpeg-python
humanize
mergedeep
psutil
redis
requests
rq
supervisor
tinydb
uvicorn
yt-dlp