From 808e305a1c2babc792144a0cf3c152f18d0db54a Mon Sep 17 00:00:00 2001 From: SergeantPanda Date: Sun, 23 Feb 2025 15:36:07 -0600 Subject: [PATCH] entrypoint now runs as the user context specified by PUID and PGID. --- docker/entrypoint.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 46f44b8d..a928ce69 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -13,12 +13,15 @@ export POSTGRES_USER=${POSTGRES_USER:-dispatch} export POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-secret} export POSTGRES_HOST=${POSTGRES_HOST:-localhost} export POSTGRES_PORT=${POSTGRES_PORT:-5432} +export PUID=${PUID:-1000} +export PGID=${PGID:-1000} export DJANGO_SUPERUSER_USERNAME=${DEFAULT_USERNAME:-admin} export DJANGO_SUPERUSER_PASSWORD=${DEFAULT_PASSWORD:-admin} export DJANGO_SUPERUSER_EMAIL=${DEFAULT_EMAIL:-admin@dispatcharr.local} export PGDATA=${PGDATA:-/app/data/db} export PG_BINDIR="/usr/lib/postgresql/14/bin" + # Echo environment variables for debugging echo_with_timestamp "POSTGRES_DB: $POSTGRES_DB" echo_with_timestamp "POSTGRES_USER: $POSTGRES_USER" @@ -107,7 +110,7 @@ fi # Start Redis echo_with_timestamp "Starting Redis..." -service redis-server start +su - $POSTGRES_USER -c 'redis-server --daemonize yes' # Run Django commands echo_with_timestamp "Running Django commands..." @@ -124,8 +127,8 @@ fi # Start Celery echo_with_timestamp "Starting Celery..." -celery -A dispatcharr worker --loglevel=info & +su - $POSTGRES_USER -c 'cd /app && celery -A dispatcharr worker --loglevel=info &' # Start Gunicorn echo_with_timestamp "Starting Gunicorn..." -gunicorn --workers=4 --worker-class=gevent --timeout=300 --bind 0.0.0.0:9191 dispatcharr.wsgi:application \ No newline at end of file +su - $POSTGRES_USER -c 'cd /app && gunicorn --workers=4 --worker-class=gevent --timeout=300 --bind 0.0.0.0:9191 dispatcharr.wsgi:application' \ No newline at end of file