You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.1 KiB

  1. #!/usr/bin/env bash
  2. set -o errexit
  3. if [[ -z "${ADMIN_USERNAME}" ]]; then echo "Missing ADMIN_USERNAME environment variable" >&2; exit 1; fi
  4. if [[ -z "${ADMIN_PASSWORD}" ]]; then echo "Missing ADMIN_PASSWORD environment variable" >&2; exit 1; fi
  5. if [[ -z "${ADMIN_EMAIL}" ]]; then echo "Missing ADMIN_EMAIL environment variable" >&2; exit 1; fi
  6. set -o nounset
  7. echo "Making staticfiles"
  8. static_dir=staticfiles
  9. if [[ ! -d $static_dir ]] || [[ -z $(ls -A $static_dir) ]]; then
  10. echo "Executing collectstatic"
  11. python manage.py collectstatic --noinput;
  12. fi
  13. echo "Initializing database"
  14. python manage.py wait_for_db
  15. python manage.py migrate
  16. python manage.py create_roles
  17. echo "Creating admin"
  18. if [[ -n "${ADMIN_USERNAME}" ]] && [[ -n "${ADMIN_PASSWORD}" ]] && [[ -n "${ADMIN_EMAIL}" ]]; then
  19. python manage.py create_admin \
  20. --username "${ADMIN_USERNAME}" \
  21. --password "${ADMIN_PASSWORD}" \
  22. --email "${ADMIN_EMAIL}" \
  23. --noinput \
  24. || true
  25. fi
  26. echo "Starting django"
  27. gunicorn --bind="${HOST:-0.0.0.0}:${PORT:-8000}" --workers="${WORKERS:-4}" config.wsgi --timeout 300