diff --git a/config/production/deploy.py b/config/production/deploy.py index 78b748e..c8a6e36 100644 --- a/config/production/deploy.py +++ b/config/production/deploy.py @@ -31,6 +31,10 @@ CONFIG_FILES = [ '%s/config/production/local_settings.py' % GIT_DOWNLOAD_DIR, '%s/herobrine/local_settings.py' % APP_DIRECTORY ), + ( + '%s/config/production/nginx.conf' % GIT_DOWNLOAD_DIR, + './conf/nginx.conf' + ), ] FIXTURES = [ @@ -213,6 +217,13 @@ else: check_status(status) +sub('Storing current version:') +status = call('cd %s && git describe' % GIT_DOWNLOAD_DIR, + stdout=open('./conf/app_version', 'wb'), + stderr=open(os.devnull, 'wb'), + shell=True) +check_status(status) + # =========== CHECK SCRIPT UPDATE ================== title('Checking if deploy script is updated on repository') actual_size = os.stat('./deploy.py').st_size @@ -382,7 +393,7 @@ if PREPROCESSORS['less']['items']: check_status(status, words=[os.path.basename(path_to), 'failed']) title('Collecting all staticfiles') -sub('manage.py collectstatic') +sub('manage.py ollectstatic:') status = call( 'source %s/bin/activate && python %s/manage.py collectstatic --noinput' % ( VIRTUALENV_PATH, @@ -392,8 +403,8 @@ status = call( shell=True, executable='/bin/bash' ) check_status(status) -# ================ SERVER ======================= +# ================ SERVER ======================= print("") success('Finished!') diff --git a/config/production/install.sh b/config/production/install.sh index 6bd789c..a6e2e48 100644 --- a/config/production/install.sh +++ b/config/production/install.sh @@ -34,9 +34,16 @@ npm install -g coffee-script npm install -g uglify-js npm install -g less -echo "=> Creating user app and its home folder" +echo "=> Creating user APP with its requirements" # Create site user useradd app mkdir /home/app chown app:app /home/app -echo "[REMEMBER!] create ssh keypair for the server." +su - app -c "mkdir conf" +su - app -c "touch ./conf/app_version" +su - app -c "touch .environment" +su - app -c "echo 'source .environment' > .bash_profile" + +# Reminders +echo "[REMEMBER!]" +echo " - Create ssh keypair for the server." diff --git a/config/production/local_settings.py b/config/production/local_settings.py index c44914c..c988830 100644 --- a/config/production/local_settings.py +++ b/config/production/local_settings.py @@ -30,3 +30,13 @@ STATIC_URL = '/static/' # Mediafiles MEDIA_ROOT = 'media' MEDIA_URL = '/media/' + +# Sentry +RAVEN_CONFIG = { + 'dsn': 'http://809b0824b821462db7902f96cf5ad2c9:bf82b9625be84d9fb2f2a15af1009176@sentry.fmartingr.com/4', +} + +INSTALLED_APPS = INSTALLED_APPS + ( + 'raven.contrib.django.raven_compat', + 'gunicorn' +) diff --git a/config/production/nginx.conf b/config/production/nginx.conf index 8bf93a8..51dafdd 100644 --- a/config/production/nginx.conf +++ b/config/production/nginx.conf @@ -14,5 +14,8 @@ server { # pass requests for dynamic content to rails/turbogears/zope, et al location / { proxy_pass http://127.0.0.1:8000; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } diff --git a/config/production/requirements.pip b/config/production/requirements.pip index 010fad6..9719247 100644 --- a/config/production/requirements.pip +++ b/config/production/requirements.pip @@ -1,2 +1,4 @@ psycopg2==2.5 +raven==3.3.7 +gunicorn==0.17.4 -r ../requirements.pip