diff --git a/Dockerfile b/Dockerfile index a4e0e41d..767b716e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM node:lts-alpine AS node_builder WORKDIR /app COPY ui ./ -RUN if [ ! -d /app/exported ]; then yarn install --production --prefer-offline --frozen-lockfile && yarn run generate; else echo "Skipping UI build, already built."; fi +RUN if [ ! -f "/app/exported/index.html" ]; then yarn install --production --prefer-offline --frozen-lockfile && yarn run generate; else echo "Skipping UI build, already built."; fi FROM python:3.11-alpine AS python_builder @@ -26,7 +26,7 @@ FROM python:3.11-alpine ARG TZ=UTC ARG USER_ID=1000 ENV IN_CONTAINER=1 -ENV UMASK=022 +ENV UMASK=0002 ENV YTP_CONFIG_PATH=/config ENV YTP_TEMP_PATH=/tmp ENV YTP_DOWNLOAD_PATH=/downloads diff --git a/app/library/Utils.py b/app/library/Utils.py index ab82ca81..a199ffe8 100644 --- a/app/library/Utils.py +++ b/app/library/Utils.py @@ -26,7 +26,6 @@ IGNORED_KEYS: tuple[str] = ( "download_archive", ) YTDLP_INFO_CLS: yt_dlp.YoutubeDL = None -OS_ALT_SEP: list[str] = list(sep for sep in [os.sep, os.path.altsep] if sep is not None and sep != "/") class StreamingError(Exception): @@ -119,6 +118,9 @@ def calcDownloadPath(basePath: str, folder: str | None = None, createPath: bool if not folder: return basePath + if folder.startswith("/"): + folder = folder[1:] + realBasePath = os.path.realpath(basePath) download_path = os.path.realpath(os.path.join(basePath, folder)) diff --git a/entrypoint.sh b/entrypoint.sh index 94a38918..2706d0ee 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -19,4 +19,17 @@ if [ ! -w "${YTP_CONFIG_PATH}" ]; then exit 1 fi +if [ ! -w "${YTP_DOWNLOAD_PATH}" ]; then + CH_USER=$(stat -c "%u" "${YTP_DOWNLOAD_PATH}") + CH_GRP=$(stat -c "%g" "${YTP_DOWNLOAD_PATH}") + echo_err "ERROR: Unable to write to '${YTP_DOWNLOAD_PATH}' downloads directory. Current user id '${UID}' while directory owner is '${CH_USER}'." + echo_err "[Running under docker]" + echo_err "change docker-compose.yaml user: to user:\"${CH_USER}:${CH_GRP}\"" + echo_err "Run the following command to change the directory ownership" + echo_err "chown -R \"${CH_USER}:${CH_GRP}\" ./config" + echo_err "[Running under podman]" + echo_err "change docker-compose.yaml user: to user:\"0:0\"" + exit 1 +fi + exec "${@}"