Development environment for Ruby on Rails based on Vagrant, VirtualBox and Ubuntu 16.04 LTS (Xenial Xerus).
MIT License
Development environment for Ruby on Rails based on Vagrant, VirtualBox and Ubuntu 16.04 LTS (Xenial Xerus).
The Vagrant provisioning scripts do the following:
ubuntu
with password localdbpass
and grant it CREATEDB permissions.root
user to localdbpass
.Other scripts run at shell startup to set environment variables and Bash shortcuts (aliases and functions).
Install the latest version of Vagrant and VirtualBox on the host machine.
Choose a directory for your VirtualBox shared folder (in the host machine). Download this repository and unzip it inside the chosen directory.
Create an SSH key pair, name the files id_rsa
(private key), id_rsa.pub
(public key), and place them in the vm_provisioning
directory.
Edit the Vagrantfile
in order to customize the values of the variables
located in the "User Configurations" section.
Optional: If you require any custom environment variables to be available at
the guest VM, create a file named environment_variables.sh
within the
vm_provisioning
directory and set your environment vars using the standard
bash syntax: one export VAR_NAME='var value'
declaration per line. Those vars
will be loaded automatically every time the VM boots. That is a good place to
store your API keys and other secrets.
Optional: If you wish to use any custom bash aliases or functions, add them
to bash_shortcuts.sh
Optional: If you intend to use Selenium and Chrome headless with Capybara
and RSpec, add the following to spec/rails_helper.rb
:
require 'selenium-webdriver'
Capybara.register_driver :selenium do |app|
options = Selenium::WebDriver::Chrome::Options.new
# The window size is important for screenshots
options.add_argument "--window-size=1366,768"
Selenium::WebDriver::Chrome.driver_path = "/usr/local/bin/chromedriver"
Capybara::Selenium::Driver.new(app,
browser: :chrome,
options: options)
end
File | Contents and/or purpose | Executed at | Called by |
---|---|---|---|
bash_shortcuts.sh | Custom bash aliases and function definitions. | "Login" (shell startup) | Symlink at /etc/profile.d |
environment_variables.sh | Custom environment variable definitions. You may store your API keys and other secrets here, as long as you keep this file outside any Git repositories. | "Login" (shell startup) | Symlink at /etc/profile.d |
boot.sh | Custom startup commands. These commands were not inserted in rc.local because: a) we prefer Bash over Bourne Shell; b) the -e flag used in rc.local's shebang line causes undesired behavior. | VM boot | /etc/rc.local |
custom_rc_local.sh | Custom rc.local. Waits for the Vagrant shared folder to be mounted and executes the custom boot script (boot.sh ). |
VM boot | Installed by provision.sh |
provision.sh | Installs and configures everything in the VM, except Ruby and Rails. | VM provisioning | Vagrantfile |
install_ruby.sh | Installs Ruby and Rails in the VM at the end of provisioning. | VM provisioning | Vagrantfile |
Vagrantfile | General configurations. Set up the VirtualBox VM and the provisioning process. | vagrant up, halt, etc | the user |
cd to the directory where the Vagrantfile is (in the host machine) and run:
vagrant up
to start the VM;vagrant ssh
to access the VM via SSH;vagrant halt
to turn off the VM;You can also access the VM via SSH by connecting to port 2222 of the host
machine with your favorite SSH client, using the private key specified in the
ssh_private_key
variable of the Vagrantfile.
Shortcuts
All shortcuts except jcurl
only work when executed within a Rails app
directory.
rs
rails s -b 0.0.0.0
rc
rails console
br
bin/rspec. Use within the Rails application folder to run RSpec with
Spring.
brfd
bin/rspec --format documentation
tdl
tail -f development log
ttl
tail -f test log
ctl
clear test log
cdl
clear development log
jcurl
runs curl -s and pretty prints JSON output with the awesome_print gem.
Takes a URL as an argument.
bi
Run bundle install in multiple parallel threads (faster).
gpl
git pull
ga
git add
gc
git commit. Takes a commit message as an argument.
gp
git push. Takes a remote name and a branch name as optional arguments
(e.g., origin master)
gs
git status
gl
git log
Bug reports
Please use the issue tracker to report any bugs.
Developing
Released under the MIT License.