forked from BASIN-3D/docker-django-basin3d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-entrypoint.sh
executable file
·40 lines (28 loc) · 975 Bytes
/
docker-entrypoint.sh
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
37
38
39
40
#!/usr/bin/env bash
echo "********************************"
echo " BASIN-3D APP Docker Entrypoint "
echo "********************************"
# Loads the environment variables
source /usr/local/bin/docker-manage-entrypoint.sh
if [ "$DATABASE" = "postgres" ]
then
echo "Waiting for postgres..."
while ! nc -z ${SQL_HOST:-db} ${SQL_PORT:-5432}; do
sleep 0.1
done
echo "PostgreSQL started"
fi
pip freeze
# Collect the static files
python manage.py collectstatic --no-input
# migrate django
python manage.py migrate
IS_LOADED=$(./manage.py shell -c "from django.contrib.auth.models import User; print(User.objects.count())")
echo "IS_LOADED:$IS_LOADED"
if [ "${IS_LOADED}" == "0" ];
then
# Create a default superuser
./manage.py shell -c "from django.contrib.auth.models import User; User.objects.create_superuser('${ADMIN_USER:-admin}', '${ADMIN_EMAIL}', '${ADMIN_PASSWORD}')"
echo "Admin superuser '${ADMIN_USER}' created"
fi
exec $@