# Download and configure a stock VirtualBox instance of Ubuntu Raring 13.04.
# Configure it for runtime and development of cpppo applications (including
# Docker-based configurations)
Vagrant.configure("2") do |config|
  config.vm.box				= "precise64"
  config.vm.provision "shell" do |s|
    # Installs lxc-docker, and linux-image-extra-3.X.X-... for every installed kernel version
    # (which may be different than the running kernel after the upgrade! ) Raring requiries
    # software-properties-common, Precise python-software-properties to supply apt-add-repository.
    # Adding a docker group causes /var/run/docker.sock to be docker group writable.
    # The initiating cpppo source directory is mounted on /src/cpppo.  
    s.inline 				= '			\
        sed -e "s|us.archive.ubuntu.com|mirrors.kernel.org|" -i /etc/apt/sources.list\
        && apt-get update					\
        && apt-get install -y					\
            software-properties-common python-software-properties\
            apt-show-versions					\
        && apt-get -u -y dist-upgrade				\
        && echo "Installing docker and utilities..."		\
        && sudo -u vagrant wget -q --output-document=/usr/local/bin/pipework \
                https://raw.github.com/pjkundert/pipework/master/pipework \
        && chmod a+x /usr/local/bin/pipework			\
        && add-apt-repository ppa:dotcloud/lxc-docker		\
        && apt-get update					\
        && apt-get install -y `apt-show-versions -a | sed -ne	\
           \'s/^\(linux-image\)-\([[:digit:]\.]\+[^[:space:]]*\).*installed$/\1-extra-\2/p\'`\
	   git python-pip lxc-docker 				\
        && addgroup docker					\
        && addgroup vagrant docker				\
        && service docker restart				\
        && pip install cpppo					\
        && echo && echo "Login w/ vagrant ssh"			\
	'
  end
  config.vm.network "forwarded_port",	   guest: 80, host: 8080, auto_correct: true
  config.vm.synced_folder		   "../../..", "/home/vagrant/src"
  config.vm.provider "vmware_fusion" do |v|
    v.vmx["memsize"]			= "2048"
    v.vmx["numvcpus"]			= "2"
    v.gui 				= true
  end
  config.vm.provider "virtualbox" do |v|
    v.gui 				= true
  end
end
