/ api-gateway / docker-entrypoint.sh
docker-entrypoint.sh
1 #!/bin/sh 2 set -e 3 4 # Fix permissions for uploads and sessions directories if they exist 5 # This runs as root before switching to user 1000 6 if [ -d "/app/uploads" ]; then 7 chown -R 1000:1000 /app/uploads || true 8 chmod -R 755 /app/uploads || true 9 fi 10 11 if [ -d "/app/sessions" ]; then 12 chown -R 1000:1000 /app/sessions || true 13 chmod -R 755 /app/sessions || true 14 fi 15 16 # Switch to non-root user and execute command 17 if [ "$(id -u)" = "0" ]; then 18 # If running as root, switch to user fastapi (UID 1000) using runuser 19 # First check if user exists, create if not 20 if ! id -u 1000 > /dev/null 2>&1; then 21 useradd -m -u 1000 fastapi || true 22 fi 23 exec runuser -u fastapi -- "$@" 24 else 25 # If already running as non-root, just execute 26 exec "$@" 27 fi