From aaac6e2eb0ee15ba6be7d8dbe21ca9ee3b7ea0fc Mon Sep 17 00:00:00 2001 From: Nick Sergeant Date: Thu, 30 Oct 2014 22:45:33 -0400 Subject: [PATCH] Oy. --- Makefile | 16 +++++++++------- README.md | 5 ++++- requirements.txt | 1 - salt/application/init.sls | 6 +++--- salt/nginx/init.sls | 14 +++++++++----- salt/nginx/nginx.conf | 2 +- settings.py | 1 - settings_local.py-template | 1 - 8 files changed, 26 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index 0afd10f..1ae6c0a 100644 --- a/Makefile +++ b/Makefile @@ -81,6 +81,7 @@ deploy-heroku: @git push heroku salt-server: + @scp -q -P 55555 settings_local_server.py deploy@69.164.221.98:/var/www/snipt/settings_local.py @scp -q -P 55555 -r ./salt/ deploy@69.164.221.98:salt @scp -q -P 55555 -r ./pillar/ deploy@69.164.221.98:pillar @$(ssh-server-deploy) 'sudo rm -rf /srv' @@ -112,12 +113,13 @@ server: @$(ssh-server-root) 'sudo mv ~/salt /srv/salt' @$(ssh-server-root) 'sudo mv ~/pillar /srv/pillar' @$(ssh-server-root) 'sudo salt-call --local state.highstate' - @scp -q -P 55555 settings_local_server.py deploy@69.164.221.98:/var/www/snipt/settings_local.py + +server-init: @$(ssh-server-deploy) 'cd /var/www/snipt; make db;' - @$(ssh-server-deploy) '$(pm) syncdb;' + @$(ssh-server-deploy) '$(pm) syncdb --noinput;' @$(ssh-server-deploy) '$(pm) migrate;' - @$(ssh-server-deploy) '$(pm) backfill_api_keys' - @$(ssh-server-deploy) '$(pm) rebuild_index --noinput' + @$(ssh-server-deploy) '$(pm) backfill_api_keys;' + @$(ssh-server-deploy) '$(pm) rebuild_index --noinput;' vagrant: @vagrant up --provider=vmware_fusion @@ -137,8 +139,8 @@ vagrant: @vagrant ssh -c 'cd /var/www/snipt; make db;' @vagrant ssh -c '$(pm) syncdb;' @$(ssh-vagrant) '$(pm) migrate;' - @$(ssh-vagrant) '$(pm) backfill_api_keys' - @$(ssh-vagrant) '$(pm) rebuild_index --noinput' + @$(ssh-vagrant) '$(pm) backfill_api_keys;' + @$(ssh-vagrant) '$(pm) rebuild_index --noinput;' .PHONY: assets, \ db, \ @@ -148,6 +150,6 @@ vagrant: provision-vagrant, \ salt-server, \ salt-vagrant, \ - server-settings, \ + server-init, \ server, \ vagrant diff --git a/README.md b/README.md index 0699187..8dd036b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This is the codebase for the website, [Snipt.net](https://snipt.net/). -# Running the Django app +# Running the Django app locally with Vagrant Install [Vagrant](https://www.vagrantup.com/) and either [VirtualBox](https://www.virtualbox.org/) or [VMWare Fusion](http://www.vmware.com/products/fusion). @@ -14,11 +14,14 @@ Install [Vagrant](https://www.vagrantup.com/) and either [VirtualBox](https://ww 5. Visit [http://local.snipt.net:8080/](http://local.snipt.net:8080/). # Deploying to a VM + 1. Clone the repo. 2. `cp settings_local.py-template settings_local_server.py` 3. Edit local server settings (choose a database password - you'll be prompted for it). 4. Manually change the VM IP address in the Makefile. 5. `make server` +6. SSH into the server, `sudo su - deploy`, `ssh-keygen`, and add the public key to your repo as a deploy key. +7. `make server-init` # Deploying to Heroku diff --git a/requirements.txt b/requirements.txt index 815dcc6..ef6ea51 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,7 +9,6 @@ django-debug-toolbar==0.11.0 django-extensions==1.2.5 django-markdown-deux==1.0.4 django-pagination==1.0.7 -django-sslify>=0.2 django-storages==1.1.5 django-taggit==0.10 django-tastypie==0.10.0 diff --git a/salt/application/init.sls b/salt/application/init.sls index 897706a..52bc00f 100644 --- a/salt/application/init.sls +++ b/salt/application/init.sls @@ -68,7 +68,7 @@ snipt-site: - group: deploy - mode: 755 - require: - - pkg: nginx + - pkg: nginx-extras - group: deploy enable-snipt-site: @@ -77,8 +77,8 @@ enable-snipt-site: - target: /etc/nginx/sites-available/snipt - force: false - require: - - pkg: nginx + - pkg: nginx-extras cmd.run: - name: service nginx restart - require: - - pkg: nginx + - pkg: nginx-extras diff --git a/salt/nginx/init.sls b/salt/nginx/init.sls index 0c8e637..9a19a54 100644 --- a/salt/nginx/init.sls +++ b/salt/nginx/init.sls @@ -1,9 +1,13 @@ -nginx: +nginx-extras: pkg: - installed + +nginx: service: - running - enable: True + - require: + - pkg: nginx-extras - watch: - file: /etc/nginx/nginx.conf - file: /etc/nginx/sites-enabled/* @@ -12,13 +16,13 @@ nginx: file.directory: - mode: 755 - require: - - pkg: nginx + - pkg: nginx-extras /etc/nginx/sites-enabled: file.directory: - mode: 755 - require: - - pkg: nginx + - pkg: nginx-extras {% if pillar.env_name != 'vagrant' %} @@ -26,7 +30,7 @@ nginx: file.directory: - mode: 644 - require: - - pkg: nginx + - pkg: nginx-extras {% endif %} @@ -36,7 +40,7 @@ nginx: - mode: 400 - template: jinja - require: - - pkg: nginx + - pkg: nginx-extras /etc/nginx/sites-enabled/default: file.absent diff --git a/salt/nginx/nginx.conf b/salt/nginx/nginx.conf index 238d30c..ab64ae1 100644 --- a/salt/nginx/nginx.conf +++ b/salt/nginx/nginx.conf @@ -17,7 +17,7 @@ http { gzip on; gzip_disable "msie6"; - gzip_types text/html text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript; + gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript; include /etc/nginx/sites-enabled/*; diff --git a/settings.py b/settings.py index 3a4174f..75cd1f1 100644 --- a/settings.py +++ b/settings.py @@ -109,7 +109,6 @@ LOGGING = { 'loggers': {} } MIDDLEWARE_CLASSES = ( - 'sslify.middleware.SSLifyMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', diff --git a/settings_local.py-template b/settings_local.py-template index a80fa1c..2a5de6b 100644 --- a/settings_local.py-template +++ b/settings_local.py-template @@ -5,7 +5,6 @@ POSTMARK_API_KEY = '' RAVEN_CONFIG = { 'dsn': '' } SECRET_KEY = 'changeme' SESSION_COOKIE_SECURE = False -SSLIFY_DISABLE = True STRIPE_SECRET_KEY = '' USE_HTTPS = False