More Vagrant stuff.
förälder
21e154f499
incheckning
c6443c9ae9
28
Makefile
28
Makefile
|
@ -1,7 +1,4 @@
|
|||
deploy:
|
||||
@git push heroku
|
||||
|
||||
deploy-with-assets:
|
||||
assets:
|
||||
@cat media/css/bootstrap.min.css \
|
||||
media/css/blog-themes/pro-adams/style.css \
|
||||
media/css/highlightjs-themes/tomorrow.css \
|
||||
|
@ -63,6 +60,19 @@ deploy-with-assets:
|
|||
media/js/src/pro.js \
|
||||
> media/js/pro-all.min.js
|
||||
/Users/Nick/.virtualenvs/snipt/bin/python manage.py collectstatic --noinput
|
||||
|
||||
db:
|
||||
@echo Creating database user snipt:
|
||||
@sudo -H -u postgres bash -c 'createuser snipt -P'
|
||||
@sudo -H -u postgres bash -c 'createdb snipt -O snipt'
|
||||
|
||||
deploy:
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'cd /var/www/snipt; git pull;'
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'cd /var/www/snipt; make assets;'
|
||||
@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 'sudo supervisorctl restart snipt'
|
||||
|
||||
deploy-heroku:
|
||||
@git push heroku
|
||||
|
||||
salt-vagrant:
|
||||
|
@ -88,8 +98,14 @@ vagrant:
|
|||
@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'
|
||||
@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'
|
||||
|
||||
.PHONY: deploy, \
|
||||
deploy-with-assets, \
|
||||
.PHONY: assets, \
|
||||
db, \
|
||||
deploy, \
|
||||
deploy-heroku, \
|
||||
salt-vagrant, \
|
||||
vagrant
|
||||
|
|
13
README.md
13
README.md
|
@ -4,13 +4,14 @@ This is the codebase for the website, [Snipt.net](https://snipt.net/).
|
|||
|
||||
# Running the Django app
|
||||
|
||||
Install [Vagrant](https://www.vagrantup.com/) and either [VirtualBox](https://www.virtualbox.org/) or
|
||||
[VMWare Fusion](http://www.vmware.com/products/fusion).
|
||||
|
||||
1. Clone the repo.
|
||||
2. Setup a virtualenv.
|
||||
3. `pip install -r requirements.txt`
|
||||
5. `python manage.py syncdb`
|
||||
6. `python manage.py migrate`
|
||||
7. `python manage.py runserver`
|
||||
8. If you created a superuser in the syncdb step, you need to also run `python manage.py backfill_api_keys` to generate an API key for that user.
|
||||
2. `cp settings_local.py-template settings_local.py`
|
||||
3. Edit local settings (choose a database password - you'll be prompted for it).
|
||||
4. `make vagrant`
|
||||
5. Visit [http://local.snipt.net:8080/](http://local.snipt.net:8080/).
|
||||
|
||||
# Deploying to Heroku
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ class BlogMiddleware:
|
|||
host = request.META.get('HTTP_HOST', '')
|
||||
host_s = host.replace('www.', '').split('.')
|
||||
|
||||
if host != 'snipt.net' and host != 'snipt.localhost':
|
||||
if host != 'snipt.net' and host != 'snipt.localhost' and host != 'local.snipt.net':
|
||||
if len(host_s) > 2:
|
||||
if host_s[1] == 'snipt':
|
||||
|
||||
|
|
|
@ -74,8 +74,11 @@ server {
|
|||
proxy_set_header Host $host;
|
||||
}
|
||||
|
||||
location /static/ {
|
||||
alias /var/www/snipt/static/;
|
||||
expires max;
|
||||
}
|
||||
{% if pillar.env_name != 'vagrant' %}
|
||||
location /static/ {
|
||||
alias /var/www/snipt/static/;
|
||||
expires max;
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
gzip_types text/html 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/*;
|
||||
|
||||
|
|
17
settings.py
17
settings.py
|
@ -21,23 +21,6 @@ if 'DATABASE_URL' in os.environ:
|
|||
if es.username:
|
||||
HAYSTACK_CONNECTIONS['default']['KWARGS'] = {"http_auth": es.username + ':' + es.password}
|
||||
|
||||
else:
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||
'NAME': 'snipt',
|
||||
'USER': '',
|
||||
'PASSWORD': '',
|
||||
'HOST': 'localhost',
|
||||
'PORT': ''
|
||||
}
|
||||
}
|
||||
HAYSTACK_CONNECTIONS = {
|
||||
'default': {
|
||||
'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
|
||||
},
|
||||
}
|
||||
|
||||
ABSOLUTE_URL_OVERRIDES = { 'auth.user': lambda u: "/%s/" % u.username, }
|
||||
ACCOUNT_ACTIVATION_DAYS = 0
|
||||
ADMINS = (('Nick Sergeant', 'nick@snipt.net'),)
|
||||
|
|
|
@ -1,8 +1,30 @@
|
|||
AWS_ACCESS_KEY_ID = ''
|
||||
AWS_SECRET_ACCESS_KEY = ''
|
||||
AWS_STORAGE_BUCKET_NAME = ''
|
||||
DEBUG=True
|
||||
DEBUG = True
|
||||
INTERCOM_SECRET_KEY = ''
|
||||
POSTMARK_API_KEY = ''
|
||||
RAVEN_CONFIG_DSN = ''
|
||||
S3_URL = 'https://%s.s3.amazonaws.com/' % AWS_STORAGE_BUCKET_NAME
|
||||
SECRET_KEY = ''
|
||||
SSLIFY_DISABLE = True
|
||||
STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
|
||||
STATIC_URL = '/static/'
|
||||
STRIPE_SECRET_KEY = ''
|
||||
USE_SSL = False
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||
'NAME': 'snipt',
|
||||
'USER': 'snipt',
|
||||
'PASSWORD': 'password',
|
||||
'HOST': 'localhost',
|
||||
'PORT': ''
|
||||
}
|
||||
}
|
||||
HAYSTACK_CONNECTIONS = {
|
||||
'default': {
|
||||
'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
|
||||
},
|
||||
}
|
||||
|
|
Laddar…
Referens i nytt ärende