Created
September 28, 2016 15:59
-
-
Save lacostenycoder/0770dba1ae56efed681e6acdd0864d09 to your computer and use it in GitHub Desktop.
Vagrantfile Ruby RBENV & Postgres. Includes hack to solve PG default Encoding Issues
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 : | |
$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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks to Paval Horal for this which helped: http://stackoverflow.com/questions/20815440/force-postgres-to-install-with-utf8-encoding-not-latin1