From 9e381ebe323cdda8cf120a12c0803da9765c227d Mon Sep 17 00:00:00 2001 From: Joakim Persson Date: Mon, 13 Apr 2026 19:46:25 +0200 Subject: [PATCH] Fix ownership of named volume mount points in entrypoint Named Docker volumes are created as root on first use, causing permission denied errors for the developer user. The entrypoint now fixes ownership of all known volume mount points after UID/GID adjustment. --- entrypoint.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/entrypoint.sh b/entrypoint.sh index e40181f..dc510a2 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -46,5 +46,23 @@ if [ -d "/home/$USER_NAME/.ssh" ] && [ "$(ls -A "/home/$USER_NAME/.ssh" 2>/dev/n fi fi +# ── Fix ownership of named volume mount points ────────────────────── +# Named volumes are created as root on first use. Fix ownership so the +# developer user can write to them. +FINAL_UID="${TARGET_UID:-$CURRENT_UID}" +FINAL_GID="${TARGET_GID:-$CURRENT_GID}" +for dir in \ + /home/"$USER_NAME"/.local/share/opencode \ + /home/"$USER_NAME"/.local/share/uv \ + /home/"$USER_NAME"/.rustup \ + /home/"$USER_NAME"/.cargo \ + /home/"$USER_NAME"/.vscode-server \ + /home/"$USER_NAME"/.config/opencode \ + /home/"$USER_NAME"/.config/nvim; do + if [ -d "$dir" ] && [ "$(stat -c '%u' "$dir" 2>/dev/null)" != "$FINAL_UID" ]; then + chown -R "$FINAL_UID":"$FINAL_GID" "$dir" 2>/dev/null || true + fi +done + # ── Drop to developer user for remaining setup ────────────────────── exec gosu "$USER_NAME" /usr/local/bin/entrypoint-user.sh "$@"