Creating a New Box Version - 3ev/3ev-vagrant GitHub Wiki
This guide details the process for making a changes to a VM and releasing a new box version for other developers to use.
###The process
####1. Get a local copy of the VM
Firstly, you'll need a local copy of the provisioning scripts. Just use clone and checkout the branch for the box you want to update.
$ git clone [email protected]:3ev/3ev-vagrant.git ~/code/dev-tev-production
$ git checkout -b dev-tev-production origin/dev-tev-production
####2. Update the provisioning scripts
Once you have a local copy, you can make changes to the provisioning scripts. Make sure to keep your changes tidy and formatted with comments in the same style as the other declarations.
Once you're done, commit with a useful commit message and push your changes.
####3. Build the VM
Next, you'll need to build the VM. Just run:
$ vagrant up
as normal, which will create and provision the machine. This will of course take a while. Once the VM is ready, SSH (with vagrant ssh) in and make sure your changes are working as desired (important!).
####4. Compress the VM
Once the VM has been provisioned, SSH into it and run the following commands to reduce its size as much as possible:
# Clear up aptitude
$ sudo apt-get clean
# "zero out" the drive (can take a while)
$ sudo dd if=/dev/zero of=/EMPTY bs=1M
$ sudo rm -f /EMPTY
# Remove bash history
$ cat /dev/null > ~/.bash_history && history -c
####5. Build a box file
Once the VM has been compressed, you can build a box file from. exit the VM if you haven't already, and run:
$ vagrant package --output dev-tev-production.box
Note: The box name doesn't actually matter here, but I tend to just name it to match the branch for sanity.
####6. Upload the new box version
Finally, you'll need to upload the updated box file to Hashicorp so that it becomes available for everybody to download. To do this:
- Login to Hashicorp and go to the Vagrant page
- Click on the name of the box you want to update, then click 'New Version' on the left
- Enter a new box version number (additions to the box typically are a new minor version e.g
1.2.0->1.3.0) and some notes on what's changed, then click 'Create Version' - On the next screen, click 'Create new provider' and select 'Virtualbox' from the list. Check the 'upload' radio and upload the box file you created in the previous step. This may take a bit of time. Once the upload is complete, click 'Finish'
- You'll see your new box version on the listing screen. Click the 'unreleased' link then 'Release version' to release your box
That's it! Developers will now be notified of the new box version when they next bring their VM up.
###Thanks and useful links