Created
August 17, 2017 18:23
-
-
Save gouvermxt/fe18bf255fe3a6a73dc3fc94358ad91b to your computer and use it in GitHub Desktop.
Vagrant file for Ruby 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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.configure(2) do |config| | |
config.vm.box = "ubuntu/trusty64" | |
config.vm.network "private_network", ip: "10.2.2.2" | |
config.vm.network :forwarded_port, guest: 3000, host: 3000 | |
config.vm.network :forwarded_port, guest: 5432, host: 5432 | |
config.vm.provider "virtualbox" do |vb| | |
#Customize the amount of memory on the VM: | |
vb.memory = "768" | |
end | |
config.vm.provision 'shell', privileged: true, inline: <<-SHELL | |
apt-get -y update | |
apt-get -y upgrade | |
apt-get install -y curl build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion libgmp-dev nodejs libpq-dev | |
SHELL | |
config.vm.provision 'shell', privileged: false, inline: <<-SHELL | |
command curl -sSL https://rvm.io/mpapis.asc | gpg --import - | |
curl -L https://get.rvm.io | bash -s stable | |
source ~/.rvm/scripts/rvm | |
rvm requirements | |
rvm install 2.4.1 | |
echo "gem: --no-ri --no-rdoc" > ~/.gemrc | |
gem install bundler | |
gem update --system | |
cd /vagrant | |
SHELL | |
config.vm.provision 'shell', privileged: true, inline: <<-SHELL | |
export LANGUAGE=en_US.UTF-8 | |
export LANG=en_US.UTF-8 | |
export LC_ALL=en_US.UTF-8 | |
locale-gen en_US.UTF-8 | |
dpkg-reconfigure locales | |
apt-get install -y postgresql postgresql-contrib postgresql-server-dev-9.3 | |
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD 'root'" | |
sudo -u postgres psql -c "CREATE USER vagrant WITH PASSWORD 'vagrant'" | |
sudo -u postgres psql -c "ALTER USER vagrant CREATEDB" | |
echo 'host all all all password' >> /etc/postgresql/9.3/main/pg_hba.conf | |
echo "listen_addresses = '*'" >> /etc/postgresql/9.3/main/postgresql.conf | |
/etc/init.d/postgresql restart | |
SHELL | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Basicamente depois de instalar o vagrant, coloca este Vagrantfile no diretório vazio do seu projeto.
vagrant up
vagrant ssh
e você já vai estar dentro de uma máquina Ubuntu com Ruby 2.4.1 instalado/vagrant
(tudo que criar aí dentro vai sincronizar com a pasta do seu projeto no windows)gem install rails -v 5.0.3
rails new . -d postgresql
config/database.yml
que o comando criou coloca esse conteúdorails db:create
rails s -b 0.0.0.0
http://localhost:3000