From 0681f60692a1917a2c9f6ec58468b96b85e6e1b2 Mon Sep 17 00:00:00 2001 From: Jesse Szwedko Date: Thu, 7 Jun 2018 10:03:00 -0700 Subject: [PATCH] Brush off Vagrantfile * Name Virtualbox VM to make it easier to find * Prefer long form of flags for readibility * Install git (needed by Gemfile dependency) * Use .ruby-version to determine the version of Ruby to install to have less places to update * Disable redis-server so it doesn't start on boot (in case the machine is rebooted). * Remove Profile.vagrant (basic Procfile works fine and is the one referenced in the README) --- Procfile.vagrant | 2 -- Vagrantfile | 35 ++++++++++++++++++----------------- 2 files changed, 18 insertions(+), 19 deletions(-) delete mode 100644 Procfile.vagrant diff --git a/Procfile.vagrant b/Procfile.vagrant deleted file mode 100644 index 4e219ba..0000000 --- a/Procfile.vagrant +++ /dev/null @@ -1,2 +0,0 @@ -web: bundle exec rackup -worker: bundle exec sidekiq -r ./app.rb \ No newline at end of file diff --git a/Vagrantfile b/Vagrantfile index bb819b6..1d11452 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -43,13 +43,14 @@ Vagrant.configure(2) do |config| # backing providers for Vagrant. These expose provider-specific options. # Example for VirtualBox: # - # config.vm.provider "virtualbox" do |vb| + config.vm.provider "virtualbox" do |vb| + vb.name = "citygram" # # Display the VirtualBox GUI when booting the machine # vb.gui = true # # # Customize the amount of memory on the VM: # vb.memory = "1024" - # end + end # # View the documentation for the provider you are using for more # information on available options. @@ -66,34 +67,34 @@ Vagrant.configure(2) do |config| # documentation for more information about their specific syntax and use. config.vm.provision "shell", privileged: false, inline: <<-SHELL # print command to stdout before executing it: - set -x - - curl -sSL https://rvm.io/mpapis.asc | gpg --import - - curl -L https://get.rvm.io | bash -s stable --autolibs=enabled --ruby - - source "$HOME/.rvm/scripts/rvm" - rvm install 2.5.0 - rvm use 2.5.0 + set -o xtrace - echo 'source "$HOME/.rvm/scripts/rvm"' >> .bashrc - echo "rvm use 2.5.0" >> .bashrc + curl --silent --show-error --location https://rvm.io/mpapis.asc | gpg --import - + curl --location https://get.rvm.io | bash -s stable --autolibs=enabled --ruby + echo 'source "$HOME/.rvm/scripts/rvm"' >> $HOME/.bashrc # install postgres - sudo apt-get -y install postgresql postgresql-contrib libpq-dev postgresql-9.3-postgis-2.1 redis-server - sudo -u postgres psql -c "CREATE USER vagrant WITH PASSWORD 'vagrant';" - sudo -u postgres psql -c "ALTER ROLE vagrant SUPERUSER CREATEROLE CREATEDB REPLICATION;" - sudo -u postgres psql -c "CREATE EXTENSION postgis;" + sudo apt-get --assume-yes install postgresql postgresql-contrib libpq-dev postgresql-9.3-postgis-2.1 redis-server + sudo -u postgres psql --command "CREATE USER vagrant WITH PASSWORD 'vagrant';" + sudo -u postgres psql --command "ALTER ROLE vagrant SUPERUSER CREATEROLE CREATEDB REPLICATION;" + sudo -u postgres psql --command "CREATE EXTENSION postgis;" cd /vagrant + + source "$HOME/.rvm/scripts/rvm" + rvm install $(cat .ruby-version) + rvm use $(cat .ruby-version) + cp .env.sample .env echo "DATABASE_URL=postgres://vagrant:vagrant@localhost/citygram_development" >> .env - sudo apt-get install -y libgmp-dev node + sudo apt-get install --assume-yes git libgmp-dev node gem install bundle bundle install bundle exec rake db:create db:migrate sudo service redis-server stop + sudo update-rc.d redis-server disable SHELL end