Created
October 15, 2014 16:58
-
-
Save wjordan/daab26c08ca9d4c75ea5 to your computer and use it in GitHub Desktop.
code-dot-org vagrant setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
VAGRANTFILE_API_VERSION = "2" | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
config.vm.box = "ubuntu/trusty64" | |
config.vm.network "private_network", ip: "192.168.60.10" | |
config.vm.provider "virtualbox" do |vb| | |
vb.customize ["modifyvm", :id, "--memory", "2048"] | |
end | |
$root_script = <<SCRIPT | |
set -e # exit if any command exits with nonzero | |
export DEBIAN_FRONTEND=noninteractive | |
# Configure apt updates for speedup (eliminate multiple languages, pipeline http requests) | |
echo << EOF > /etc/apt/apt.conf.d/99speedup | |
Acquire::Languages { "en"; }; | |
Acquire::http { Pipeline-Depth "200"; } | |
EOF | |
# Use closest Ubuntu mirror repository | |
sed -i -e 's#http://archive.ubuntu.com/ubuntu#mirror://mirrors.ubuntu.com/mirrors.txt#g' /etc/apt/sources.list | |
# Disable source repository downloads | |
sed -i 's/^deb\-src/\#deb\-src/' /etc/apt/sources.list | |
apt-get install -y aptitude | |
aptitude update | |
aptitude upgrade -y | |
# Install mysql server 5.5 with empty root password (temp password is necessary for unattended install) | |
if [ ! -f /usr/bin/mysql ]; then | |
cat << EOF | debconf-set-selections | |
mysql-server-5.5 mysql-server/root_password password TEMPPASSWORD | |
mysql-server-5.5 mysql-server/root_password_again password TEMPPASSWORD | |
mysql-server-5.5 mysql-server/root_password seen true | |
mysql-server-5.5 mysql-server/root_password_again seen true | |
EOF | |
aptitude install -y mysql-server-5.5 mysql-server | |
cat << EOF | mysql -pTEMPPASSWORD | |
FLUSH PRIVILEGES; | |
SET PASSWORD FOR root@'localhost' = PASSWORD(''); | |
FLUSH PRIVILEGES; | |
EOF | |
fi | |
# Install all other necessary OS packages | |
aptitude install -y git build-essential libmysqlclient-dev libssl-dev zlib1g-dev imagemagick libmagickcore-dev libmagickwand-dev libsqlite3-dev sqlite3 libxslt1-dev | |
aptitude install -y git build-essential libsqlite3-dev sqlite3 libmysqlclient-dev libxslt1-dev libssl-dev zlib1g-dev imagemagick libmagickcore-dev libmagickwand-dev nodejs nodejs-legacy openjdk-7-jre-headless libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev curl npm | |
npm update -g npm | |
npm install -g grunt-cli | |
SCRIPT | |
$user_script = <<SCRIPT | |
# Run this script as user (not root) | |
# Install ruby 2.0.0 from rvm | |
curl -sSL https://get.rvm.io | bash | |
source $HOME/.rvm/scripts/rvm | |
rvm install 2.0.0 | |
echo "gem: --no-ri --no-rdoc" > ~/.gemrc | |
gem install bundler | |
cd $HOME | |
git clone http://github.com/code-dot-org/code-dot-org | |
cd code-dot-org/aws | |
bundle install | |
cd ../dashboard | |
bundle install | |
bundle exec rake db:create db:schema:load seed:all | |
cd ../pegasus | |
bundle install | |
echo CREATE DATABASE pegasus_development | mysql -uroot | |
rake db:migrate | |
rake seed:migrate | |
SCRIPT | |
config.vm.provision :shell, inline: $root_script | |
config.vm.provision :shell do |shell| | |
shell.inline = $user_script | |
shell.privileged = false | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment