Permalink
Browse files

Add support for stackato deployment.

  • Loading branch information...
Osmose committed Dec 18, 2013
1 parent b790a32 commit c4f5831e410ba85927cf8455192d5cf2f04f9286
Showing with 165 additions and 6 deletions.
  1. +1 −0 .gitignore
  2. +9 −5 oneanddone/settings/__init__.py
  3. +1 −0 oneanddone/settings/base.py
  4. +93 −0 oneanddone/settings/stackato.py
  5. +50 −0 stackato.yml
  6. +11 −1 wsgi/playdoh.wsgi
View
@@ -17,3 +17,4 @@ build
tmp/*
*~
*.mo
+static
@@ -1,6 +1,10 @@
from .base import *
-try:
- from .local import *
-except ImportError, exc:
- exc.args = tuple(['%s (did you rename settings/local.py-dist?)' % exc.args[0]])
- raise exc
+
+if 'STACKATO_APP_NAME' in os.environ:
+ from .stackato import *
+else:
+ try:
+ from .local import *
+ except ImportError, exc:
+ exc.args = tuple(['%s (did you rename settings/local.py-dist?)' % exc.args[0]])
+ raise exc
@@ -124,6 +124,7 @@
# Do not preprocess LESS files.
LESS_PREPROCESS = False
+LESS_BIN = 'lessc'
# Testing configuration.
NOSE_ARGS = ['--logging-clear-handlers', '--logging-filter=-factory,-south']
@@ -0,0 +1,93 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+import os
+
+import dj_database_url
+
+from . import base
+
+
+# Database
+##############################################################################
+
+DATABASES = {
+ 'default': dj_database_url.config()
+}
+
+# Uncomment this and set to all slave DBs in use on the site.
+# SLAVE_DATABASES = ['slave']
+
+
+# Environment-specific Settings
+##############################################################################
+
+# Debugging displays nice error messages, but leaks memory. Set this to False
+# on all server instances and True only for development.
+DEBUG = os.environ.get('DJANGO_DEBUG', False)
+TEMPLATE_DEBUG = os.environ.get('DJANGO_TEMPLATE_DEBUG', False)
+
+# Is this a development instance? Set this to True on development/master
+# instances and False on stage/prod.
+DEV = os.environ.get('DJANGO_DEV', False)
+
+# Should robots.txt allow web crawlers? Set this to True for production
+ENGAGE_ROBOTS = True
+
+# Uncomment this line if you are running a local development install without
+# HTTPS to disable HTTPS-only cookies.
+SESSION_COOKIE_SECURE = False
+
+# django-browserid requires you to specify audiences that are valid for your
+# site. An audience is a protocol + hosename + port that users will use to
+# access your site.
+#
+# In development, this is typically 'http://localhost:8000' or similar. In
+# production, this is typically the protocol and domain for the site.
+BROWSERID_AUDIENCES = [os.environ.get('BROWSERID_AUDIENCE', 'https://oneanddone.paas.allizom.org')]
+
+TIME_ZONE = 'America/New_York'
+
+# Path to Less binary.
+LESS_BIN = os.environ.get('LESSC_BIN', 'lessc')
+
+# Stackato's proxy hides the fact that we're using SSL, so we need to
+# tell Django how to determine if a request is using SSL.
+SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
+
+
+# Error Reporting
+##############################################################################
+
+# Recipients of traceback emails and other notifications.
+ADMINS = (
+ ('One and Done Admin', os.environ.get('DJANGO_ADMIN_EMAIL', '')),
+)
+MANAGERS = ADMINS
+
+
+# Security
+##############################################################################
+
+# Playdoh ships with Bcrypt+HMAC by default because it's the most secure.
+# To use bcrypt, fill in a secret HMAC key. It cannot be blank.
+HMAC_KEYS = {
+ '2013-11-07': os.environ.get('DJANGO_HMAC_KEY', ''),
+}
+
+from django_sha2 import get_password_hashers
+PASSWORD_HASHERS = get_password_hashers(base.BASE_PASSWORD_HASHERS, HMAC_KEYS)
+
+# Make this unique, and don't share it with anybody. It cannot be blank.
+SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY', 'ssssshhhhhh')
+
+
+# Logging
+##############################################################################
+
+# SYSLOG_TAG = "oneanddone_app"
+# LOGGING = dict(loggers=dict(playdoh={'level': logging.DEBUG}))
+
+# Common Event Format logging parameters
+#CEF_PRODUCT = 'Playdoh'
+#CEF_VENDOR = 'Mozilla'
View
@@ -0,0 +1,50 @@
+name: oneanddone
+framework:
+ type: python
+ start-file: wsgi/playdoh.wsgi
+env:
+ DJANGO_SETTINGS_MODULE: oneanddone.settings
+ DJANGO_SECRET_KEY: ${random-word}
+ DJANGO_HMAC_KEY: ${random-word}
+ DJANGO_SERVE_STATIC: true
+ DJANGO_DEBUG: ''
+ DJANGO_TEMPLATE_DEBUG: ''
+ DJANGO_DEV: true
+ BROWSERID_AUDIENCE: 'https://oneanddone.paas.allizom.org'
+ DJANGO_ADMIN_EMAIL: ''
+ LESSC_BIN: '$HOME/node_modules/less/bin/lessc'
+ NEW_RELIC_LOG: stderr
+ NEW_RELIC_APP_NAME: oneanddone.paas.allizom.org
+requirements:
+ pypm:
+ - MySQL-python==1.2.3
+ - jinja2==2.5.5
+ - py-bcrypt==0.3
+min_version:
+ client: 1.4.5
+services:
+ ${name}-db: mysql
+ ${name}-memcache: memcached
+ media: filesystem
+hooks:
+ post-staging:
+ - python manage.py syncdb --noinput
+ - python manage.py migrate --noinput
+ # Currently these have to be run locally prior to pushing. :(
+ #- npm install less
+ #- python manage.py collectstatic --noinput
+ #- python manage.py compress_assets
+processes:
+ web: $STACKATO_UWSGI --static-map /static=$HOME/static
+ignores:
+ - ".git"
+ - "*.pyc"
+ - "*.pyo"
+ - "*.swp"
+ - "*.un~"
+ - "*.orig"
+ - "*.sublime*"
+ - ".coverage*"
+ - "_coverage/*"
+ - ".noseids"
+ - "*settings/local.py"
View
@@ -1,6 +1,15 @@
import os
import site
+try:
+ import newrelic.agent
+except ImportError:
+ newrelic = False
+
+
+if newrelic:
+ newrelic.agent.initialize()
+
os.environ.setdefault('CELERY_LOADER', 'django')
# NOTE: you can also set DJANGO_SETTINGS_MODULE in your environment to override
# the default value in manage.py
@@ -15,4 +24,5 @@ import manage
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
-# vim: ft=python
+if newrelic:
+ application = newrelic.agent.wsgi_application()(application)

0 comments on commit c4f5831

Please sign in to comment.