Skip to content

Instantly share code, notes, and snippets.

@lacostenycoder
Created September 28, 2016 15:59
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 lacostenycoder/0770dba1ae56efed681e6acdd0864d09 to your computer and use it in GitHub Desktop.
Save lacostenycoder/0770dba1ae56efed681e6acdd0864d09 to your computer and use it in GitHub Desktop.
Vagrantfile Ruby RBENV & Postgres. Includes hack to solve PG default Encoding Issues
# -*- mode: ruby -*-
# vi: set ft=ruby :
$script = <<SCRIPT
sudo apt-get -y update
sudo apt-get -y install curl git-core python-software-properties ruby-dev libpq-dev build-essential nginx libsqlite3-0 libsqlite3-dev libxml2 libxml2-dev libxslt1-dev nodejs imagemagick
sudo apt-get -y install libcurl4-openssl-dev
sudo apt-get -y install libc6 zlib1q
sudo apt-get -y install postgresql postgresql-contrib
# System prerequisites
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
sudo -H -u vagrant bash -i -c 'rbenv install 2.1.5'
sudo -H -u vagrant bash -i -c 'rbenv rehash'
sudo -H -u vagrant bash -i -c 'rbenv global 2.1.5'
sudo -H -u vagrant bash -i -c 'gem install bundler --no-ri --no-rdoc'
sudo -H -u vagrant bash -i -c 'rbenv rehash'
echo "ALTER USER postgres" | sudo -u postgres psql
echo "CREATE USER vagrant" | sudo -u postgres psql
echo "ALTER ROLE vagrant CREATEDB" | sudo -u postgres psql
#Begin PG Hack
sudo -u postgres pg_dumpall > /tmp/postgres.sql
sudo pg_dropcluster --stop 9.1 main
sudo pg_createcluster --locale en_US.UTF-8 --start 9.1 main
sudo -u postgres psql -f /tmp/postgres.sql
sudo rm /tmp/postgres.sql
# end PG hack
SCRIPT
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "hashicorp/precise64"
config.vm.network "forwarded_port", guest: 3000, host: 3000
config.ssh.forward_agent = true
# config.vm.provider :virtualbox do |vb|
# vb.customize ["modifyvm", :id, "--memory", "1024"]
# end
config.vm.provision :shell, :inline => <<-EOT
echo 'LC_ALL="en_US.UTF-8"' > /etc/default/locale
echo 'LANGUAGE=en_US.UTF-8' >> /etc/default/locale
EOT
config.vm.provision :shell, privileged: false, inline: $script
end
@lacostenycoder
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment