Skip to content
Snippets Groups Projects
Commit 91bf8656 authored by nimrod's avatar nimrod
Browse files

Fiddling around with Honcho, Fabric and gunicorn.

parent 1a69b3a9
No related branches found
No related tags found
No related merge requests found
SECRET_KEY='7t^^#zw41ol8v*to-ti*jx7)iq@-=l9jquq1!5f!e02o!j2xyu'
DEBUG="True"
ALLOWED_HOSTS="*"
DB_NAME="realestate"
DB_USER="realestate"
DB_PASSWORD="password"
DB_HOST="localhost"
APP_HOST="localhost"
#SECURE_COOKIES="False"
......@@ -4,3 +4,4 @@
~*
*.pyc
.vagrant
.env
app: gunicorn
django-realestate
*****************
A Django application for managing real estate listings.
A Django application for managing real estate listings. This is also an
excersice in building a 12-factor application.
Requirements
------------
- Python3
Usage
-----
TODO
----
- Provisioning (Fabric for DB hosts, App hosts, maybe Cache hosts, using
environment variables, SystemD service for App with setting under
/etc/default).
- Investigate default enviroment in Honcho.
File moved
......@@ -20,12 +20,18 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '7t^^#zw41ol8v*to-ti*jx7)iq@-=l9jquq1!5f!e02o!j2xyu'
SECRET_KEY = os.environ['SECRET_KEY']
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
try:
DEBUG = bool(os.environ['DEBUG'])
except KeyError:
pass
ALLOWED_HOSTS = []
try:
ALLOWED_HOSTS = os.environ['ALLOWED_HOSTS'].split(' ')
except KeyError:
pass
# Application definition
......@@ -76,8 +82,11 @@ WSGI_APPLICATION = 'Realestate.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.environ['DB_NAME'],
'USER': os.environ['DB_USER'],
'PASSWORD': os.environ['DB_PASSWORD'],
'HOST': os.environ['DB_HOST']
}
}
......@@ -100,3 +109,9 @@ USE_TZ = True
# https://docs.djangoproject.com/en/1.8/howto/static-files/
STATIC_URL = '/static/'
try:
SESSION_COOKIE_SECURE = bool(os.environ['SECURE_COOKIES'])
CSRF_COOKIE_SECURE = bool(os.environ['SECURE_COOKIES'])
except KeyError:
pass
File moved
File moved
......@@ -3,15 +3,9 @@
Vagrant.configure(2) do |config|
config.vm.box = "debian/jessie64"
if Vagrant.has_plugin?("landrush")
config.landrush.enabled = true
config.landrush.tld = "vagrant"
end
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.synced_folder "./", "/opt/realestate"
config.vm.provision "shell", inline: <<-SHELL
sudo apt-get update
sudo apt-get install -yf python3-pip python3-dev postgresql postgresql-client python3-psycopg2
sudo pip3 install -r /opt/realestate/requirements.txt
sudo apt-get install -yf postgresql redis-server
SHELL
end
#!/usr/bin/env python3
from fabric.api import env, task, hosts
import os
env.use_ssh_config = True
@task
@hosts(os.environ['APP_HOST'])
def deploy():
raise NotImplemented
File moved
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment