This Virtual Machine has everything installed that we use to develop software with Ruby on Rails, Python & Golang.
It's the single source of runtime that imitates the production servers to ensure that all developers have exactly the same development environments.
- Copy the
Vagrantfile
from this repository into your project root - Type
vagrant up
- Type
vagrant ssh
- Type
cd app
The ~/app
directory inside the VM will be the root of your project.
Note: If you are using MySQL, please run sudo mysql_secure_installation
after provisioning the VM.
Contents of the Vagrantfile
:
Vagrant.configure("2") do |config|
config.vm.box = "apolloblack/dev-vm"
config.vm.box_check_update = false
config.vm.network "forwarded_port", guest: 3000, host: 3000 # rails
config.vm.synced_folder ".", "/vagrant_data"
config.vm.provider "virtualbox" do |vb|
vb.memory = "2048"
end
config.vm.provision "shell", privileged: false, inline: <<-SHELL
ln -s /vagrant_data ~/app
SHELL
end
- VirtualBox
tested on v5.2.16
- Vagrant
tested on v2.1.5
- Nodejs 10.7.0
- NVM 0.33.11
- NPM 6.1.0
- PHP 7.0
- Ruby 2.6.1
- Bundler 1.16.3
- Webpacker 3.5.5
- Crystal 0.25.1
- Java 8
- Python 2.7 & 3.5.2
- Lua 5.3.5
All database usernames and passwords would generally be:
- Username: vagrant
- Password: vagrant
- AWS CLI Tools
- Heroku Command Line v7.7.4
- Docker
- Vue CLI
- React Native CLI
- Yarn
- Expo CLI
- Tesseract
- Google Cloud CLI
There are also utilities installed on the machine to help make life easier:
To share your environment using ngrok:
$> ngrok http 3000
is-up 1.0: Check if a website is up or down.
$> is-up apollo.black
pageres-cli 4.1.0: Capture screenshots of websites in any resolution
$> pageres apollo.black 1024x768
loadtest 3.0.3: Perform a load test on any URL
$> loadtest -n 100 -c 5 -k apollo.black
pgweb 0.9.12: Plug and play Postgresql web interface
$> pgweb --host localhost --user app_user --db app_db
htop: Interactive unix process viewer
$> htop
httpie: Command line HTTP client
$> http -v apollo.black
Daily use sometimes requires that you destroy or reload virtual machines, here are some useful commands.
$> vagrant up
$> vagrant ssh
$> vagrant halt
$> vagrant reload
$> vagrant destroy
$> vagrant global-status
You can find more information about the available commands on the Vagrant website.
To make life easier, we have the following ENV variables defined in /etc/environment
:
$> DATABASE_URL="postgresql://vagrant:[email protected]:5432/vagrant"
$> REDIS_URL="redis://localhost:6379"
$> RAILS_ENV="development"
You can add new ENV vars to either the /etc/environment
file or the ~/.profile
file.
If you install Nginx and Phusion Passenger on the VM and want to set application specific ENV
variables, you can use passenger_env_var directive:
$> passenger_env_var DATABASE_URL postgresql://vagrant:[email protected]:5432/vagrant;
$> passenger_env_var REDIS_URL redis://localhost:6379;
Similarly, with Apache2, you can use the SetEnv directive:
$> SetEnv DATABASE_URL postgresql://vagrant:[email protected]:5432/vagrant
$> SetEnv REDIS_URL redis://localhost:6379
You can adjust the available VM memory within the Vagrantfile
, by changing vb.memory
:
config.vm.provider "virtualbox" do |vb|
vb.memory = "2048"
end
Any number not exceeding your available host RAM will work.
Note: Depending on what development frameworks you want to use, you'll need to fiddle with the available VRAM for your VM instance. Java and .Net(Mono), BigData or ML/AI based projects will require much more VRAM than simpler tech like PHP or Ruby.
- Open VirtualBox and launch a blank Ubuntu Image. The base virtual drive should be 15gb or larger.
- Install Git
sudo apt install git-core
- Clone this repository
git clone https://github.com/apollo-black/dev-vm.git
- Execute the
setup.sh
script in this repository.
- SSH into the VM and run the following:
$> rm ~/dev-vm
$> rm ~/downloads
$> cat /dev/null > ~/.bash_history && history -c && exit
$> sudo dd if=/dev/zero of=/EMPTY bs=1M
$> sudo rm -f /EMPTY
Head back to your host machine terminal and run the following:
$> vagrant package --base <box name> --output apollo-<BOX NAME>.box
Replace <box name>
with the name of the Virtual Box instance (ie: apollo-ruby)
. Once done, the box will be packaged in the same directory that you are currently in.
MIT License
Copyright (c) 2019 Apollo Black / Sean Nieuwoudt
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.