entrypoint.sh 633 Bytes
Newer Older
1 2 3 4 5 6 7
#!/usr/bin/env bash
set -eo pipefail

# default variables
: "${SLEEP:=1}"
: "${TRIES:=60}"

8
function wait_for_database {
9 10 11 12
  echo "Waiting for database to respond..."
  tries=0
  while true; do
    [[ $tries -lt $TRIES ]] || return
13
    (echo "from django.db import connection; connection.connect()" | umap shell)
14 15 16 17
    [[ $? -eq 0 ]] && return
    sleep $SLEEP
    tries=$((tries + 1))
  done
18
}
19

20
echo "Wait for the database..."
21
wait_for_database
22
echo "Migrate the database..."
23
umap migrate
24
echo "Collect static files..."
25
umap collectstatic --noinput
26
echo "Compress static files..."
27
umap compress
28

29
echo "Launch uMap via uWSGI..."
30
exec $@