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
950 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. apt-get update && apt-get install -y g++ unixodbc-dev # pyodbc build dependencies
  14. "${venv}/bin/pip" install -r "${root}/requirements.txt"
  15. echo "Initializing database"
  16. "${venv}/bin/python" "${app}/manage.py" wait_for_db
  17. "${venv}/bin/python" "${app}/manage.py" migrate
  18. if [[ -n "${ADMIN_USERNAME}" ]] && [[ -n "${ADMIN_PASSWORD}" ]] && [[ -n "${ADMIN_EMAIL}" ]]; then
  19. "${venv}/bin/python" "${app}/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. "${venv}/bin/python" -u "${app}/manage.py" runserver "$@"