···11+#!/bin/bash
22+set -e
33+44+# Get current UID/GID from environment or use defaults
55+USER_ID=${PUID:-$(stat -c '%u' "$SMALLWEB_DIR")}
66+GROUP_ID=${PGID:-$(stat -c '%g' "$SMALLWEB_DIR")}
77+88+if [ "$USER_ID" = "0" ]; then
99+ exec /usr/local/bin/smallweb "$@"
1010+fi
1111+1212+if [ "$(id -u smallweb)" != "$USER_ID" ]; then
1313+ echo "Updating user 'smallweb' with new UID -> $USER_ID"
1414+ usermod -u "$USER_ID" smallweb
1515+fi
1616+1717+if [ "$(id -g smallweb)" != "$GROUP_ID" ]; then
1818+ echo "Updating group 'smallweb' with new GID -> $GROUP_ID"
1919+ groupmod -g "$GROUP_ID" smallweb
2020+fi
2121+2222+# Execute the command as the smallweb user
2323+exec gosu smallweb:smallweb /usr/local/bin/smallweb "$@"
-21
entrypoint.sh
···11-#!/bin/bash
22-set -e
33-44-# Get current UID/GID from environment or use defaults
55-USER_ID=${PUID:-1000}
66-GROUP_ID=${PGID:-1000}
77-88-echo "Starting with UID: $USER_ID, GID: $GROUP_ID"
99-1010-# Update the user to match desired UID/GID if needed
1111-if [ "$USER_ID" != "1000" ] || [ "$GROUP_ID" != "1000" ]; then
1212- echo "Updating user 'smallweb' with new UID:GID -> $USER_ID:$GROUP_ID"
1313- groupmod -g "$GROUP_ID" smallweb
1414- usermod -u "$USER_ID" -g "$GROUP_ID" smallweb
1515-fi
1616-1717-# Ensure correct ownership of the application directory
1818-chown -R smallweb:smallweb /smallweb
1919-2020-# Execute the command as the smallweb user
2121-exec gosu smallweb:smallweb /usr/local/bin/smallweb "$@"