From 567a6058e7f145d53370b708d979715646199a3e Mon Sep 17 00:00:00 2001 From: John Joshua Abulo Date: Mon, 30 Jul 2018 11:13:35 +0300 Subject: [PATCH] [Chore #159327974] Host Authors Haven on Heroku --- .gitignore | 1 - .travis.yml | 3 +++ Procfile | 1 + README.md | 3 +++ .../migrations/0002_auto_20180726_1459.py | 18 ++++++++++++++++++ authors/settings/base.py | 11 +++++++++-- authors/wsgi.py | 2 +- requirements.txt | 2 ++ 8 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 Procfile create mode 100644 authors/apps/authentication/migrations/0002_auto_20180726_1459.py diff --git a/.gitignore b/.gitignore index fba7af4..496c3f2 100644 --- a/.gitignore +++ b/.gitignore @@ -98,4 +98,3 @@ db.sqlite3 # DS_store .DS_Store -authors/ diff --git a/.travis.yml b/.travis.yml index c427da3..a4141af 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,3 +11,6 @@ script: after_success: - coveralls +env: + - SECRET_KEY='7pgozr2jn7zs_o%i8id6=rddieSECRET_KEY0f0qy3$oy$(8231i^4*@u3' + diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..1d6b99c --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: gunicorn authors.wsgi diff --git a/README.md b/README.md index cbb3821..e94d1a1 100644 --- a/README.md +++ b/README.md @@ -405,3 +405,6 @@ No additional parameters required `python3 manage.py test --settings=authors.settings.test` +### Application [Staging](https://en.wikipedia.org/wiki/Deployment_environment#Staging) Host Name + +`https://authorshaven.herokuapp.com/` diff --git a/authors/apps/authentication/migrations/0002_auto_20180726_1459.py b/authors/apps/authentication/migrations/0002_auto_20180726_1459.py new file mode 100644 index 0000000..09eba06 --- /dev/null +++ b/authors/apps/authentication/migrations/0002_auto_20180726_1459.py @@ -0,0 +1,18 @@ +# Generated by Django 2.0.6 on 2018-07-26 14:59 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('authentication', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='user', + name='username', + field=models.CharField(db_index=True, max_length=25, unique=True), + ), + ] diff --git a/authors/settings/base.py b/authors/settings/base.py index dd75e2e..5ebb6cb 100644 --- a/authors/settings/base.py +++ b/authors/settings/base.py @@ -8,6 +8,7 @@ """ import os +import dj_database_url # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) @@ -16,9 +17,9 @@ # See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = '7pgozr2jn7zs_o%i8id6=rddie!*0f0qy3$oy$(8231i^4*@u3' +SECRET_KEY = os.getenv('SECRET_KEY') -ALLOWED_HOSTS = [] +ALLOWED_HOSTS = ['127.0.0.1','localhost','authorshaven.herokuapp.com'] # automaticall append slashes APPEND_SLASH = True @@ -79,6 +80,12 @@ }, ] +# using the dj_database_url +# https://stackoverflow.com/questions/16868451/how-to-set-up-database-for-django-app-on-heroku +# https://devcenter.heroku.com/articles/python-concurrency-and-database-connections +# https://stackoverflow.com/questions/27985368/heroku-databases-is-not-defined +DATABASES = { 'default': dj_database_url.config(conn_max_age=600, ssl_require=True) } + WSGI_APPLICATION = 'authors.wsgi.application' # Password validation diff --git a/authors/wsgi.py b/authors/wsgi.py index a444b04..e898130 100644 --- a/authors/wsgi.py +++ b/authors/wsgi.py @@ -11,6 +11,6 @@ from django.core.wsgi import get_wsgi_application -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "authors.settings") +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "authors.settings.base") application = get_wsgi_application() diff --git a/requirements.txt b/requirements.txt index 4c14c19..fe27b2b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,6 +4,7 @@ certifi==2018.4.16 chardet==3.0.4 coverage==4.5.1 coveralls==1.3.0 +dj-database-url==0.5.0 Django==2.0.6 django-cors-middleware==1.3.1 django-coverage==1.2.4 @@ -12,6 +13,7 @@ django-nose==1.4.5 djangorestframework==3.8.2 djangorestframework-jwt==1.11.0 docopt==0.6.2 +gunicorn==19.9.0 idna==2.7 isort==4.3.4 lazy-object-proxy==1.3.1