29
Cluj Napoca, Romania Meet Magento RO Using Vagrant for Magento development Alexander Turiak, @HexBrain

development for Magento Using Vagrantro.meet-magento.com/wp-content/uploads/2014/09/Using-Vagrant-for... · Meet Magento RO Using Vagrant for Magento development ... Meet Magento

Embed Size (px)

Citation preview

Page 1: development for Magento Using Vagrantro.meet-magento.com/wp-content/uploads/2014/09/Using-Vagrant-for... · Meet Magento RO Using Vagrant for Magento development ... Meet Magento

Cluj Napoca, RomaniaMeet Magento RO

Using Vagrant for Magento development

Alexander Turiak, @HexBrain

Page 2: development for Magento Using Vagrantro.meet-magento.com/wp-content/uploads/2014/09/Using-Vagrant-for... · Meet Magento RO Using Vagrant for Magento development ... Meet Magento

Cluj Napoca, RomaniaMeet Magento RO

$ whoami

- Magento developer since 2011- (Tries to be) Active in Magento community- Co-founded HexBrain in 2013

Page 3: development for Magento Using Vagrantro.meet-magento.com/wp-content/uploads/2014/09/Using-Vagrant-for... · Meet Magento RO Using Vagrant for Magento development ... Meet Magento

Cluj Napoca, RomaniaMeet Magento RO

Key points

- What is Vagrant (boxes, virtual machines, provisioners)- Why should you use Vagrant- Magento specific use cases

Page 4: development for Magento Using Vagrantro.meet-magento.com/wp-content/uploads/2014/09/Using-Vagrant-for... · Meet Magento RO Using Vagrant for Magento development ... Meet Magento

Cluj Napoca, RomaniaMeet Magento RO

What is Vagrant?

Is a tool for creating, deploying, sharing and managing virtual environments for solving development and testing tasks

Page 5: development for Magento Using Vagrantro.meet-magento.com/wp-content/uploads/2014/09/Using-Vagrant-for... · Meet Magento RO Using Vagrant for Magento development ... Meet Magento

Cluj Napoca, RomaniaMeet Magento RO

Created by Mitchell Hashimoto in 2010

A wrapper around virtualization software and configuration management software

Page 6: development for Magento Using Vagrantro.meet-magento.com/wp-content/uploads/2014/09/Using-Vagrant-for... · Meet Magento RO Using Vagrant for Magento development ... Meet Magento

Cluj Napoca, RomaniaMeet Magento RO

Page 7: development for Magento Using Vagrantro.meet-magento.com/wp-content/uploads/2014/09/Using-Vagrant-for... · Meet Magento RO Using Vagrant for Magento development ... Meet Magento

Cluj Napoca, RomaniaMeet Magento RO

Main issue it solves is “Works on my machine” providing environment consistency which can be shared same way as you share code e.g. using git

Page 8: development for Magento Using Vagrantro.meet-magento.com/wp-content/uploads/2014/09/Using-Vagrant-for... · Meet Magento RO Using Vagrant for Magento development ... Meet Magento

Cluj Napoca, RomaniaMeet Magento RO

What’s in the “box”?

Box is the Vagrant specific package format, each box is tied to a specific provider

Page 9: development for Magento Using Vagrantro.meet-magento.com/wp-content/uploads/2014/09/Using-Vagrant-for... · Meet Magento RO Using Vagrant for Magento development ... Meet Magento

Cluj Napoca, RomaniaMeet Magento RO

Providers

Out of the box Vagrant supports Virtual BoxOther providers (supported via plugins):- VMware (commercial)- AWS, Digital Ocean, Rackspace, Open Stack- Docker

Page 10: development for Magento Using Vagrantro.meet-magento.com/wp-content/uploads/2014/09/Using-Vagrant-for... · Meet Magento RO Using Vagrant for Magento development ... Meet Magento

Cluj Napoca, RomaniaMeet Magento RO

Provisioners

- Shell- Puppet- Chef- AnsibleVagrant.configure("2") do |config| config.vm.provision "shell", path: "script.sh"end

Page 11: development for Magento Using Vagrantro.meet-magento.com/wp-content/uploads/2014/09/Using-Vagrant-for... · Meet Magento RO Using Vagrant for Magento development ... Meet Magento

Cluj Napoca, RomaniaMeet Magento RO

Synced folders

- NFS- SMB- rsync

config.vm.synced_folder ".", "/vagrant", type: "rsync", rsync__exclude: ".git/"

Page 12: development for Magento Using Vagrantro.meet-magento.com/wp-content/uploads/2014/09/Using-Vagrant-for... · Meet Magento RO Using Vagrant for Magento development ... Meet Magento

Cluj Napoca, RomaniaMeet Magento RO

Quick setup

vagrant box add precise32 http://files.vagrantup.com/precise32.box vagrant init precise32 vagrant up

Page 13: development for Magento Using Vagrantro.meet-magento.com/wp-content/uploads/2014/09/Using-Vagrant-for... · Meet Magento RO Using Vagrant for Magento development ... Meet Magento

Cluj Napoca, RomaniaMeet Magento RO

PuPHPet or Puppet

PuPHPet — is a GUI configuration tool for Vagrant. It uses Puppet for packages installation and configurationhttps://puphpet.com/

Page 14: development for Magento Using Vagrantro.meet-magento.com/wp-content/uploads/2014/09/Using-Vagrant-for... · Meet Magento RO Using Vagrant for Magento development ... Meet Magento

Cluj Napoca, RomaniaMeet Magento RO

What is Puppet?

It’s a tool which allows management of software packages, their configuration and the operating system itself

Just like Vagrant it’s written in Ruby. Alternatives: Ansible (Python), Chef (Ruby)

