docker-entrypoint.sh 676 B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env bash
  2. set -eo pipefail
  3. # default variables
  4. : "${SLEEP:=1}"
  5. : "${TRIES:=60}"
  6. function wait_for_database {(
  7. echo "Waiting for database to respond..."
  8. tries=0
  9. while true; do
  10. [[ $tries -lt $TRIES ]] || return
  11. (echo "from django.db import connection; connection.connect()" | umap shell) >/dev/null 2>&1
  12. [[ $? -eq 0 ]] && return
  13. sleep $SLEEP
  14. tries=$((tries + 1))
  15. done
  16. )}
  17. # first wait for the database
  18. wait_for_database
  19. # then migrate the database
  20. umap migrate
  21. # then collect static files
  22. umap collectstatic --noinput
  23. # create languagae files
  24. #umap storagei18n
  25. # compress static files
  26. umap compress
  27. # run uWSGI
  28. exec uwsgi --ini uwsgi.ini