mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
fix(docker): warn on workspace gid mismatch as well as uid
This commit is contained in:
1 parent
3ad90e5894
commit
b3394a976e
3 files changed
+43
-15
No files matched your search
@@ -92,7 +92,7 @@ if ! align_container_user node; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
warn_if_workspace_owner_differs /workspace "$OCM_TARGET_UID"
|
||||
warn_if_workspace_owner_differs /workspace "$OCM_TARGET_UID" "$OCM_TARGET_GID"
|
||||
|
||||
mkdir -p /app/data /workspace /home/node/.cache /home/node/.opencode
|
||||
chown -R node:node /app/data /workspace /home/node
|
||||
|
||||
@@ -81,15 +81,18 @@ align_container_user() {
|
||||
}
|
||||
|
||||
warn_if_workspace_owner_differs() {
|
||||
local path="$1" target_uid="$2" current_uid
|
||||
local path="$1" target_uid="$2" target_gid="$3" owner current_uid current_gid
|
||||
|
||||
[ -d "$path" ] || return 0
|
||||
[ -n "$(ls -A "$path" 2>/dev/null)" ] || return 0
|
||||
|
||||
current_uid="$(stat -c %u "$path" 2>/dev/null)" || return 0
|
||||
if [ "$current_uid" != "$target_uid" ]; then
|
||||
echo "WARNING: $path is owned by uid $current_uid but the container will run as uid $target_uid" >&2
|
||||
echo "WARNING: startup is about to chown $path to uid $target_uid, rewriting ownership of existing files" >&2
|
||||
owner="$(stat -c '%u %g' "$path" 2>/dev/null)" || return 0
|
||||
current_uid="${owner%% *}"
|
||||
current_gid="${owner##* }"
|
||||
|
||||
if [ "$current_uid" != "$target_uid" ] || [ "$current_gid" != "$target_gid" ]; then
|
||||
echo "WARNING: $path is owned by uid $current_uid/gid $current_gid but the container will run as uid $target_uid/gid $target_gid" >&2
|
||||
echo "WARNING: startup is about to chown $path to uid $target_uid/gid $target_gid, rewriting ownership of existing files" >&2
|
||||
echo "WARNING: stop the container now and set PUID/PGID from 'id -u' and 'id -g' if that is not intended" >&2
|
||||
fi
|
||||
}
|
||||
Reference in new issue
Block a user