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.

33 lines
868 B

  1. #!/usr/bin/env bash
  2. set -o errexit
  3. root="$(dirname "$0")/.."
  4. app="${root}/app"
  5. venv="${root}/venv"
  6. if [[ ! -f "${venv}/bin/python" ]]; then
  7. echo "Creating virtualenv"
  8. mkdir -p "${venv}"
  9. python3 -m venv "${venv}"
  10. "${venv}/bin/pip" install --upgrade pip setuptools
  11. fi
  12. echo "Installing dependencies"
  13. "${venv}/bin/pip" install -r "${root}/requirements.txt"
  14. echo "Initializing database"
  15. "${venv}/bin/python" "${app}/manage.py" wait_for_db
  16. "${venv}/bin/python" "${app}/manage.py" migrate
  17. if [[ -n "${ADMIN_USERNAME}" ]] && [[ -n "${ADMIN_PASSWORD}" ]] && [[ -n "${ADMIN_EMAIL}" ]]; then
  18. "${venv}/bin/python" "${app}/manage.py" create_admin \
  19. --username "${ADMIN_USERNAME}" \
  20. --password "${ADMIN_PASSWORD}" \
  21. --email "${ADMIN_EMAIL}" \
  22. --noinput \
  23. || true
  24. fi
  25. echo "Starting django"
  26. "${venv}/bin/python" -u "${app}/manage.py" runserver "$@"