Files
tally-counter/entrypoint.sh
T
sebastas b8e7570dc0
Build and publish Docker image / build-and-push (release) Successful in 19s
fix: update user and group modification logic in entrypoint script (again)
2026-07-02 16:36:23 +02:00

26 lines
688 B
Bash

#!/bin/sh
set -e
PUID=${PUID:-1001}
PGID=${PGID:-1001}
# Only remap if the requested IDs differ from the defaults baked into the image
if [ "$PGID" != "1001" ]; then
existing_group=$(getent group "$PGID" | cut -d: -f1)
if [ -n "$existing_group" ] && [ "$existing_group" != "nodejs" ]; then
groupmod -g "$((PGID + 50000))" "$existing_group"
fi
groupmod -g "$PGID" nodejs
fi
if [ "$PUID" != "1001" ]; then
existing_user=$(getent passwd "$PUID" | cut -d: -f1)
if [ -n "$existing_user" ] && [ "$existing_user" != "nextjs" ]; then
usermod -u "$((PUID + 50000))" "$existing_user"
fi
usermod -u "$PUID" nextjs
fi
chown -R nextjs:nodejs /data
exec su-exec nextjs "$@"