Skip to content

Commit

Permalink
fixup Tweaks to get it running first pass.
Browse files Browse the repository at this point in the history
Use install-as-user script to set up general.yml, database etc;
this is made much easier by putting the checkout in /vagrant/mapit
rather than /vagrant.

Remove mailcatcher/varnish lines, and use of sudo. Make virtualenv
self-activate, and install pyinotify to reduce CPU etc usage.
  • Loading branch information
dracos committed May 11, 2016
1 parent bee23a9 commit dde0c3e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 35 deletions.
5 changes: 2 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@ Create, and SSH in to, the Vagrant VM:

Inside the VM, run the Django dev server:

. /virtualenv-mapit/bin/activate
cd /vagrant
cd /vagrant/mapit
./manage.py runserver 0.0.0.0:8000

MapIt will be accessible at <http://localhost:8000> on the host machine.

If you make changes to the stylesheets, you will need to recompile the Sass files:

# from /vagrant in the VM:
# from /vagrant/mapit in the VM:
bin/mapit_make_css

## Full setup on your own server
Expand Down
47 changes: 15 additions & 32 deletions VagrantFile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"

# Enable NFS access to the disk
config.vm.synced_folder ".", "/vagrant", :nfs => true
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.synced_folder ".", "/vagrant/mapit", :nfs => true

# NFS requires a host-only network
# This also allows you to test via other devices (e.g. mobiles) on the same
Expand All @@ -20,10 +21,6 @@ Vagrant.configure(2) do |config|

# Django dev server
config.vm.network "forwarded_port", guest: 8000, host: 8000
# For accessing via Varnish
config.vm.network "forwarded_port", guest: 8001, host: 81
# For mailcatcher
config.vm.network "forwarded_port", guest: 1080, host: 1080

# Give the VM a bit more power to speed things up
config.vm.provider "virtualbox" do |v|
Expand All @@ -33,39 +30,25 @@ Vagrant.configure(2) do |config|

# Provision the vagrant box
config.vm.provision "shell", inline: <<-SHELL
sudo apt-get update
apt-get update
cd /vagrant
chown vagrant:vagrant /vagrant
cd /vagrant/mapit
# Install the packages from conf/packages.ubuntu-trusty
xargs sudo apt-get install -qq -y < conf/packages.ubuntu-trusty
# Install some of the other things we need that are either just for dev
# or can't come from the usual package manager
# ruby-dev for mailcatcher
# git for installing mapit from the repo directly
sudo apt-get install -qq -y ruby-dev git
xargs apt-get install -qq -y < conf/packages.ubuntu-trusty
# Create a postgresql user
sudo -u postgres psql -c "CREATE USER mapit SUPERUSER CREATEDB PASSWORD 'mapit'"
# Create a database
sudo -u postgres psql -c "CREATE DATABASE mapit"
# Install the POSTGIS extensions
sudo -u postgres psql -c "CREATE EXTENSION postgis; CREATE EXTENSION postgis_topology;" -d mapit
su postgres -c 'psql -c "CREATE USER vagrant SUPERUSER CREATEDB"'
# Install mailcatcher to make dev email development easier
sudo gem install mailcatcher
# Run install-as-user to set up a database, virtualenv, python, sass etc
su vagrant -c 'bin/install-as-user vagrant mapit.mysociety.org /vagrant'
# Run post-deploy actions script to create a virtualenv, install the
# python packages we need, migrate the db and generate the sass etc
conf/post_deploy_actions.bash
# Nicer running of runserver
su vagrant -c '../virtualenv-mapit/bin/pip install pyinotify'
# Auto-activate virtualenv on login
echo >> /home/vagrant/.bashrc "source /vagrant/virtualenv-mapit/bin/activate"
SHELL

# Start mailcatcher every time we start the VM
config.vm.provision "shell", run: "always" do |s|
s.inline = <<-SHELL
mailcatcher --http-ip 0.0.0.0
cd /vagrant
source ../virtualenv-mapit/bin/activate
SHELL
end
end
end

0 comments on commit dde0c3e

Please sign in to comment.