Closed ndarville closed 11 years ago
Maybe I should just adapt it to AWS/Cloud 66 considering the RapGenius imbroglio.
requirements.txt
# Heroku
dj-database-url
@@ -1,16 +1,20 @@
import os
+
+DOTCLOUD_ENVIRONMENT = False
+HEROKU_ENVIRONMENT = False
+LOCAL_DEVELOPMENT = False
+
if 'DOTCLOUD_ENVIRONMENT' in os.environ:
import json
with open('/home/dotcloud/environment.json') as f:
env = json.load(f)
- LOCAL_DEVELOPMENT = False
DOTCLOUD_ENVIRONMENT = True
+elif 'HEROKU_POSTGRESQL_ONYX_URL' in os.environ:
+ HEROKU_ENVIRONMENT = True
else:
LOCAL_DEVELOPMENT = True
- DOTCLOUD_ENVIRONMENT = False
-
PROJECT_PATH = os.path.realpath(os.path.dirname(__file__))
DEBUG = False
@@ -25,9 +29,9 @@
#
#MANAGERS = ADMINS
-if not LOCAL_DEVELOPMENT and DOTCLOUD_ENVIRONMENT:
+if DOTCLOUD_ENVIRONMENT:
# Do not alter these values under normal circumstances:
- DOTCLOUD_DB = {
+ DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'template1',
@@ -37,7 +41,10 @@
'PORT': int(env['DOTCLOUD_DB_SQL_PORT']),
}
}
- DATABASES = DOTCLOUD_DB
+
+elif HEROKU_ENVIRONMENT:
+ import dj_database_url
+ DATABASES['default'] = dj_database_url.config()
elif 'TRAVIS' in os.environ:
DATABASES = {
@@ -279,8 +286,9 @@
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
SECURE_CONTENT_TYPE_NOSNIFF = True
SECURE_BROWSER_XSS_FILTER = True
- # SECURE_SSL_REDIRECT = True
- # Disable for dotCloud: http://tinyurl.com/conn569
+ if 'DOTCLOUD_ENVIRONMENT':
+ # `True` causes infinite redirects: http://tinyurl.com/bjrk48z
+ SECURE_SSL_REDIRECT = False
SESSION_COOKIE_SECURE = True
SESSION_COOKIE_HTTPONLY = True
###
Going to retire this, until Pony Forum moves to something resembling production. I’m not very keen on supporting Heroku with what they’ve done right now.
Signs of postinstall hook: https://github.com/heroku/ruby-rails-sample/blob/b1e1000fedb6ca448dd78702de4fc78dedfee48c/app.json#L7-L9 for one-ish-click deployment.
An example of a more extensive Heroku Deploy script: https://github.com/swanson/stringer/blob/master/app.json.
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/ndarville/pony-forum)
app.json
{
"name": "Pony Forum",
//"description": "This app does one little thing, and does it well.",
"keywords": ["forum", "community"],
"website": "https://pony-forum.com",
"repository": "https://github.com/ndarville/pony-forum",
//"logo": "https://small-sharp-tool.com/logo.svg",
//"success_url": "/welcome",
"scripts": {
// "postdeploy": "bundle exec rake bootstrap"
// "postinstall": sh build_forum.sh && collectstatic
},
"env": {
"EMAIL_HOST": {
"description": "Your e-mail server (e.g. smtp.gmail.com, smtp.sendgrid.net)",
// "required": true
},
"EMAIL_HOST_USER": {
"description": "Your e-mail address (e.g. user@gmail.com)"
// "required": true
}
"EMAIL_HOST_PASSWORD": {
"description": "Your e-mail password"
// "required": true
}
"EMAIL_PORT": {
"description": "E-mail port number",
"value": "587"
// "required": true
}
"EMAIL_USE_TLS": {
"description": "use TLS by default",
"value": "True"
// "required": true
}
},
"addons": ["pgbackups", "expeditedssl", "sendgrid"] // "deployhooks"
}
Heroku Conversion
django-admin.py checksecure
and make them pass tests, unless they cause bugs like the aboverequirements.txt
.slugignore
- which only works for Heroku, apparently.