Page 15: development for Magento Using Vagrantro.meet-magento.com/wp-content/uploads/2014/09/Using-Vagrant-for... · Meet Magento RO Using Vagrant for Magento development ... Meet Magento

Cluj Napoca, RomaniaMeet Magento RO

Vagrant & PuPHPet

How does it work?configValues = YAML.load_file("#{dir}/puphpet/config.yaml")

Page 16: development for Magento Using Vagrantro.meet-magento.com/wp-content/uploads/2014/09/Using-Vagrant-for... · Meet Magento RO Using Vagrant for Magento development ... Meet Magento

Cluj Napoca, RomaniaMeet Magento RO

PuPHPet. Have you stuck?

What to do in case it doesn’t support adding a package you need?

Page 17: development for Magento Using Vagrantro.meet-magento.com/wp-content/uploads/2014/09/Using-Vagrant-for... · Meet Magento RO Using Vagrant for Magento development ... Meet Magento

Cluj Napoca, RomaniaMeet Magento RO

This is Puppet

Page 18: development for Magento Using Vagrantro.meet-magento.com/wp-content/uploads/2014/09/Using-Vagrant-for... · Meet Magento RO Using Vagrant for Magento development ... Meet Magento

Cluj Napoca, RomaniaMeet Magento RO

Adding NodeJS

1. puphpet/puppet/Puppetfile

mod 'nodejs', :git => 'https://github.com/willdurand/puppet-nodejs.git'

2. puphpet/puppet/manifest.pp

class { 'nodejs': version => 'stable', target_dir => '/bin',}

3. vagrant provision

Page 19: development for Magento Using Vagrantro.meet-magento.com/wp-content/uploads/2014/09/Using-Vagrant-for... · Meet Magento RO Using Vagrant for Magento development ... Meet Magento

Cluj Napoca, RomaniaMeet Magento RO

Life after `vagrant up`

1. /etc/hosts2. vagrant ssh3. DB connect4. Xdebug

Page 20: development for Magento Using Vagrantro.meet-magento.com/wp-content/uploads/2014/09/Using-Vagrant-for... · Meet Magento RO Using Vagrant for Magento development ... Meet Magento

Cluj Napoca, RomaniaMeet Magento RO

What about Magento?

- n98-magerun- modman- modgit

vagrant ssh -c "cd /var/www/magento && n98-magerun.phar cache:clear"

Page 21: development for Magento Using Vagrantro.meet-magento.com/wp-content/uploads/2014/09/Using-Vagrant-for... · Meet Magento RO Using Vagrant for Magento development ... Meet Magento

Cluj Napoca, RomaniaMeet Magento RO

Testing Varnish

To test several sites for Varnish implementation it's convenient to setup a box running Varnish on separate ports and route the traffic further to web server instances

Page 22: development for Magento Using Vagrantro.meet-magento.com/wp-content/uploads/2014/09/Using-Vagrant-for... · Meet Magento RO Using Vagrant for Magento development ... Meet Magento

Cluj Napoca, RomaniaMeet Magento RO

Magento 2

There is a box built by Rolando Granadino most commonly known as @beeplogic https://github.com/rgranadino/mage2_vagrant which allows to quickly install Magento 2 with all it dependencies along with sample data ported by Marius Strajeru from Magento 1

Page 23: development for Magento Using Vagrantro.meet-magento.com/wp-content/uploads/2014/09/Using-Vagrant-for... · Meet Magento RO Using Vagrant for Magento development ... Meet Magento

Cluj Napoca, RomaniaMeet Magento RO

Docker

It uses feature of Linux systems called containers allowing to spawn resources like file system, memory etc. of host machine to build separate isolated services ultimately having complex cloud like infrastructures locally

Page 24: development for Magento Using Vagrantro.meet-magento.com/wp-content/uploads/2014/09/Using-Vagrant-for... · Meet Magento RO Using Vagrant for Magento development ... Meet Magento

Cluj Napoca, RomaniaMeet Magento RO

Released in 2013 by Solomon Hykes, allows deploying applications into isolated containers

Frequently used with lightweight CoreOS based on Linux kernel

Page 25: development for Magento Using Vagrantro.meet-magento.com/wp-content/uploads/2014/09/Using-Vagrant-for... · Meet Magento RO Using Vagrant for Magento development ... Meet Magento

Cluj Napoca, RomaniaMeet Magento RO

Vagrant + Docker

http://docs.vagrantup.com/v2/provisioning/docker.html

Allows to use power of Vagrant with efficiency of Docker

Page 27: development for Magento Using Vagrantro.meet-magento.com/wp-content/uploads/2014/09/Using-Vagrant-for... · Meet Magento RO Using Vagrant for Magento development ... Meet Magento

Cluj Napoca, RomaniaMeet Magento RO

Pros and cons

+ Configuration flexibility+ Portability+ Setup and reconfiguration speed+ Testing code with different versions of software (PHP 5.4, 5.5, 5.6, HHVM)

- Overhead- Disk space for each virtual machine (2-5 GB)

Page 28: development for Magento Using Vagrantro.meet-magento.com/wp-content/uploads/2014/09/Using-Vagrant-for... · Meet Magento RO Using Vagrant for Magento development ... Meet Magento

Cluj Napoca, RomaniaMeet Magento RO

Links

http://vagrantup.com/http://vagrantcloud.com/http://puppetlabs.com/http://puphpet.com/http://docker.io/

Page 29: development for Magento Using Vagrantro.meet-magento.com/wp-content/uploads/2014/09/Using-Vagrant-for... · Meet Magento RO Using Vagrant for Magento development ... Meet Magento

Cluj Napoca, RomaniaMeet Magento RO

Thank you for attention!

Mulțumesc!