-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathentrypoint.sh
executable file
·51 lines (38 loc) · 1.21 KB
/
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
#!/bin/bash
set -e
if [ -z "$1" ]; then
if [ ! -f /app/config/config.py ]; then
cp /app/config.py.example /app/config/config.py
fi
#if app is mounted, Dockerfile is available
if [ -f Dockerfile ]; then
pip3 install -r requirements.txt
fi
#chicken and egg problem: checking needs migrations
#wait for postgres
# until python3 manage.py db current > /dev/null ; do
# >&2 echo "Postgres is unavailable - sleeping"
# sleep 1
# done
# if /app/migrations is empty init database
if [ ! -f /app/migrations/README ]; then
python3 manage.py db init -d /tmp/migrations 2> /dev/null
mv /tmp/migrations/* /app/migrations
fi
python3 manage.py db migrate
python3 manage.py db upgrade
python3 manage.py imoprtInitData
python3 manage.py generate_asset
python3 worker.py &
#if app is mounted, Dockerfile is available
if [ -f Dockerfile ]; then
echo "Running app in debug mode!"
#run translation
python3 manage.py pybabel
python3 manage.py runserver -h 0.0.0.0 -p 80
else
echo "Running app in production mode!"
nginx && uwsgi --ini /app/app.ini
fi
fi
exec "$@"