forked from Patrowl/PatrowlManager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-entrypoint.sh
executable file
·47 lines (36 loc) · 1.42 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
#!/bin/bash
echo "[+] Wait for DB availability"
while !</dev/tcp/db/5432; do sleep 1; done
source env3/bin/activate
# Collect static files
echo "[+] Collect static files"
python manage.py collectstatic --noinput
# Apply database migrations
echo "[+] Make database migrations"
python manage.py makemigrations
# Apply database migrations
echo "[+] Apply database migrations"
python manage.py migrate
# Check for first install
if [ ! -f status.created ]; then
# Create the default admin user
echo "[+] Create the default admin user"
echo "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('admin', 'admin@dev.patrowl.io', 'Bonjour1!')" | python manage.py shell
# Populate the db with default data
echo "[+] Populate the db with default data"
python manage.py loaddata var/data/assets.AssetCategory.json
python manage.py loaddata var/data/engines.Engine.json
python manage.py loaddata var/data/engines.EnginePolicyScope.json
python manage.py loaddata var/data/engines.EnginePolicy.json
touch status.created
fi
# Start Supervisord (Celery workers)
echo "[+] Start Supervisord (Celery workers)"
supervisord -c var/etc/supervisord.conf
# Configure engines and turn-on auto-refresh engine status
if [ -f set_engines.py ]; then
python manage.py shell < set_engines.py
fi
# Start server
echo "[+] Starting server"
gunicorn -b 0.0.0.0:8003 app.wsgi:application --timeout 300