Improved dev workflows using Vagrant and Docker Makis Asimidis @aasimid
Improved dev workflows using Vagrant
and Docker
Makis Asimidis @aasimid
What is vagrant?
• Vagrant is a tool for building complete development environments. With an easy-to-use workflow and focus on automation, Vagrant lowers development environment setup time, increases development/production parity, and makes the "works on my machine" excuse a relic of the past.
https://www.vagrantup.com/about.html
Dev environments
• On the production system
Dev environments
• Shared development server - Local/Remote/Cloud
• Costly to buy
• Maintenance, Administration
• Developers sharing the same hardware/resources
• Tied down to specific software packages, versions
• Remote/Cloud = Network latencies
Dev environments
• Native local machine setup (e.g. WAMP)
• OS, platform, architecture, dependencies
• Package dependency mayhem
• Cannot quickly experiment by switching to different versions or packages
Does not work in production?
Does not work in production?
• We can run the exact same operating system and setup as the production boxes, on top of any other machine, be it Mac, Windows or Linux.
!
• We can install the same software / packages / versions.
!
• Everything is run in a contained sandbox and resources can be managed.
!
• We can create distributable images to share.
!
• If we run the VM’s locally, we can develop offline.
Local virtual environments
• Disadvantages
• Search for appropriate images or install OS on the VM manually
• No easy fallback in case of problems
• Not easily and most importantly programmatically reproducible
• Can be hard to learn, setup and configure
Local virtual environments
Vagrant virtual development environment
• A simple quick way to
• Bring up virtual machines with minimum requirements
• Programmatically recreate configuration
• Store vm configuration in vcs (Infrastructure as code)
• Share virtual machine settings
• Easy rollbacks
• Integration with configuration management tools (Puppet, Chef, Salt, Ansible etc.)
Questions• Won't it be slow?
• Headless Linux VMs are much less resource hungry than a fully blown Win/MacOS virtual image
• I want to use my preferred IDE
• You can. Vagrant automatically shares a folder with the host OS
• How do I transfer my code to the box?
• See above
• Where do I find, or how do I build an image
• All popular OS and apps offered as ready-made bundles
• Is this for coding only?
• NO! We can use it to test, experiment with new packages/versions and even in packaging & delivering software
• Required software (for your specific operating system):
• VirtualBox -- https://virtualbox.org/
• Vagrant -- https://vagrantup.com/
• GitBash -- https://git-scm.com/download/ (for Windows users)
Vagrant virtual development environment
$ mkdir vagrant-demo $ cd vagrant-demo/ $ vagrant init ubuntu/trusty64 $ vagrant up --provider=virtualbox $ vagrant ssh !You should see a default Ubuntu login message. You are now logged into your Vagrant VM. Enter the following: !Last login: Thu Jun 25 14:34:01 2015!vagrant@linux-p94a:~> uname -a!Linux linux-p94a 3.12.43-52.6-default #1 SMP Wed May 20 12:44:39 UTC 2015 (fc0ce!ac) x86_64 x86_64 x86_64 GNU/Linux!vagrant@linux-p94a:~>
Vagrant basic usage
VS
+
Demo
Resources• http://www.slideshare.net/ichilton/virtualized-development-
environments-phpne-may-2012
• http://www.slideshare.net/ortussolutions/vagrant-48606177
• http://www.slideshare.net/lorinh/vagrant-ansible-and-openstack-on-your-laptop
• https://eu.yourcircuit.com/#/conversation/49efedc6-b2db-4cc0-ac09-499c98fcca2d
• https://it-ebooks.info/book/5792/