#!/bin/bash set -e # Detect if we are running as root (default) if [ "$(id -u)" = "0" ]; then # Ensure the temp directory exists and set ownership if [ -d "/tmp/audio_splitter_web" ]; then echo "Setting ownership of /tmp/audio_splitter_web to appuser:appgroup" chown -R appuser:appgroup /tmp/audio_splitter_web else echo "Creating /tmp/audio_splitter_web and setting ownership" mkdir -p /tmp/audio_splitter_web chown -R appuser:appgroup /tmp/audio_splitter_web fi # Drop privileges and run uvicorn using gosu exec gosu appuser uvicorn backend.main:app --host 0.0.0.0 --port 8000 else # If not root, just run directly exec uvicorn backend.main:app --host 0.0.0.0 --port 8000 fi