Files
mt-drugs/backend/entrypoint.sh
2026-01-21 17:08:47 -05:00

24 lines
563 B
Bash

#!/bin/bash
set -e
# Default values
PUID=${PUID:-1000}
PGID=${PGID:-1000}
# Create group if it doesn't exist
if ! getent group $PGID > /dev/null; then
addgroup --gid $PGID appuser 2>/dev/null || true
fi
# Create user if it doesn't exist
if ! getent passwd $PUID > /dev/null; then
useradd -u $PUID -g $PGID -m -s /bin/bash appuser 2>/dev/null || true
fi
# Set ownership of app directory
mkdir -p /app/data
chown -R $PUID:$PGID /app
# Run command as the created user
exec gosu $PUID:$PGID python -m uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload