From d0165326a64f19d96b0bbdf701ecde1e98568cc6 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Tue, 15 Jul 2025 06:56:46 -0700 Subject: [PATCH] Tweak: Improve ownership check and chown handling for .next dir (#5513) --- docker-entrypoint.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 99379de1e..16ce33aa6 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -44,9 +44,15 @@ fi if [ -d /app/.next ]; then CURRENT_UID=$(stat -c %u /app/.next) - if [ "$CURRENT_UID" -ne "$PUID" ]; then + CURRENT_GID=$(stat -c %g /app/.next) + + if [ "$PUID" -ne 0 ] && ([ "$CURRENT_UID" -ne "$PUID" ] || [ "$CURRENT_GID" -ne "$PGID" ]); then echo "Fixing ownership of /app/.next" - chown -R "$PUID:$PGID" /app/.next || echo "Warning: Could not chown /app/.next" + if ! chown -R "$PUID:$PGID" /app/.next 2>/dev/null; then + echo "Warning: Could not chown /app/.next; continuing anyway" + fi + else + echo "/app/.next already owned by correct UID/GID or running as root, skipping chown" fi fi