-
Notifications
You must be signed in to change notification settings - Fork 4
/
docker-entrypoint.sh
executable file
Β·59 lines (53 loc) Β· 1.52 KB
/
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
export DJANGO_SETTINGS_MODULE=${DJANGO_SETTINGS_MODULE:-pyconkr.prod-settings}
echo "Yarn install"
yarn install
echo "Collect static files"
python manage.py compilemessages
python manage.py compilescss
python manage.py collectstatic --noinput &
#python manage.py compress --force
echo "Apply database migrations"
python manage.py makemigrations
python manage.py migrate
# For Debug
echo ""
echo "========== python manage.py showmigrations =========="
python manage.py showmigrations
echo ""
echo ""
echo "Create admin user"
CREATE_ADMIN_SOURCE="
from django.contrib.auth.models import User
from django.contrib.auth import get_user_model
UserModel = get_user_model()
# Create admin user
USERNAME='pyconkr'
EMAIL='pyconkr@pycon.kr'
# Should be changed
PASSWORD='pyconkr'
try:
UserModel.objects.get(username=USERNAME)
except UserModel.DoesNotExist:
User.objects.create_superuser(USERNAME, EMAIL, PASSWORD)
"
echo "${CREATE_ADMIN_SOURCE}" | python manage.py shell
mkdir -p /logs
touch /logs/gunicorn.log
touch /logs/access.log
tail -n 0 -f /logs/*.log &
echo "==== Starting server ====="
gunicorn pyconkr.wsgi:application \
--bind=0.0.0.0:8000 \
--workers 1 \
# --threads 256 \
--worker-connections=5000 \
--max-requests 10000 \
--max-requests-jitter 5 \
-k gevent \
--log-level=info \
--log-file=/logs/gunicorn.log \
# --log-file=-
--access-logfile=/logs/access.log \
# --preload
# https://stackoverflow.com/questions/12449172/how-to-debug-gunicorn-failure-issues-worker-failed-to-boot