Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Vagrant file for installing ruby with rbenv
# -*- mode: ruby -*-
# vi: set ft=ruby :
RUBY_V = File.open("./.ruby-version") { |f| f.read }.chomp
$apt_script = <<SCRIPT
sudo apt-get update
sudo apt-get install -y git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev libmysqlclient-dev
SCRIPT
$rbenv_script = <<SCRIPT
if [ ! -d ~/.rbenv ]; then
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
fi
if [ ! -d ~/.rbenv/plugins/ruby-build ]; then
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
fi
export PATH="$HOME/.rbenv/bin:$PATH"
export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"
eval "$(rbenv init -)"
if [ ! -e .rbenv/versions/#{RUBY_V} ]; then
rbenv install #{RUBY_V}
fi
cd /vagrant
if [ ! -e /home/vagrant/.rbenv/shims/bundle ]; then
gem install bundler
rbenv rehash
fi
bundle install
SCRIPT
Vagrant.configure("2") do |config|
config.vm.define :ruby do |deploy_config|
deploy_config.vm.box = "hashicorp/precise64"
deploy_config.vm.hostname = "deploy"
deploy_config.vm.provider "virtualbox" do |vb|
vb.memory = "256"
end
deploy_config.ssh.forward_agent = true
deploy_config.vm.provision :shell, inline: $apt_script
deploy_config.vm.provision :shell, privileged: false, inline: $rbenv_script
end
end
@deepflame

This comment has been minimized.

Copy link

deepflame commented Dec 20, 2018

very clean and good ideas. Thanks for sharing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.