-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
36 lines (29 loc) · 1.13 KB
/
entrypoint.sh
File metadata and controls
36 lines (29 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env bash
# Exit on error
set -o errexit
# Collect static files, run migrations, and start server
echo "Running migrations..."
python manage.py makemigrations Crash_Analysis --noinput || true
python manage.py migrate --noinput
python manage.py migrate Crash_Analysis --noinput
# Optionally create a superuser automatically (if env vars set)
if [ "$DJANGO_SUPERUSER_USERNAME" ] && [ "$DJANGO_SUPERUSER_EMAIL" ] && [ "$DJANGO_SUPERUSER_PASSWORD" ]; then
echo "Creating superuser..."
python manage.py createsuperuser \
--noinput \
--username "$DJANGO_SUPERUSER_USERNAME" \
--email "$DJANGO_SUPERUSER_EMAIL" || true
else
echo "Skipping superuser creation (env vars not set)"
fi
python manage.py collectstatic --noinput
if [ "${DELETE_DATA,,}" = "true" ]; then
echo "Removing data"
python manage.py shell -c "
from django.apps import apps
for model in apps.get_app_config('Crash_Analysis').get_models():
model.objects.all().delete()
"
fi
echo "Starting Gunicorn..."
exec gunicorn FARS_Project.wsgi:application --bind 0.0.0.0:$PORT --workers 1 --threads 2 --access-logfile - --error-logfile - --log-level debug --timeout 300