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

CIハンズオン@PHPカンファレンス福岡-環境構築

 CIハンズオン@PHPカンファレンス福岡-環境構築

B51ca7a51ae1fd06bc536fe83e6113e2?s=128

Kaz Watanabe

June 27, 2015
Tweet

Transcript

  1. $",&1)1ͰֶͿ ܧଓతΠϯςάϨʔγϣϯϋϯζΦϯ ؀ڥߏஙฤ @PHPΧϯϑΝϨϯε෱Ԭ 2015/6/27

  2. WHO? • Θͨͳ΂͔ͣͻΖ(@kaz_29) • ߹ಉձࣾ decr (decr.jp) • PHP(CakePHP)ͰWebΞϓϦ։ൃ •

    Πϯϑϥߏஙɾӡ༻ • iOSΞϓϦ։ൃ #beer #iosdev #cakephp #cat #camp #golf #chef #vagrant
  3. WHO?

  4. QUESTION?

  5. QUESTION? VagrantΛ࢖ͬͨࣄ͕͋Δਓ

  6. QUESTION? chefΛ࢖ͬͨࣄ͕͋Δਓ

  7. ಈ࡞؀ڥ • VirtualBox • Vagrant • chef-solo(+knife-solo) • berkshelf

  8. ಈ࡞؀ڥ ։ൃ؀ڥ EFWFMPQ $*؀ڥ DJ ຊ൪؀ڥ EFQMPZ ؀ڥઃఆ TIBSFEGPMEFS ޷͖ͳΤσΟλ*%&Ͱ։ൃ

    QVTI QVMM ·ͣ͸͜͜ͷ࿩
  9. http://bit.ly/1IBecmb ͜͜ͰςΩετΛڞ༗͠·͢

  10. ඞཁͳ΋ͷ • VitrtualBox - https://www.virtualbox.org/ • Vagrant - https://www.vagrantup.com/ •

    (ChefDK - https://downloads.getchef.com/chef-dk/) ग़དྷΔ͚ͩ࠷৽Λ࢖͏
  11. BOXFILE௥Ճ $ vagrant box add handson_develop ~/Desktop/develop.box $ vagrant box

    add handson_ci ~/Desktop/ci.box $ vagrant box add handson_deploy ~/Desktop/deploy.box ͖ͬ͞USB͔Βίϐʔͨ͠΋ͷΛ࢖͍ͬͯͩ͘͞ʂ
  12. Vagrant PluginͷΠϯετʔϧ $ vagrant plugin install vagrant-omnibus $ vagrant plugin

    install vagrant-cachier
  13. ؀ڥઃఆϦϙδτϦΛऔಘ $ git clone https://github.com/kaz29/php_ci_env phpci_handson $ git checkout -b

    handson origin/handson $ cd phpci_handson $ mkdir application $ mkdir -p application/app/webroot $ echo "<?php phpinfo();" > application/app/webroot/index.php
  14. ։ൃ༻αʔόͷىಈ $ vagrant up develop

  15. Vagrantfileͷղઆ … config.vm.define :develop do |develop| develop.omnibus.chef_version = :latest develop.vm.hostname

    = "develop" develop.vm.box = "opscode-ubuntu-14.04" develop.vm.box_url = "handson_develop.box" develop.vm.network :private_network, ip: "192.168.33.10" develop.vm.synced_folder "application", "/var/www/application/ current", id: "vagrant-root", :nfs => false, :owner => "vagrant", :group => "www-data", :mount_options => ["dmode=775,fmode=775"] …
  16. Vagrantfileͷղઆ … develop.vm.provision :chef_solo do |chef| chef.log_level = "debug" chef.cookbooks_path

    = "./cookbooks" chef.json = { nginx: { docroot: { owner: "vagrant", group: "vagrant", path: "/var/www/application/current/app/webroot", force_create: true }, default: { fastcgi_params: { CAKE_ENV: "development" } }, test: { available: true, fastcgi_params: { CAKE_ENV: "test" } } } } chef.run_list = %w[ recipe[apt] recipe[phpenv::default] recipe[phpenv::composer] recipe[phpenv::develop] recipe[capistrano] ] end …
  17. http://192.168.33.10/

  18. CIαʔόͷىಈ $ vagrant up ci

  19. http://192.168.33.100:8080/

  20. DEPLOYαʔόͷىಈ $ vagrant up deploy

  21. http://192.168.33.200/

  22. αϯϓϧΞϓϦ؀ڥͷߏங

  23. ։ൃ؀ڥ EFWFMPQ ಈ࡞؀ڥ $*؀ڥ DJ ຊ൪؀ڥ EFQMPZ ؀ڥઃఆ TIBSFEGPMEFS ޷͖ͳΤσΟλ*%&Ͱ։ൃ

    QVTI QVMM
  24. ಈ࡞؀ڥ

  25. BLOGAPPΛFORK͢Δ https://github.com/kaz29/blogapp

  26. 伴Λ࡞ͬͯొ࿥ $ vagrant ssh develop $ ssh-keygen Generating public/private rsa

    key pair. Enter file in which to save the key (/home/vagrant/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: … $ cat ~/.ssh/id_rsa.pub ެ։伴Λίϐʔ
  27. 伴Λ࡞ͬͯొ࿥ setting -> SSH Keys ͜͜ʹެ։伴ΛೖΕΔ

  28. GITͷઃఆ $ git config --global user.name "Your Name" $ git

    config --global user.email you@example.com
  29. ΞϓϦέʔγϣϯΛॳظԽ $ vagrant ssh develop $ cd /var/www/application/current $ rm

    -rf * $ git clone git://github.com/decr/blogapp.git . (<=υοτ) $ cd /var/www/application/current/app $ composer install --dev
  30. None
  31. JenkinsʹJobΛొ࿥

  32. JenkinsʹJobΛొ࿥

  33. JenkinsʹJobΛొ࿥ https://github.com/kaz29/blogapp.git

  34. JenkinsʹJobΛొ࿥ 4$.ΛϙʔϦϯάΛνΣοΫ )    ઃఆ׬ྃͨ͠Βอଘ

  35. JenkinsʹJobΛొ࿥ ϏϧυΛ࣮ߦ

  36. JenkinsʹJobΛొ࿥

  37. JenkinsʹJobΛొ࿥

  38. ؀ڥઃఆ׬ྃʂ $ vagrant halt deploy ͠͹Β͘࢖Θͳ͍ͷͰམͱ͓͖ͯ͠·͢

  39. ؀ڥߏஙฤ Fin @kaz_29