Last active
November 18, 2020 10:28
-
-
Save hopsor/8283cea0246fbe3284bd to your computer and use it in GitHub Desktop.
Vagrant provision script for Rails development environment
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
#!/bin/bash | |
echo "Provisioning virtual machine" | |
# Git | |
echo "Installing Git" | |
apt-get install git -y | |
# RVM + 1.9.3 + 2.1.3 | |
echo "Installing rvm + ruby 1.9.3 + ruby 2.1.3" | |
curl -sSL https://get.rvm.io | bash -s $1 | |
source /usr/local/rvm/scripts/rvm | |
rvm use --install 1.9.3 | |
rvm use --install 2.1.3 | |
# Adding user vagrant to rvm group so that he can use rvm | |
echo "Adding vagrant user to rvm group" | |
usermod -a -G rvm vagrant | |
# NodeJS | |
echo "Installing nodejs" | |
curl -sL https://deb.nodesource.com/setup | sudo bash - | |
apt-get install -y nodejs | |
# Postgresql + Contrib package + Developer dependencies | |
echo "Installing postgresql + Contrib package + Developer dependencies" | |
apt-get install -y postgresql postgresql-contrib libpq-dev | |
# MySQL + Developer dependencies | |
echo "Preparing MySQL" | |
apt-get install debconf-utils -y > /dev/null | |
debconf-set-selections <<< "mysql-server mysql-server/root_password password 1234" | |
debconf-set-selections <<< "mysql-server mysql-server/root_password_again password 1234" | |
echo "Installing MySQL + Developer dependencies" | |
apt-get install -y mysql-server libmysqlclient-dev | |
# MongoDB | |
echo "Installing mongodb" | |
apt-get install -y mongodb | |
# Redis | |
echo "Installing redis" | |
apt-get install -y redis-server | |
# Other dependencies such as imagemagick, libxslt, etc. Most of them needed by principal ruby gems | |
echo "Installing imagemagick and rmagick related dependencies" | |
apt-get install -y imagemagick libmagick++-dev libmagickwand-dev | |
echo "Installing nokogiri dependencies" | |
apt-get install -y libxslt-dev libxml2-dev | |
# Installing zsh setting as default shell for vagrant user | |
echo "Installing zsh, oh-my-zsh and setting it as default shell for vagrant user" | |
apt-get install -y zsh | |
sudo su - vagrant -c 'wget --no-check-certificate http://install.ohmyz.sh -O - | sh' | |
sudo su - vagrant -c "echo 'source /etc/profile.d/rvm.sh' >> ~/.zshrc" | |
chsh -s $(which zsh) vagrant |
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/syntax version. Don't touch unless you know what you're doing! | |
VAGRANTFILE_API_VERSION = "2" | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
# All Vagrant configuration is done here. The most common configuration | |
# options are documented and commented below. For a complete reference, | |
# please see the online documentation at vagrantup.com. | |
# Every Vagrant virtual environment requires a box to build off of. | |
config.vm.box = "ubuntu-14.04" | |
config.vm.network :forwarded_port, guest: 3000, host: 3000 | |
config.vm.network :private_network, ip: "192.168.50.4" | |
config.vm.synced_folder "./www", "/vagrant_data", nfs: true | |
config.vm.provider :virtualbox do |vb| | |
# Use VBoxManage to customize the VM. For example to change memory: | |
vb.customize ["modifyvm", :id, "--memory", "4096"] | |
end | |
config.ssh.forward_agent = true | |
# Shell provisioning | |
config.vm.provision "shell" do |s| | |
s.path = "vagrant-provision/setup.sh" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment