From a5bc4c451ba41c1dd894d614996fa54fe6aed504 Mon Sep 17 00:00:00 2001 From: Nick Sergeant Date: Mon, 20 Oct 2014 11:32:18 -0400 Subject: [PATCH] Working on Heroku integration. Conflicts: fabfile.py --- Dockerfile | 21 -------- accounts/views.py | 2 - fabfile.py | 83 ------------------------------- fig.yml | 32 ------------ gunicorn.conf.server.py | 12 ----- settings.py | 4 +- settings_local-template.py | 89 ---------------------------------- utils/templatetags/intercom.py | 1 - views.py | 2 - wsgi.py | 4 +- 10 files changed, 5 insertions(+), 245 deletions(-) delete mode 100644 Dockerfile delete mode 100644 fabfile.py delete mode 100644 fig.yml delete mode 100644 gunicorn.conf.server.py delete mode 100644 settings_local-template.py diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 6fc3eb5..0000000 --- a/Dockerfile +++ /dev/null @@ -1,21 +0,0 @@ -FROM debian:jessie -ENV DEBIAN_FRONTEND noninteractive -RUN apt-get update && apt-get install -y \ - build-essential \ - python \ - python-dev \ - python-setuptools \ - git-core \ - mercurial \ - libxml2-dev \ - libxslt-dev \ - libpq-dev -RUN easy_install pip -COPY . /app/snipt -RUN pip install -r /app/snipt/requirements.txt -RUN pip install --index-url https://code.stripe.com --upgrade stripe -ADD .docker/run.sh /docker-run -RUN mkdir -p /tmp/app -WORKDIR /app/snipt -EXPOSE 8000 -CMD ["/docker-run"] diff --git a/accounts/views.py b/accounts/views.py index ed4213d..57a1c97 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -4,8 +4,6 @@ from snipts.models import Snipt import stripe -from settings_local import STRIPE_SECRET_KEY - @login_required @render_to('account.html') diff --git a/fabfile.py b/fabfile.py deleted file mode 100644 index f9c1a20..0000000 --- a/fabfile.py +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env python -# -- coding: utf-8 -- - -from fabric.api import cd, local, env, run, sudo - -from boto.s3.connection import S3Connection -from boto.s3.key import Key - -import datetime, hashlib, sys - -from settings_local import AMAZON_API_KEY, AMAZON_API_SECRET, ENV_HOST - - -env.hosts = [ENV_HOST] -env.site_path = '/home/nick/snipt' - - -def dep(): - local('python manage.py collectstatic --ignore cache --noinput') - - try: - local('git push') - except: - pass - - with cd(env.site_path): - run('git pull') - run('/home/nick/snipt/.docker/control.sh collectstatic') - run('/home/nick/snipt/.docker/control.sh deploy') - -def db_backup(): - conn = S3Connection(AMAZON_API_KEY, AMAZON_API_SECRET) - snipt_bucket = conn.get_bucket('snipt') - k = Key(snipt_bucket) - k.key = filename - k.set_contents_from_filename('/tmp/snipt.pgdump') - local('rm {}'.format('/tmp/snipt.pgdump')) - -def db(): - with cd(env.site_path): - run('/home/nick/snipt/.docker/control.sh syncdb') - run('/home/nick/snipt/.docker/control.sh migrate') - -def gravatars(): - - from fabric.contrib import django - django.settings_module('settings') - - from django.contrib.auth.models import User - - import requests - - for user in User.objects.all().order_by('id'): - - email_md5 = hashlib.md5(user.email.lower()).hexdigest() - - print 'Email MD5: {}'.format(email_md5) - - greq = requests.get('https://secure.gravatar.com/avatar/{}?s=50&d=404'.format(email_md5)) - - if greq.status_code == 404: - has_gravatar = False - else: - has_gravatar = True - - profile = user.profile - profile.has_gravatar = has_gravatar - profile.save() - - try: - from fabric.colors import green, red - - if has_gravatar: - print 'Has Gravatar: {}'.format(green(has_gravatar)) - else: - print 'Has Gravatar: {}'.format(red(has_gravatar)) - - except ImportError: - print 'Has Gravatar: {}'.format(has_gravatar) - -def re(): - with cd(env.site_path): - run('/home/nick/snipt/.docker/control.sh restart') diff --git a/fig.yml b/fig.yml deleted file mode 100644 index 635c3f7..0000000 --- a/fig.yml +++ /dev/null @@ -1,32 +0,0 @@ -postgres: - image: postgres:9.1 - expose: - - "5432" - -elasticsearch: - image: arcus/elasticsearch - expose: - - "9200" - - "9300" -app: - build: . - links: - - postgres:db - - elasticsearch:es - ports: - - "8000:80" - expose: - - "8000" - environment: - - DB_NAME=postgres - - DB_USER=postgres - -proxy: - image: nginx - ports: - - "80" - volumes: - - .docker/nginx.conf:/etc/nginx.conf - - static:/app/snipt/static - net: "container:snipt_app_1" - diff --git a/gunicorn.conf.server.py b/gunicorn.conf.server.py deleted file mode 100644 index f48c9fb..0000000 --- a/gunicorn.conf.server.py +++ /dev/null @@ -1,12 +0,0 @@ -bind = "0.0.0.0:8000" -daemon = False # Whether work in the background -debug = False # Some extra logging -logfile = ".gunicorn.log" # Name of the log file -loglevel = "info" # The level at which to log -pidfile = ".gunicorn.pid" # Path to a PID file -workers = 9 # Number of workers to initialize -umask = 0 # Umask to set when daemonizing -user = None # Change process owner to user -group = None # Change process group to group -proc_name = "gunicorn-snipt" # Change the process name -tmp_upload_dir = None # Set path used to store temporary uploads diff --git a/settings.py b/settings.py index 76640cc..e3a6c0c 100644 --- a/settings.py +++ b/settings.py @@ -27,9 +27,9 @@ SECRET_KEY = 'changethis' SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') SESSION_COOKIE_AGE = 15801100 SITE_ID = 1 -STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'),) +STATICFILES_DIRS = (os.path.join(BASE_PATH, 'media'),) STATICFILES_FINDERS = ('django.contrib.staticfiles.finders.FileSystemFinder','django.contrib.staticfiles.finders.AppDirectoriesFinder',) -STATIC_ROOT = 'staticfiles' +STATIC_ROOT = os.path.join(BASE_PATH, 'static') STATIC_URL = '/static/' TASTYPIE_CANNED_ERROR = "There was an error with your request. The site developers have a record of this error, please email api@snipt.net and we'll help you out." TEMPLATE_DIRS = (os.path.join(PROJECT_PATH, 'templates')) diff --git a/settings_local-template.py b/settings_local-template.py deleted file mode 100644 index bab4930..0000000 --- a/settings_local-template.py +++ /dev/null @@ -1,89 +0,0 @@ -import os -from settings import INSTALLED_APPS, MIDDLEWARE_CLASSES - -DEBUG = True -if os.environ.get('DEBUG', '').lower() == 'false': - DEBUG = False - -TEMPLATE_DEBUG = DEBUG - -BASE_PATH = os.path.dirname(__file__) - -PROJECT_PATH = os.path.abspath(os.path.dirname(__file__)) - -ADMINS = ( - ('Name', 'name@domain.com'), -) - -MANAGERS = ADMINS - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.postgresql_psycopg2', - 'NAME': os.environ.get('DB_NAME', 'snipt'), - 'USER': os.environ.get('DB_USER', ''), - 'PASSWORD': os.environ.get('DB_PASS', ''), - 'HOST': os.environ.get('DB_PORT_5432_TCP_ADDR', 'localhost'), - 'PORT': os.environ.get('DB_PORT_5432_TCP_PORT', ''), - } -} - - -TIME_ZONE = 'America/New_York' - -LANGUAGE_CODE = 'en-us' - -MEDIA_ROOT = os.path.join(BASE_PATH, 'media/uploads') - -MEDIA_URL = '/media/uploads/' - -STATIC_URL = '/static/' - -SECRET_KEY = '' - -DEFAULT_FROM_EMAIL = 'support@snipt.net' -SERVER_EMAIL = 'support@snipt.net' -EMAIL_BACKEND = 'postmark.django_backend.EmailBackend' -POSTMARK_API_KEY = '' - -VIRTUALENV_PATH = '' - -AMAZON_API_KEY = '' -AMAZON_API_SECRET = '' - -STRIPE_SECRET_KEY = '' - -ENV_HOST = 'user@domain.com:22' - -USE_HTTPS = False -SESSION_COOKIE_SECURE = False -CSRF_COOKIE_SECURE = False -SESSION_COOKIE_DOMAIN = '.snipt.net' -ALLOWED_HOSTS = ['*'] - -ES_HOST = os.environ.get('ES_PORT_9200_TCP_ADDR', '127.0.0.1') -ES_PORT = os.environ.get('ES_PORT_9200_TCP_PORT', '9200') - -HAYSTACK_CONNECTIONS = { - 'default': { - 'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine', - 'URL': 'http://{}:{}/'.format(ES_HOST, ES_PORT), - 'INDEX_NAME': 'haystack', - }, -} - -INSTALLED_APPS += ( - 'debug_toolbar', - 'django_extensions', - 'raven.contrib.django.raven_compat', -) - -RAVEN_CONFIG = { - 'dsn': '', -} - -MIDDLEWARE_CLASSES = MIDDLEWARE_CLASSES + ( - 'raven.contrib.django.raven_compat.middleware.Sentry404CatchMiddleware', -) - -INTERCOM_SECRET_KEY = '' diff --git a/utils/templatetags/intercom.py b/utils/templatetags/intercom.py index d1a52cc..ced4efa 100644 --- a/utils/templatetags/intercom.py +++ b/utils/templatetags/intercom.py @@ -1,5 +1,4 @@ from django import template -from settings_local import INTERCOM_SECRET_KEY import hmac, hashlib diff --git a/views.py b/views.py index be6b355..e8c78b6 100644 --- a/views.py +++ b/views.py @@ -16,8 +16,6 @@ import datetime import hashlib import stripe -from settings_local import STRIPE_SECRET_KEY - @ajax_request def user_api_key(request): diff --git a/wsgi.py b/wsgi.py index ba081cc..fd45078 100644 --- a/wsgi.py +++ b/wsgi.py @@ -11,4 +11,6 @@ import os os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") from django.core.wsgi import get_wsgi_application -application = get_wsgi_application() +from dj_static import Cling + +application = Cling(get_wsgi_application())