diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 4efd9c3..6031a2b 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -5,21 +5,29 @@ set -e +# If not running as root, do nothing +if [ "$(id -u)" != "0" ]; then + echo "Running as non-root user ($(id -u)), skipping PUID/PGID handling" + exec "$@" +fi + + # Function to create user and switch to it switch_user() { local puid="$1" local pgid="$2" - # Create group if it doesn't exist - if ! getent group bichon >/dev/null 2>&1; then + # group: avoid GID conflict + if ! getent group "$pgid" >/dev/null 2>&1; then groupadd -g "$pgid" bichon fi - # Create user if it doesn't exist + # user: ensure bichon exists if ! getent passwd bichon >/dev/null 2>&1; then useradd -u "$puid" -g "$pgid" -s /bin/bash -d /data bichon fi + # Change ownership of directories that the process needs to write to chown -R "$puid:$pgid" /data chown -R "$puid:$pgid" /opt/bichon