forked from City-of-Helsinki/apartment-application-service
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
executable file
·48 lines (41 loc) · 1.12 KB
/
Copy pathdocker-entrypoint.sh
File metadata and controls
executable file
·48 lines (41 loc) · 1.12 KB
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
#!/bin/bash
set -e
if [ -n "$DATABASE_HOST" ]; then
until nc -z -v -w30 "$DATABASE_HOST" 5432
do
echo "Waiting for postgres database connection..."
sleep 1
done
echo "Database is up!"
fi
if [ -n "$ELASTICSEARCH_HOST" ]; then
until nc -z -v -w30 "$ELASTICSEARCH_HOST" "$ELASTICSEARCH_HOST_PORT"
do
echo "Waiting for elasticsearch connection..."
sleep 1
done
echo "Elasticsearch is up!"
fi
# Apply database migrations
if [[ "$APPLY_MIGRATIONS" = "1" ]]; then
echo "Applying database migrations..."
./manage.py migrate --noinput
fi
# Create superuser
if [[ "$CREATE_SUPERUSER" = "1" ]]; then
./manage.py add_admin_user -u admin -p admin -e admin@example.com
echo "Admin user created with credentials admin:admin (email: admin@example.com)"
fi
# Create data transfer folder
if [[ "$CREATE_DATA_TRANSFER_PATH" = "1" ]]; then
./manage.py create_data_transfer_folder
echo "Apartment data transfer folder created"
fi
# Start server
if [[ ! -z "$@" ]]; then
"$@"
elif [[ "$DEV_SERVER" = "1" ]]; then
python ./manage.py runserver 0.0.0.0:8081
else
uwsgi --ini .prod/uwsgi.ini
fi