🔓
Pro Docs
Boom! Unlocked. Thanks for supporting us.
TL;DR
Pro Version
git clone https://github.com/scotch-io/scotch-box-pro my-project
cd my-project
vagrant up
Pro Version (NGINX)
git clone https://github.com/scotch-io/scotch-box-pro-nginx my-project
cd my-project
vagrant up
Build Scripts
git clone https://github.com/scotch-io/scotch-box-build-scripts my-project
cd my-project
vagrant up
Get Started with Pro
Pro is just as easy to use! You can access the Scotch Box Pro GitHub repo here:
Important:
The Vagrantfile has been adjusted and improved - but is still as simple as ever. You'll notice it's a little bit different:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "scotch/box-pro"
config.vm.hostname = "scotchbox"
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.synced_folder ".", "/var/www", :mount_options => ["dmode=777", "fmode=666"]
# Optional NFS. Make sure to remove other synced_folder line too
#config.vm.synced_folder ".", "/var/www", :nfs => { :mount_options => ["dmode=777","fmode=666"] }
end
NGINX Version
This version is also available and behaves exactly the same way.
Important:
The Vagrantfile has been adjusted and improved - but is still as simple as ever. You'll notice it's a little bit different:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "scotch/box-pro-nginx"
config.vm.hostname = "scotchbox"
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.synced_folder ".", "/var/www", :mount_options => ["dmode=777", "fmode=666"]
# Optional NFS. Make sure to remove other synced_folder line too
#config.vm.synced_folder ".", "/var/www", :nfs => { :mount_options => ["dmode=777","fmode=666"] }
end
Build Scripts
The build scripts are a good way for you to try and replicate the box or personalize them. You can access them here:
Create a Personalized / Custom Box
If you're anything like me, you love customizing and personalizing your dev setup. From your terminal, to your editor, and to your work station.
I've setup these build scripts in a way to be super easy to customize with very little experience. It's purposefully all in one file with very easy to read spacing from the top. Everything will look like this:
/*=====================================
= INSTALL GROUP =
=====================================*/
bunch of code
bunch of code
bunch of code
bunch of code
/*=====================================
= INSTALL GROUP =
=====================================*/
bunch of code
bunch of code
bunch of code
bunch of code
Hopefully you'll see just how easy it will be to modify this build process to your needs. You barely have to even know bash!
The Box Builder Vagrantfile
Let's talk about the Vagrantfile. This is different than the default Vagrantfile for Scotch Box. Here's what it looks like, then we'll talk about it:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "bento/ubuntu-16.04"
config.vm.hostname = "scotchbox"
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.synced_folder ".", "/var/www", :mount_options => ["dmode=777", "fmode=666"]
config.ssh.insert_key = false
config.vm.provision "shell", path: "install.sh", privileged: false
end
Key Points:
- We use Bento's Ubuntu box because it's Vagrant ready (but everything else is 100% the same).
- SSH Insert Key needs to be OFF as shown above during the build process.
- The shell provisioner runs as the vagrant user and not root. So you'll need to add "sudo" to commands.
How to Build a Box:
Step 0: Prerequisites
Make sure:
- You're running the latest version of Vagrant
- You're running the latest version of Virtual Box.
- You downloaded the latest VirtualBox Extension Pack here.
Step 1: Clone the Repo:
git clone https://github.com/scotch-io/scotch-box-build-scripts
cd scotch-box-build-scripts
Step 2: Change the Hostname
In the Vagrantfile, pick a hostname for your box:
Step 3: Modify install.sh
You can literally do whatever you want here! This install script should get your foot in the door in the simplest and easiest way possible. There's 2 variables at the top for speediness though:
- INSTALL_NGINX_INSTEAD
- WELCOME_MESSAGE
You can modify more than that though. Here's some common things to look at for:
- Document Root
- Database Credentials
- FQDN
- PHP Settings
- Specific Versions
- Add / Remove / Improve things
Step 4: Run "Vagrant Up"
Once you get your script ready to go, just run vagrant up
.
This process will take as long as it needs based on what you did with the script. It will output all messages to you so you might need to debug a few times.
Step 5: Package it up
After it's done, feel free to SSH into the box and make sure things are working. Once you properly do QA, you're ready to package the box.
To package the box, we're going to run a few commands.
# SSH into the box
vagrant ssh
# "Zero it out" (make it small as possible)
sudo dd if=/dev/zero of=/EMPTY bs=1M
sudo rm -f /EMPTY
# Clear APT cache (make it smaller)
sudo apt-get autoremove
sudo apt-get clean
# Delete bash histroy and exit
cat /dev/null > ~/.bash_history && history -c && exit
# Stop the box
vagrant halt
# Package the box with Vagrant
vagrant package --output my-custom-environment.box
# Add the box to your vagrant!
vagrant box add my-custom-environment my-custom-environment.box
Step 6: Create a New Vagrantfile
Once this is done, we're ready to start using this! Here's what your new Vagrantfile should look like:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "my-custom-environment"
config.vm.hostname = "mycustomenvironment"
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.synced_folder ".", "/var/www", :mount_options => ["dmode=777", "fmode=666"]
# Optional NFS. Make sure to remove other synced_folder line too
#config.vm.synced_folder ".", "/var/www", :nfs => { :mount_options => ["dmode=777","fmode=666"] }
end
That's it! I hope that helps and you can get it working. For support reach out on GitHub in issues or the official Vagrant Github.