forked from jsykes/docker-taiga
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-entrypoint.sh
executable file
·70 lines (59 loc) · 2.29 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
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
# Setup database automatically if needed
if [ -z "$TAIGA_SKIP_DB_CHECK" ]; then
echo "Running database check"
python /checkdb.py
DB_CHECK_STATUS=$?
if [ $DB_CHECK_STATUS -eq 1 ]; then
echo "Failed to connect to database server or database does not exist."
exit 1
fi
# Database migration check should be done in all startup in case of backend upgrade
echo "Check for database migration"
python manage.py migrate --noinput
if [ $DB_CHECK_STATUS -eq 2 ]; then
echo "Configuring initial database"
python manage.py loaddata initial_user
python manage.py loaddata initial_project_templates
python manage.py loaddata initial_role
fi
fi
# In case of frontend upgrade, locales and statics should be regenerated
python manage.py compilemessages
python manage.py collectstatic --noinput
# Automatically replace "TAIGA_HOSTNAME" with the environment variable
sed -ri "s#(\"api\": \"http://).*(/api/v1/\",)#\1$TAIGA_HOSTNAME\2#g" /taiga/conf.json
# Look to see if we should set the "eventsUrl"
if [ ! -z "$RABBIT_PORT_5672_TCP_ADDR" ]; then
echo "Enabling Taiga Events"
sed -i "s#eventsUrl\": null#eventsUrl\": \"ws://$TAIGA_HOSTNAME/events\"#g" /taiga/conf.json
fi
# Handle enabling/disabling SSL
if [ "$TAIGA_SSL_BY_REVERSE_PROXY" = "True" ] || [ "$TAIGA_SSL" = "True" ]; then
echo "Enabling SSL support!"
sed -i "s#http://#https://#g" /taiga/conf.json
sed -i "s#ws://#wss://#g" /taiga/conf.json
elif grep -q "wss://" "/taiga/conf.json"; then
echo "Disabling SSL support!"
sed -i "s#https://#http://#g" /taiga/conf.json
sed -i "s#wss://#ws://#g" /taiga/conf.json
fi
# Reinitialize nginx links
rm /etc/nginx/sites-enabled/*
if [ "$TAIGA_SSL_BY_REVERSE_PROXY" = "True" ] || [ "$TAIGA_SSL" = "True" ]; then
if [ ! -z "$RABBIT_PORT_5672_TCP_ADDR" ]; then
ln -s /etc/nginx/sites-available/taiga-ssl /etc/nginx/sites-enabled/taiga-events-ssl
else
ln -s /etc/nginx/sites-available/taiga-ssl /etc/nginx/sites-enabled/taiga-ssl
fi
else
if [ ! -z "$RABBIT_PORT_5672_TCP_ADDR" ]; then
ln -s /etc/nginx/sites-available/taiga /etc/nginx/sites-enabled/taiga-events
else
ln -s /etc/nginx/sites-available/taiga /etc/nginx/sites-enabled/taiga
fi
fi
# Start nginx service (need to start it as background process)
service nginx start
# Start gunicorn server
exec "$@"