Merge pull request #117 from SuperSandro2000/docker-fix

Docker: Fix startup error in entrypoint, ownership of node_modules
This commit is contained in:
Tzahi12345
2020-06-03 09:46:58 -04:00
committed by GitHub
2 changed files with 9 additions and 5 deletions

View File

@@ -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" ]

View File

@@ -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