diff --git a/Procfile b/Procfile new file mode 100644 index 0000000000000000000000000000000000000000..72bd20b3dc7e841b11602bf624e76945d2bd1029 --- /dev/null +++ b/Procfile @@ -0,0 +1,2 @@ +release: python manage.py migrate +web: gunicorn pas.wsgi \ No newline at end of file diff --git a/Procfile.windows b/Procfile.windows new file mode 100644 index 0000000000000000000000000000000000000000..4feca226002315d8db6d857e58da0e8a7f943c97 --- /dev/null +++ b/Procfile.windows @@ -0,0 +1 @@ +web: python manage.py runserver 0.0.0.0:5000 \ No newline at end of file diff --git a/README.md b/README.md index 5b7ca3bac8a8b4730980b2c8d21ce1000ec277fc..1443c16ae2438494244160a713d4d024ae7574bd 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,18 @@ recommend setting up a virtual environment, using e.g. Python's `venv` module: * Install the required packages: `pip install -r requirements.txt` * Apply database migrations: `python manage.py migrate` * Optionally populate the database: `python manage.py populatedefaults` `python manage.py populatesamples` + * or `python manage.py loadcsvdata test_data/[data folder]` * Run the application: `python manage.py runserver` * This will make the application available on port 8000; visit it by going to https://localhost:8000/ in your browser. * Deactivate the virtual environment when you are done: `deactivate` + +## Heroku Deployment (for test administration) +* Install the Heroku CLI +* Open bash from the local repository root folder +* Run `heroku login` and log in +* Run `heroku create pasapp` to create a heroku app on your account +* Run `git push heroku [local branchname]:main` to push and deploy the app +* Run `heroku ps:scale web=1` to allocate one web server to the app +* Run `heroku run bash` to open a bash on the live server + * `python manage.py loadcsvdata test_data/[data folder]` to populate the server diff --git a/pas/settings.py b/pas/settings.py index 97aaee19f05bf3340b5e7bca997e6eeb55f91e44..42132d55cc9fcfb161e7717249912d62c8ecb1cf 100644 --- a/pas/settings.py +++ b/pas/settings.py @@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/3.2/ref/settings/ """ from pathlib import Path +import django_heroku # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent @@ -23,11 +24,11 @@ BASE_DIR = Path(__file__).resolve().parent.parent SECRET_KEY = 'django-insecure-r0hfpfd#gt30%9tj!8@&%q2t&^m&s-qz7(o(qgj@qait@&25gc' # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +DEBUG = False +#django_heroku overrides this with the correct value below ALLOWED_HOSTS = [] - # Application definition INSTALLED_APPS = [ @@ -120,6 +121,7 @@ USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/3.2/howto/static-files/ +STATIC_ROOT = BASE_DIR / 'static' STATIC_URL = '/static/' # Default primary key field type @@ -128,3 +130,5 @@ STATIC_URL = '/static/' DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' LOGIN_URL = '/login/' + +django_heroku.settings(locals()) \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index c496a00a07871035d6f9b98c57508d9c8f507120..fb32f484f0076bbc9d87ef322132e6d05393c296 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,5 @@ asgiref==3.4.1 Django==3.2.9 pytz==2021.3 sqlparse==0.4.2 +gunicorn==20.1.0 +django-heroku==0.3.1 \ No newline at end of file