parent
fe425f437d
commit
a5bc4c451b
21
Dockerfile
21
Dockerfile
|
@ -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"]
|
|
@ -4,8 +4,6 @@ from snipts.models import Snipt
|
|||
|
||||
import stripe
|
||||
|
||||
from settings_local import STRIPE_SECRET_KEY
|
||||
|
||||
|
||||
@login_required
|
||||
@render_to('account.html')
|
||||
|
|
|
@ -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')
|
32
fig.yml
32
fig.yml
|
@ -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"
|
||||
|
|
@ -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
|
|
@ -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'))
|
||||
|
|
|
@ -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 = ''
|
|
@ -1,5 +1,4 @@
|
|||
from django import template
|
||||
from settings_local import INTERCOM_SECRET_KEY
|
||||
|
||||
import hmac, hashlib
|
||||
|
||||
|
|
2
views.py
2
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):
|
||||
|
||||
|
|
Loading…
Reference in New Issue