More Vagrant stuff.

master
Nick Sergeant 2014-10-30 12:31:48 -04:00
parent 5f595b066d
commit 27b08c76b8
4 changed files with 78 additions and 21 deletions

13
.gitignore vendored
View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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 %}