Skip to content

apollo-black/dev-vm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Apollo Development VM

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.

General Usage

  1. Copy the Vagrantfile from this repository into your project root
  2. Type vagrant up
  3. Type vagrant ssh
  4. 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

Dependencies

Installed Components

Programming Stacks

Databases

All database usernames and passwords would generally be:

  • Username: vagrant
  • Password: vagrant

Machine Learning

Other Tools

Utilities

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

Useful Vagrant Commands

Daily use sometimes requires that you destroy or reload virtual machines, here are some useful commands.

Launch a VM
$> vagrant up
Connect to VM via SSH
$> vagrant ssh
Stop a VM
$> vagrant halt
Reload a VM without needing to destroy it
$> vagrant reload
Destroy a VM
$> vagrant destroy
Show VM's & Statuses
$> vagrant global-status

You can find more information about the available commands on the Vagrant website.

Environment Variables

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

Memory / VRAM

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.

Building the Actual VM from Source (not recommended)

  1. Open VirtualBox and launch a blank Ubuntu Image. The base virtual drive should be 15gb or larger.
  2. Install Git sudo apt install git-core
  3. Clone this repository git clone https://github.com/apollo-black/dev-vm.git
  4. Execute the setup.sh script in this repository.

Packaging a VM

  1. 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.

License

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.

Releases

No releases published

Packages

No packages published

Languages