From d0c9d655863f357a1330688e16c23392883a4493 Mon Sep 17 00:00:00 2001 From: kn100 Date: Fri, 5 Jan 2024 00:47:51 -0500 Subject: [PATCH] respect users specified pgid/puid --- docker/dockerfile | 4 ++-- docker/scripts/init.sh | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100755 docker/scripts/init.sh diff --git a/docker/dockerfile b/docker/dockerfile index 572c732e0..3bf439305 100644 --- a/docker/dockerfile +++ b/docker/dockerfile @@ -27,7 +27,7 @@ RUN mkdir ./data # ⭐ Main Image ############################################ FROM $BASE_IMAGE AS release -USER node +COPY ./docker/scripts/init.sh /usr/bin/init.sh WORKDIR /app LABEL org.opencontainers.image.source="https://github.com/louislam/uptime-kuma" @@ -40,7 +40,7 @@ COPY --chown=node:node --from=build /app /app EXPOSE 3001 HEALTHCHECK --interval=60s --timeout=30s --start-period=180s --retries=5 CMD extra/healthcheck ENTRYPOINT ["/usr/bin/dumb-init", "--"] -CMD ["node", "server/server.js"] +CMD ["/usr/bin/init.sh"] ############################################ # Rootless Image diff --git a/docker/scripts/init.sh b/docker/scripts/init.sh new file mode 100755 index 000000000..e29991c6f --- /dev/null +++ b/docker/scripts/init.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +PUID=${PUID:-1000} +PGID=${PGID:-1000} + +groupmod -o -g "$PGID" node +usermod -o -u "$PUID" node + +echo "node has uid: $(id -u node) and gid: $(id -g node)" +echo "dropping to node user" + +exec sudo -u node node server/server.js