fix XSS and Root execution of NPM in docker

This commit is contained in:
Zimeng Xiong
2025-11-22 20:38:40 -08:00
parent 888834c8f0
commit 06f13d1404
7 changed files with 887 additions and 18 deletions
+23 -1
View File
@@ -7,8 +7,30 @@ if [ ! -f "/app/prisma/schema.prisma" ]; then
cp -R /app/prisma_template/. /app/prisma/
fi
# Run migrations
# Ensure proper ownership and permissions for data directories
echo "Setting up data directory permissions..."
mkdir -p /app/uploads
mkdir -p /app/prisma
# Set ownership to the node user (UID 1000)
if [ "$(id -u)" = "0" ]; then
# If running as root (for some reason), fix ownership
chown -R nodejs:nodejs /app/uploads
chown -R nodejs:nodejs /app/prisma
fi
# Ensure database file has proper permissions
if [ -f "/app/prisma/dev.db" ]; then
chmod 664 /app/prisma/dev.db 2>/dev/null || true
fi
# Set appropriate permissions for uploads directory
chmod 755 /app/uploads
# Run migrations as the current user
echo "Running database migrations..."
npx prisma migrate deploy
# Start the application
echo "Starting application as user $(whoami) (UID: $(id -u))"
node dist/index.js