-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
31 lines (26 loc) · 870 Bytes
/
docker-entrypoint.sh
File metadata and controls
31 lines (26 loc) · 870 Bytes
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
#!/bin/bash
set -e
echo "Waiting for database..."
while ! python -c "
import django, os
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'fleet_manager.settings')
django.setup()
from django.db import connection
connection.ensure_connection()
" 2>/dev/null; do
echo "Database unavailable, waiting 2s..."
sleep 2
done
echo "Database ready!"
# Only run migrations and collectstatic for the web (gunicorn/daphne) container
if [[ "$1" == "gunicorn" || "$1" == "daphne" ]]; then
echo "Running migrations..."
python manage.py migrate --noinput
echo "Collecting static files..."
python manage.py collectstatic --noinput
# Auto-update nginx config in nginx container via Docker API
if [ -S /var/run/docker.sock ] && [ -f /app/nginx.conf ]; then
python3 /app/update-nginx-conf.py || echo "Nginx auto-update skipped"
fi
fi
exec "$@"