From 909c3914515682d5c3295db3e078fb17da5fd7ba Mon Sep 17 00:00:00 2001 From: Christopher Charbonneau Wells Date: Mon, 23 Oct 2017 04:49:10 -0400 Subject: [PATCH] Add Heroku config files. --- Pipfile | 4 +++- Pipfile.lock | 26 +++++++++++------------ README.md | 2 +- app.json | 40 ++++++++++++++++++++++++++++++++++++ babybuddy/settings/heorku.py | 39 +++++++++++++++++++++++++++++++++++ package.json | 3 ++- 6 files changed, 98 insertions(+), 16 deletions(-) create mode 100644 app.json create mode 100644 babybuddy/settings/heorku.py diff --git a/Pipfile b/Pipfile index 189f4b8a..d7bbe9e8 100644 --- a/Pipfile +++ b/Pipfile @@ -9,9 +9,11 @@ django-filter = "*" django-widget-tweaks = "*" plotly = "*" pandas = "*" +faker = "*" +dj-database-url = "*" +gunicorn = "*" [dev-packages] coveralls = "*" -faker = "*" flake8 = "*" ipaddress = "*" diff --git a/Pipfile.lock b/Pipfile.lock index 3aa9275a..4e88d4cf 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "6320081dc17e4c796cda43fc5a5bef12a154917fc572a75a5444e78454385e12" + "sha256": "52db700b9c061baeb935565e2910f5205547ba93306d53f12634b7a0a4c3cb02" }, "requires": {}, "sources": [ @@ -21,6 +21,9 @@ "decorator": { "version": "==4.1.2" }, + "dj-database-url": { + "version": "==0.4.2" + }, "django": { "version": "==1.11.6" }, @@ -33,6 +36,12 @@ "djangorestframework": { "version": "==3.7.1" }, + "faker": { + "version": "==0.8.6" + }, + "gunicorn": { + "version": "==19.7.1" + }, "idna": { "version": "==2.6" }, @@ -69,6 +78,9 @@ "six": { "version": "==1.11.0" }, + "text-unidecode": { + "version": "==1.0" + }, "traitlets": { "version": "==4.3.2" }, @@ -92,9 +104,6 @@ "docopt": { "version": "==0.6.2" }, - "faker": { - "version": "==0.8.6" - }, "flake8": { "version": "==3.4.1" }, @@ -113,18 +122,9 @@ "pyflakes": { "version": "==1.5.0" }, - "python-dateutil": { - "version": "==2.6.1" - }, "requests": { "version": "==2.18.4" }, - "six": { - "version": "==1.11.0" - }, - "text-unidecode": { - "version": "==1.0" - }, "urllib3": { "version": "==1.22" } diff --git a/README.md b/README.md index b452f56f..04eeefa5 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![License](https://img.shields.io/badge/License-BSD%202--Clause-orange.svg)](https://opensource.org/licenses/BSD-2-Clause) A buddy for babies! Helps caregivers track sleep, feedings, diaper changes, and -tummy time to learn about and predict baby's needs without all the guess work. +tummy time to learn about and predict baby's needs without (as much) guess work. ## Development diff --git a/app.json b/app.json new file mode 100644 index 00000000..1f35e9c9 --- /dev/null +++ b/app.json @@ -0,0 +1,40 @@ +{ + "name": "Baby Buddy", + "author": "Baby Buddy's Contributors", + "description": "A buddy for babies! Helps caregivers track sleep, feedings, diaper changes, and tummy time to learn about and predict baby's needs without (as much) guess work.", + "repository": "https://github.com/cdubz/babybuddy", + "keywords": [ + "baby", + "infant", + "newborn", + "baby tracking", + "baby buddy", + "python", + "django", + "web", + "self-host" + ], + "version": "0.1.0", + "license": "BSD-2-Clause", + "buildpacks": [ + { + "url": "heroku/nodejs" + }, + { + "url": "heroku/python" + } + ], + "env": { + "DJANGO_SETTINGS_MODULE": { + "description": "We have a prebuilt config for Heroku", + "value": "babybuddy.settings.heroku" + }, + "SECRET_KEY": { + "description": "Used for the Django auth system", + "generator": "secret" + } + }, + "scripts": { + "postdeploy": "python manage.py migrate" + } +} diff --git a/babybuddy/settings/heorku.py b/babybuddy/settings/heorku.py new file mode 100644 index 00000000..60b7d198 --- /dev/null +++ b/babybuddy/settings/heorku.py @@ -0,0 +1,39 @@ +import os + +import dj_database_url + +from .base import * # noqa: F401,F403 + + +DEBUG = False + + +# SECURITY WARNING: keep the secret key used in production secret! + +SECRET_KEY = os.environ['SECRET_KEY'] + + +# Database +# https://docs.djangoproject.com/en/1.11/ref/settings/#databases + +DATABASES = { + 'default': dj_database_url.config(conn_max_age=500) +} + + +# Email + +SENDGRID_USERNAME = os.environ.get('SENDGRID_USERNAME', None) # noqa: F405 +SENDGRID_PASSWORD = os.environ.get('SENDGRID_PASSWORD', None) # noqa: F405 + +# Use SendGrid if we have the addon installed, else just print to console which +# is accessible via Heroku logs +if SENDGRID_USERNAME and SENDGRID_PASSWORD: + EMAIL_HOST = 'smtp.sendgrid.net' + EMAIL_HOST_USER = SENDGRID_USERNAME + EMAIL_HOST_PASSWORD = SENDGRID_PASSWORD + EMAIL_PORT = 587 + EMAIL_USE_TLS = True + EMAIL_TIMEOUT = 60 +else: + EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' diff --git a/package.json b/package.json index 7cb0e087..c88d4b94 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,8 @@ "baby buddy", "python", "django", - "web" + "web", + "self-host" ], "dependencies": { "bootstrap": "^4.0.0-beta.2",