Skip modify of user/group when PUID/GUID not changed
continuous-integration/drone/pr Build is passing Details

With this change, you can run the API image as non-root.
To run as non-root you must use 1000:1000.
This commit is contained in:
rocktop 2023-06-05 19:18:34 +00:00
parent a86518da71
commit 52009b3327
2 changed files with 4 additions and 3 deletions

View File

@ -35,8 +35,8 @@ ENV PUID 1000
ENV PGID 1000
RUN apk --update --no-cache add tzdata tini shadow && \
addgroup vikunja && \
adduser -s /bin/sh -D -G vikunja vikunja -h /app/vikunja -H
addgroup vikunja --gid "$PGID" && \
adduser -s /bin/sh -D -G vikunja vikunja --uid "$PUID" -h /app/vikunja -H
COPY docker/entrypoint.sh /entrypoint.sh
RUN chmod 0755 /entrypoint.sh && mkdir files

View File

@ -2,7 +2,8 @@
set -e
if [ -n "$PUID" ] && [ "$PUID" -ne 0 ] && \
[ -n "$PGID" ] && [ "$PGID" -ne 0 ] ; then
[ -n "$PGID" ] && [ "$PGID" -ne 0 ] && \
([ "$PUID" -ne "$(id -u vikunja)" ] || [ "$PGID" -ne "$(id -g vikunja)" ]) ; then
echo "info: creating the new user vikunja with $PUID:$PGID"
groupmod -g "$PGID" -o vikunja
usermod -u "$PUID" -o vikunja