Merge pull request #4 from SergeantPanda/main

Updated entrypoint
This commit is contained in:
Dispatcharr 2025-02-26 16:14:11 -06:00 committed by GitHub
commit 86e11e25cb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 42 additions and 5 deletions

3
.gitignore vendored
View file

@ -1,8 +1,7 @@
.DS_Store
__pycache__/
**/__pycache__/
.vscode/launch.json
.vscode/tasks.json
**/.vscode/
*.pyc
node_modules/
.history/

View file

@ -0,0 +1,24 @@
services:
dispatcharr:
build:
context: ..
dockerfile: docker/DockerfileAIO
container_name: dispatcharr-dev
restart: unless-stopped
ports:
- 9191:9191
#- 5432:5432
environment:
- PUID=1000
- PGID=1000
- POSTGRES_HOST=localhost
- POSTGRES_USER=dispatch
- POSTGRES_PASSWORD=secret
- POSTGRES_PORT=5432
- POSTGRES_DB=dispatcharr
- DJANGO_SUPERUSER_USERNAME=admin
- DJANGO_SUPERUSER_PASSWORD=admin
- DJANGO_SUPERUSER_EMAIL=admin@dispatcharr.local
volumes:
- ./data:/app/data

View file

@ -13,9 +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"
@ -104,17 +110,25 @@ 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..."
python manage.py collectstatic --noinput || true
python manage.py makemigrations --noinput || true
python manage.py migrate --noinput || true
echo_with_timestamp "Checking if Django superuser exists..."
if ! python manage.py shell -c "from django.contrib.auth import get_user_model; exit(0) if get_user_model().objects.filter(username='${DJANGO_SUPERUSER_USERNAME}').exists() else exit(1)"; then
echo_with_timestamp "Superuser does not exist. Creating..."
python manage.py createsuperuser --noinput || true
else
echo_with_timestamp "Superuser already exists. Skipping creation."
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
su - $POSTGRES_USER -c 'cd /app && gunicorn --workers=4 --worker-class=gevent --timeout=300 --bind 0.0.0.0:9191 dispatcharr.wsgi:application'