Fix ownership handling in app scripts

This commit is contained in:
2026-05-27 10:14:51 +02:00
parent 438c29e2e0
commit 58e646e0a0
2 changed files with 26 additions and 2 deletions
+14 -1
View File
@@ -15,6 +15,17 @@ APP_SOURCE_DIR="$WORKSPACE_DIR/$APP_ID"
CATALOG_FILE="$APPFACTORY_DIR/apps/catalog.yml"
TOOLS_DIR="$WORKSPACE_DIR/appfactory-tools"
safe_chown() {
local target="$1"
local uid
local gid
uid="${APP_UID:-$(stat -c '%u' "$WORKSPACE_DIR")}"
gid="${APP_GID:-$(stat -c '%g' "$WORKSPACE_DIR")}"
chown -R "$uid:$gid" "$target" || true
}
if [ ! -d "$APP_SOURCE_DIR" ]; then
echo "Missing app source: $APP_SOURCE_DIR"
exit 1
@@ -25,7 +36,7 @@ if [ ! -f "$APP_SOURCE_DIR/Dockerfile" ]; then
exit 1
fi
chown -R "$APP_USER:$APP_GROUP" "$APP_SOURCE_DIR" || true
safe_chown "$APP_SOURCE_DIR"
echo "Updating source code..."
cd "$APP_SOURCE_DIR"
@@ -68,6 +79,8 @@ cd "$APPFACTORY_DIR/deploy"
docker compose -f docker-compose.yml -f apps-compose.yml up -d --force-recreate "$APP_ID"
safe_chown "$APP_SOURCE_DIR"
echo ""
echo "DONE"
echo "Open:"