-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
32 lines (27 loc) · 844 Bytes
/
docker-entrypoint.sh
File metadata and controls
32 lines (27 loc) · 844 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
32
#!/bin/bash
create_superuser="
import os
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mangoWeb.settings')
import django
django.setup()
from django.contrib.auth.models import User
try:
User.objects.create_superuser('$DJANGO_SUPERUSER_NAME', '$DJANGO_SUPERUSER_MAIL', '$DJANGO_SUPERUSER_PASS')
except Exception:
pass
"
create_superuser() {
if [ -z "$DJANGO_SUPERUSER_NAME" ] || [ -z "$DJANGO_SUPERUSER_MAIL" ] || [ -z "$DJANGO_SUPERUSER_PASS" ]; then
echo "Environment variables for database not set, not creating superuser."
else
echo "Creating superuser"
python -c "$create_superuser"
fi
}
if [ "$1" == "runserver" ]; then
echo "Running migrations"
python /code/manage.py makemigrations
python /code/manage.py migrate
create_superuser
exec python /code/manage.py "$@"
fi