From bab354ce812d7bcf3ec55681f50ee0ac8e08722d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Wed, 3 Jun 2020 07:11:30 +0200 Subject: [PATCH 1/5] Fix variable expansion --- backend/entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/entrypoint.sh b/backend/entrypoint.sh index 137e984..51df772 100755 --- a/backend/entrypoint.sh +++ b/backend/entrypoint.sh @@ -9,7 +9,7 @@ if [ "${1#-}" != "$1" ]; then fi # chown current working directory to current user -if [ "$@" = "$CMD" ] && [ "$(id -u)" = "0" ]; then +if [ "$*" = "$CMD" ] && [ "$(id -u)" = "0" ]; then find . \! -user "$UID" -exec chown "$UID:$GID" -R '{}' + exec su-exec "$UID:$GID" "$0" "$@" fi From dd8ab9be2950318d90aecccd5934ff75f8451649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Wed, 3 Jun 2020 07:12:14 +0200 Subject: [PATCH 2/5] Fix default uid/gid of node_modules --- backend/Dockerfile | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index d4ce0c5..6d337a4 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,9 +1,9 @@ FROM alpine:3.12 -ENV UID=1000 GID=1000 -RUN export user=youtube \ - && addgroup -S $user -g $GID && adduser -D -S $user -G $user -u $UID -USER $user +ENV UID=1000 \ + GID=1000 \ + USER=youtube +RUN addgroup -S $USER -g $GID && adduser -D -S $USER -G $USER -u $UID RUN apk add --no-cache \ ffmpeg \ @@ -13,6 +13,8 @@ RUN apk add --no-cache \ && apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing/ \ atomicparsley +# switch to default user to not chown node_modules on startup +USER $USER WORKDIR /app COPY --chown=$UID:$GID [ "package.json", "package-lock.json", "/app/" ] @@ -21,5 +23,7 @@ RUN npm install COPY --chown=$UID:$GID [ "./", "/app/" ] EXPOSE 17442 +# switch back to root to allow UID/GID changing +USER root ENTRYPOINT [ "/app/entrypoint.sh" ] CMD [ "node", "app.js" ] From 378025bd9d02ee70fcd4c3f49ba732fff887d948 Mon Sep 17 00:00:00 2001 From: Tzahi12345 Date: Wed, 3 Jun 2020 20:56:48 -0400 Subject: [PATCH 3/5] Updated dockerfile to support Windows builds --- backend/Dockerfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index 6d337a4..ee6be52 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -16,10 +16,14 @@ RUN apk add --no-cache \ # switch to default user to not chown node_modules on startup USER $USER WORKDIR /app - COPY --chown=$UID:$GID [ "package.json", "package-lock.json", "/app/" ] + +# run npm install as root, required for Windows hosts +USER root RUN npm install +RUN chown -R $UID:$GID ./ + COPY --chown=$UID:$GID [ "./", "/app/" ] EXPOSE 17442 From e8ee4ffb64e84e590699546909c269c2a08896d1 Mon Sep 17 00:00:00 2001 From: Tzahi12345 Date: Sat, 6 Jun 2020 13:07:50 -0400 Subject: [PATCH 4/5] Made additional cleanups as per recs by SuperSandro --- backend/Dockerfile | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index ee6be52..645b877 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -3,6 +3,7 @@ FROM alpine:3.12 ENV UID=1000 \ GID=1000 \ USER=youtube + RUN addgroup -S $USER -g $GID && adduser -D -S $USER -G $USER -u $UID RUN apk add --no-cache \ @@ -13,21 +14,14 @@ RUN apk add --no-cache \ && apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing/ \ atomicparsley -# switch to default user to not chown node_modules on startup -USER $USER WORKDIR /app COPY --chown=$UID:$GID [ "package.json", "package-lock.json", "/app/" ] -# run npm install as root, required for Windows hosts -USER root -RUN npm install - -RUN chown -R $UID:$GID ./ +RUN npm install && chown -R $UID:$GID ./ COPY --chown=$UID:$GID [ "./", "/app/" ] EXPOSE 17442 -# switch back to root to allow UID/GID changing -USER root + ENTRYPOINT [ "/app/entrypoint.sh" ] CMD [ "node", "app.js" ] From a074166903dadd62308e967f5d40a771f3daf8f6 Mon Sep 17 00:00:00 2001 From: Tzahi12345 Date: Mon, 8 Jun 2020 13:04:16 -0400 Subject: [PATCH 5/5] Added catch statement if youtube-dl tags could not be retrieved --- backend/app.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/app.js b/backend/app.js index e4dfdc1..8d01f11 100644 --- a/backend/app.js +++ b/backend/app.js @@ -1743,7 +1743,10 @@ async function autoUpdateYoutubeDL() { resolve(true); }); } - + }) + .catch(err => { + logger.error('Failed to check youtube-dl version for an update.') + logger.error(err) }); }); }