diff --git a/.gitignore b/.gitignore index 5af68fe..8cdc439 100644 --- a/.gitignore +++ b/.gitignore @@ -1,16 +1,17 @@ -venv .gunicorn.pid -.vagrant -*.log .sass-cache +.vagrant +.venv + +*.log *.un~ *.pgdump *.pyc settings_local.py -media/cache -tags +settings_local_server.py +media/cache media/css/pro.css media/css/snipt.css media/js/src/account.min.js @@ -23,9 +24,9 @@ media/js/src/modules/snipt.min.js media/js/src/pro.min.js media/js/snipt-all.min.js media/js/pro-all.min.js - static/admin static/css static/fonts static/img static/js +tags diff --git a/Makefile b/Makefile index 3f4e440..a31a395 100644 --- a/Makefile +++ b/Makefile @@ -75,6 +75,19 @@ deploy: deploy-heroku: @git push heroku +server-settings: + @scp -q -P 2222 -i ~/.vagrant.d/insecure_private_key -r settings_local_server.py vagrant@localhost:settings_local.py + +salt-server: + @scp -q -P 2222 -i ~/.vagrant.d/insecure_private_key -r ./salt/ vagrant@localhost:salt + @scp -q -P 2222 -i ~/.vagrant.d/insecure_private_key -r ./pillar/ vagrant@localhost:pillar + @scp -q -P 2222 -i ~/.vagrant.d/insecure_private_key -r settings_local_server.py vagrant@localhost:settings_local.py + @ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo rm -rf /srv' + @ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo mkdir /srv' + @ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo mv ~/salt /srv/salt' + @ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo mv ~/pillar /srv/pillar' + @ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo salt-call --local state.highstate' + salt-vagrant: @scp -q -P 2222 -i ~/.vagrant.d/insecure_private_key -r ./salt/ vagrant@localhost:salt @scp -q -P 2222 -i ~/.vagrant.d/insecure_private_key -r ./pillar/ vagrant@localhost:pillar @@ -84,6 +97,25 @@ salt-vagrant: @ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo mv ~/pillar /srv/pillar' @ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo salt-call --local state.highstate' +server: + @ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo apt-get update' + @ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo apt-get install -y software-properties-common python-software-properties' + @ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo add-apt-repository -y ppa:saltstack/salt' + @ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo apt-get update' + @ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo apt-get install -y salt-minion' + @scp -q -P 2222 -i ~/.vagrant.d/insecure_private_key -r ./salt/ vagrant@localhost:salt + @scp -q -P 2222 -i ~/.vagrant.d/insecure_private_key -r ./pillar/ vagrant@localhost:pillar + @ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo rm -rf /srv' + @ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo mkdir /srv' + @ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo mv ~/salt /srv/salt' + @ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo mv ~/pillar /srv/pillar' + @ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo salt-call --local state.highstate' + @scp -q -P 2222 -i ~/.vagrant.d/insecure_private_key -r settings_local_server.py vagrant@localhost:/var/www/snipt/settings_local.py + @ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'cd /var/www/snipt; make db' + @ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'cd /var/www/snipt; /var/www/.virtualenvs/snipt/bin/python manage.py syncdb' + @ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'cd /var/www/snipt; /var/www/.virtualenvs/snipt/bin/python manage.py migrate' + @ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'cd /var/www/snipt; /var/www/.virtualenvs/snipt/bin/python manage.py backfill_api_keys' + vagrant: @vagrant up --provider=vmware_fusion @ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo apt-get update' @@ -107,5 +139,8 @@ vagrant: db, \ deploy, \ deploy-heroku, \ + salt-server, \ salt-vagrant, \ + server-settings, \ + server, \ vagrant diff --git a/README.md b/README.md index b4012f3..b321799 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,13 @@ Install [Vagrant](https://www.vagrantup.com/) and either [VirtualBox](https://ww 4. `make vagrant` 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` + # Deploying to Heroku 1. Clone the repo. diff --git a/salt/application/snipt.nginx.conf b/salt/application/snipt.nginx.conf index 018c65a..236e4a1 100644 --- a/salt/application/snipt.nginx.conf +++ b/salt/application/snipt.nginx.conf @@ -60,25 +60,39 @@ upstream backend_snipt { rewrite ^/public/feed/$ https://{{ pillar.hostname }}/public/?rss permanent; } } -{% endif %} -server { - listen 80 default_server; + server { + listen 80 default_server; - location ~* /favicon.ico { - root /var/www/snipt/static/img/; - expires max; - } + location / { + proxy_pass http://backend_snipt; + proxy_set_header Host $host; + } - location / { - proxy_pass http://backend_snipt; - proxy_set_header Host $host; - } - - {% if pillar.env_name != 'vagrant' %} location /static/ { alias /var/www/snipt/static/; expires max; } - {% endif %} + location ~* /favicon.ico { + root /var/www/snipt/static/img/; + expires max; + } + } +{% else %} + server { + listen 80 default_server; -} + location / { + proxy_pass http://backend_snipt; + proxy_set_header Host $host; + } + + location /static/ { + alias /var/www/snipt/media/; + expires max; + } + location ~* /favicon.ico { + root /var/www/snipt/media/img/; + expires max; + } + } +{% endif %}