-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
33 lines (25 loc) · 819 Bytes
/
run.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
#!/usr/bin/env bash
if [ "$ENVIRONMENT" = "dev" ]; then
echo "[run] make migrations"
python3 manage.py makemigrations || exit 1
fi
echo "[run] Migrate DB"
python3 manage.py migrate || exit 1
echo "[run] Create superuser"
echo "from django.contrib.auth import get_user_model
User = get_user_model()
if not User.objects.filter(is_superuser=True).exists():
user = User()
user.first_name = 'Admin'
user.last_name = 'Dev'
user.is_superuser = True
user.is_staff = True
user.set_password('qwerty123')
user.email = '${ADMIN_EMAIL}'
user.username = 'admin'
user.save()
" | python3 manage.py shell || exit 1
[ "$ENVIRONMENT" = dev ] &&
python3 manage.py runserver 0.0.0.0:8000
[ "$ENVIRONMENT" != dev ] &&
gunicorn config.wsgi:application --bind 0.0.0.0:8000 --log-level=info --timeout=500