Skip to content

Instantly share code, notes, and snippets.

@arubdesu
Last active December 28, 2015 02:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arubdesu/a932d7d9adcb312ea8c4 to your computer and use it in GitHub Desktop.
Save arubdesu/a932d7d9adcb312ea8c4 to your computer and use it in GitHub Desktop.
For working on madebygraham Django webapps, a vagrantfile and script to run inside the resulting vm (as sudo) to set up a dev env (no nginx, no postgresql, no wsgi). Expects a unpacked download of the crypt-server docker repo in the shared folder(which is the same as the vagrantfile's working dir by default), checks out current master
#!/bin/bash
set -x
# Run from /vagrant dir inside vm (as sudo) to set up dev env (no nginx, no postgresql, no wsgi)
APP_DIR="/vagrant/crypt"
git clone https://github.com/grahamgilbert/crypt-server.git $APP_DIR
pip install -r $APP_DIR/setup/requirements.txt
# move docker ADD'd files/dirs into place
cp /vagrant/crypt-server-master/settings.py $APP_DIR/fvserver/
cp /vagrant/crypt-server-master/settings_import.py $APP_DIR/fvserver/
cp -R /vagrant/crypt-server-master/django/management/ $APP_DIR/server/management/
# perform original run.sh tasks
cd $APP_DIR
python generate_keyczart.py
python manage.py syncdb --noinput
python manage.py migrate server
python manage.py migrate --noinput
python manage.py collectstatic --noinput
python manage.py update_admin_user --username=admin --password=password
# chown -R vagrant:vagrant $APP_DIR
chmod go+x $APP_DIR
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "puppetlabs/ubuntu-14.04-64-nocm"
config.vm.network "forwarded_port", guest: 8000, host: 8000
# note: if rolling back snapshots w/ 1.8, this may cause a lenghty re-provision
config.vm.provision "shell", inline: <<-SHELL
sudo apt-get update
sudo apt-get install -y software-properties-common && \
sudo apt-get -y update && \
sudo add-apt-repository -y ppa:nginx/stable && \
sudo apt-get -y install \
git \
python-setuptools \
nginx \
postgresql \
postgresql-contrib \
libpq-dev \
python-dev \
supervisor \
nano \
libffi-dev && \
sudo apt-get clean && \
sudo rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# install common python-related tools
sudo easy_install pip
sudo pip install psycopg2==2.5.3 && \
sudo pip install gunicorn && \
sudo pip install setproctitle
SHELL
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment