$30 off During Our Annual Pro Sale. View details »

速習・Dockerと学ぶPHP / 20180310-PHPerKaigi

Ayato
March 10, 2018

速習・Dockerと学ぶPHP / 20180310-PHPerKaigi

2018年3月10日
PHPerKaigi 2018 LT資料
ココネリ練馬 にて

Ayato

March 10, 2018
Tweet

More Decks by Ayato

Other Decks in Technology

Transcript

  1. ଎श DockerͱֶͿPHP @ayato_tw 2018/03/10 PhperKaigi 2018

  2. ࡢ೔ͷલ໷ࡇ

  3. ࡢ೔ͷલ໷ࡇ > PHPerͳΒ͜ΕΒΛ֮ࣗతʹ ʮ࡞Εʯ·͢ΑͶ řŏŕ

  4. ؀ڥߏஙΛεϚϗͰྫ͑Δ 1)1͕ಈ͘
 αʔόʔ࡞ͬͯ εϚϗͰ
 5XJUUFSݟΕΔ༷ʹͯ͠ 㱺

  5. ؀ڥߏஙΛεϚϗͰྫ͑Δ 1)1͕ಈ͘
 αʔόʔ࡞ͬͯ
 
 ΋ͪΖΜ(%ͱ͔ *NBHF.BHJDLͱ͔ಈ͘ΑͶ εϚϗͰ
 5XJUUFSݟΕΔ༷ʹͯ͠ ΋ͪΖΜެࣜΞϓϦೖΕΔΑ Ͷ

  6. ؀ڥߏஙΛεϚϗͰྫ͑Δ 1)1͕ಈ͘
 αʔόʔ࡞ͬͯ
 
 ΋ͪΖΜ(%ͱ͔ *NBHF.BHJDLͱ͔ಈ͘ΑͶ 0QFO44-͡Όͳͯ͘ -JCSF44-Ͱ εϚϗͰ
 5XJUUFSݟΕΔ༷ʹͯ͠

    ΋ͪΖΜެࣜΞϓϦೖΕΔΑ Ͷ 2ஈ֊ೝূ͸SMS͡Όͳͯ͘ ΞϓϦ 㱺
  7. ͪͳΈʹձ৔Ͱ͸ 1. εϚϗͰTwitterݟͯΔਓ 2. εϚϗͰTwitterΛެࣜΞϓϦͰݟ͍ͯΔਓ 3. εϚϗͰTwitterΛެࣜΞϓϦͰݟ͍ͯͯɺ͔ ͭ2ஈ֊ೝূʹΞϓϦΛ࢖͍ͬͯΔํ

  8. ؀ڥΛ࡞Δͱޡ͕ࠩੜ·ΕΔ • ͤΊͯϨγϐ͕͋Ε͹... 㱺 Ansible, Itamae ౳ • ͱ͍͏͔(ΊΜͲ͍͠)௚઀࢖͍ճ͠ग़དྷΕ͹... 㱺

    Docker ౳
  9. DockerΛ࢖ͬͯΈΔ Vagrant౳ͷଞͷԾ૝Խٕज़͸ׂѪ

  10. Docker • ৭ΜͳॴͰศརʹ࢖͑Δ༷ʹͳ͖ͬͯͯΔ • GCP / AWS / Azure ͰਐԽ͕ܹ͍͠

    • ਎ۙͳॴͩͱ ϩʔΧϧ։ൃ؀ڥ / CircleCI 2.0 • speakerdeck.com/kunit ݟͯʂ
  11. DockerͷΠϝʔδ / ίϯςφ Πϝʔδ 㱺 ͍ΘΏΔʮzipͰ͘Εʯ ίϯςφ 㱺 ల։ޙͷϑΝΠϧ܈ (Έ͍ͨͳ΋ͷ)

    DockerHub 㱺 DockerΠϝʔδ͕ެ։͞ΕͯΔॴ ≒ GitHub
  12. DockerͷΠϝʔδ / ίϯςφ ͜ΕͰ؀ڥͷ࢖͍ճ͕͠ग़དྷΔʂ 1. hub.docker.com ͰΠϝʔδΛ୳͢ 2. ΠϝʔδΛ࣋ͬͯ͘Δ (docker

    pull) 3. ίϯςφΛىಈͯ͠࢖͏ (docker run, docker exec, …)
  13. DockerͷΠϝʔδ / ίϯςφ εϚϗͷྫ͑Ͱݴ͏ͱ 1. ళฮͰTwitterެࣜΞϓϦ౳ͷઃఆ͕ऴΘͬͨεϚϗΛ୳͢ 2. εϚϗΛങ͏ 3. ిݯΛೖΕͯ࢖͏

    ؆୯ʂɹ(ྫ͑࿩͔ͩΒళฮා͍ͱ͔ݴΘͳ͍)
  14. Dockerfile • shell script ͬΆ͍΋ͷ • Πϝʔδͷ࡞Γํ • ళฮͷઃఆϚχϡΞϧతͳ •

    ྫͱͯ͠ wordpress:4.9-php56-apache ͷ DockerΠϝʔδΛௐ΂ͯΈΔ
  15. wordpress:4.9-php56-apache • hub.docker.com/_/wordpress/ ΁ΞΫηε • 4.9-php5.6-apache λάͷ Dockerfile ΛݟͯΈΔ
 㱺

    GitHubʹ Dockerfile ͕ஔ͍ͯ͋Δ • FROM ͱ RUN ͷॴʹ஫໨
 㱺 gd / mysqli / opcache ͸ೖͬͯΔ
 㱺 WordPressຊମ΋ઃஔࡁΈ • ͋Εɺapache͸ʁ
  16. FROM ۟ΛḷΔ • FROM php:5.6-apache ͳͷͰ
 hub.docker.com/_/php/ ΁ΞΫηε • 5.6-apache

    λάΛݟΔ
 㱺 ͜Ε΋GitHubͰDockerfileΛݟͯΈΔ ...ͱ͍͏ײ͡ͰDockerfile८Γͷཱྀ͕ग़དྷ·͢ ྑ͍ઃఆ͸ਅࣅ͠Α͏ʂ(ϥΠηϯεOKͳΒ)
  17. Dockerʹڵຯ͕͋Ε͹ DockerެࣜΠϝʔδΛݟͯΈͨΓ hub.docker.com/r/library/ 
 ެࣜυΩϡϝϯτͷ೔ຊޠ༁ΛಡΜͰΈͨΓ ҎԼͷΩʔϫʔυͰάάͬͯΈͨΓ • docker-php-ext-install • docker-compose

    • ϓϥΠϕʔτϨδετϦ
  18. ࠷ޙʹ Dockerfile८ΓͷཱྀΛ͠ͳ͕Β PHPͱDockerΛಉ࣌ʹษڧͯ͠Έ·͠ΐ͏ʂ ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