#!/bin/sh
set -e

# Ensure uploads directory exists and is writable
mkdir -p /app/public/uploads

# Fix permissions for uploads directory (needed for volume mounts)
chown -R nodejs:nodejs /app/public/uploads
chmod -R 755 /app/public/uploads

# Switch to nodejs user and execute the main command
exec su-exec nodejs "$@"
