Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Virtualização do Ambiente de Desenvolvimento com Vagrant

Virtualização do Ambiente de Desenvolvimento com Vagrant

"Lightning Talk" realizado no encontro mensal "PHPubSP" (Grupo de usuários PHP de São Paulo) - http://phpsp.org.br/2012/08/phpubsp-talks/

Mario Rezende

August 28, 2012
Tweet

Other Decks in Programming

Transcript

  1. Virtualização do Ambiente de Desenvolvimento com Vagrant Crie e configure

    ambientes leves, reproduzíveis e portáteis. http://vagrantup.com Mario Rezende http://about.me/mariorez
  2. Configuração do Ambiente de Dev Host Machine • Dependente do

    Sistema Operacional • Softwares relevantes ao Desenvolvimento • Duplicidade de Softwares ( Apache x Nginx | MySQL x Postgre ) • Dificil reproduzir Ambiente de Produção • Maior velocidade na execusão Virtual Machine • Ambiente não interfere na maquina "Host" (isolamento) • Reproduzir Ambiente de Produção com exatidão. • Varios Ambientes com configuração diferentes (Apache x Nginx / MySQL x Postgre) • Lentidão na execução
  3. Antes de tudo... • Instale VirtualBox -> http://www.virtualbox.org • Instale

    Vagrant -> http://downloads.vagrantup.com [ Ubuntu: apt-get install vagrant ]
  4. $ vagrant box add lucid32 http://files.vagrantup.com/lucid32.box Criando um Ambiente Virtual

    $ vagrant box add debian-squeeze-64 ~/my_boxes/debian-squeeze-64.box [vagrant] Downloading with Vagrant::Downloaders::File... [vagrant] Copying box to temporary location... [vagrant] Extracting box... [vagrant] Verifying box... [vagrant] Cleaning up downloaded box...
  5. $ vagrant up [default] Importing base box 'debian-squeeze-64'... [default] Matching

    MAC address for NAT networking... [default] Clearing any previously set forwarded ports... [default] Forwarding ports... [default] -- 22 => 2222 (adapter 1) [default] -- 3306 => 3309 (adapter 1) [default] -- 80 => 9090 (adapter 1) [default] Exporting NFS shared folders... [vagrant] Preparing to edit /etc/exports. Administrator privileges will be required... [sudo] password for mario: * Stopping NFS kernel daemon [ OK ] * Unexporting directories for NFS kernel daemon... [ OK ] * Exporting directories for NFS kernel daemon... [ OK ] * Starting NFS kernel daemon [ OK ] [default] Creating shared folders metadata... [default] Clearing any previously set network interfaces... [default] Preparing network interfaces based on configuration... [default] Booting VM... [default] Waiting for VM to boot. This can take a few minutes. [default] VM booted and ready for use! [default] Configuring and enabling network interfaces... [default] Mounting shared folders... [default] -- v-root: /vagrant [default] Mounting NFS shared folders... Vagrant up "levantando" o ambiente
  6. mario@deep-thought:~/Projects/test$ ls -al total 16 drwxrwxr-x 2 mario mario 4096

    Aug 28 03:00 . drwxrwxr-x 6 mario mario 4096 Aug 28 01:47 .. -rw-rw-r-- 1 mario mario 61 Aug 28 02:31 .vagrant -rw-rw-r-- 1 mario mario 306 Aug 28 02:27 Vagrantfile mario@deep-thought:~/Projects/test$ Vagrant sshacessando a VM mario@deep-thought:~/Projects/test$ vagrant ssh Linux vagrant-debian-squeeze 2.6.32-5-amd64 #1 SMP Sun May 6 04:00:17 UTC 2012 x86_64 Last login: Tue Aug 28 02:55:17 2012 from 10.0.2.2 vagrant@vagrant-debian-squeeze:~$ cd /vagrant/ vagrant@vagrant-debian-squeeze:/vagrant$ ls -al total 16 drwxrwxr-x 2 vagrant vagrant 4096 Aug 28 03:00 . drwxr-xr-x 23 root root 4096 Aug 28 02:33 .. -rw-rw-r-- 1 vagrant vagrant 61 Aug 28 02:31 .vagrant -rw-rw-r-- 1 vagrant vagrant 306 Aug 28 02:27 Vagrantfile vagrant@vagrant-debian-squeeze:/vagrant$
  7. $ vagrant package --vagrantfile Vagrantfile.pkg --include README.txt [default] Attempting graceful

    shutdown of VM... [default] Clearing any previously set forwarded ports... [default] Creating temporary directory for export... [default] Exporting VM... [default] Compressing package to: /home/mario/Projects/test/package.box [default] Packaging additional file: Vagrantfile.pkg [default] Packaging additional file: README.txt Criando Box distrubua seu ambiente mario@deep-thought:~/Projects/test$ ls -al total 467512 drwxrwxr-x 2 mario mario 4096 Aug 28 03:19 . drwxrwxr-x 6 mario mario 4096 Aug 28 01:47 .. -rw-rw-r-- 1 mario mario 478708224 Aug 28 03:20 package.box -rw-rw-r-- 1 mario mario 0 Aug 28 03:18 README.txt -rw-rw-r-- 1 mario mario 61 Aug 28 02:31 .vagrant -rw-rw-r-- 1 mario mario 306 Aug 28 02:27 Vagrantfile -rw-rw-r-- 1 mario mario 306 Aug 28 02:27 Vagrantfile.pkg
  8. VALEU !!! • Vagrant -> http://vagrantup.com • Vagrant Boxes ->

    http://www.vagrantbox.es • VirtualBox -> http://www.virtualbox.org Mario Rezende http://about.me/mariorez