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

【オンラインハンズオン】Docker+LandoでCMS環境を構築してみよう #Drupal #CNDT2022

【オンラインハンズオン】Docker+LandoでCMS環境を構築してみよう #Drupal #CNDT2022

More Decks by アクイアジャパン Acquia Japan

Other Decks in Programming

Transcript

  1. ʲΦϯϥΠϯϋϯζΦϯʳ Docker + LandoͰ CMS؀ڥΛߏஙͯ͠ΈΑ͏ ΞΫΠΞδϟύϯ

  2. ຊ΢ΣϏφʔͰ͸࣭໰͕ՄೳͰ͢ɻ νϟοτ΋͘͠͸Q&AͷϘλϯΑΓ͓ؾܰʹ͓دͤͩ͘͞ ͍ɻ ࢿྉɾಈը͸ޙ೔ڞ༗͠·͢ɻ ࠷ޙʹΞϯέʔτ͕දࣔ͞Ε·͢ɻ ΢ΣϏφʔ඼࣭޲্ͷͨΊʹͥͻ͝ڠྗ͓ئ͍͠·͢ɻ ຊϋϯζΦϯ΢ΣϏφʔʹ͍ͭͯ

  3. – ࣗ෼ͷϚγϯʹDrupalͷΑ͏ͳLAMP؀ڥΛDockerίϯςφͰى ಈͰ͖ΔΑ͏ʹͳΔ – Landoͷجຊతͳૢ࡞ํ๏͕ཧղͰ͖Δ ຊ೔ͷΰʔϧ

  4. ඞཁͳ༧උ஌ࣝ – λʔϛφϧͷίϚϯυϥΠϯૢ࡞ʹ͋Δఔ౓׳Ε͍ͯΔํ͕ର৅ ࣄલ४උ – LandoͱDocker DesktopΛࣄલʹΠϯετʔϧ͓ͯ͘͠ ϋϯζΦϯ͝ࢀՃͷલʹ

  5. 1. Lando΍DockerɺDrupalʹؔ͢Δجૅ஌ࣝ 2. ʲϋϯζΦϯᶃʳLandoΛ࢖ͬͯCMS؀ڥΛߏஙͯ͠ΈΑ͏ 3. ʲϋϯζΦϯᶄʳ؀ڥม਺Λ௥Ճ͠Α͏ 4. ʲϋϯζΦϯᶅʳϝʔϧαʔόʔΛ௥Ճ͠Α͏ 5. ʲϋϯζΦϯᶆʳVS

    CodeͰXdebugΛ࢖༻͠Α͏ 6. ·ͱΊ ຊ೔ͷΞδΣϯμ
  6. Lando΍Dockerɺ Drupalʹؔ͢Δ جૅ஌ࣝ

  7. Dockerͱ͸ – ίϯςφܕԾ૝Խٕज़Λ࣮ݱ͢Διϑτ΢ΣΞ – DockerࣾʹΑͬͯ։ൃ – VMʹΑΔԾ૝ԽͱҟͳΓίϯςφʹΑΔԾ૝Խ͸ɺϦιʔεফඅ ͕গͳ͘ࡁΉ(ܰྔ)ɺϙʔλϏϦςΟੑʹ༏Ε͍ͯΔ(Մൖੑ)ͳͲ ͷϝϦοτ͕͋Δ

  8. Landoͱ͸ – Lando͸ɺΦʔϓϯιʔε੡ͷΫϩεϓϥο τϑΥʔϜͷϩʔΧϧ։ൃ؀ڥߏஙπʔϧ – Linux, Windows, MacOSͰར༻Մೳ – ϓϩδΣΫτ։ൃʹඞཁͳ؀ڥΛDocker্

    ʹల։
  9. Drupalք۾Ͱ͸Α͘ར༻͞Ε͍ͯ·͢ DrupalͷϩʔΧϧ։ൃʹؔ͢Δௐࠪ(2020೥౓)

  10. ͳͥLandoͷΑ͏ͳ΋ͷ͕ඞཁʁ dockerfile΍docker composeͰ௚઀ߦ͏ΑΓ΋؆୯ʹ؀ڥΛ্ཱͪ͛ΒΕΔʂ – ϓϩΩγɺURLɺωοτϫʔΩϯάɺϑΝΠϧڞ༗ɺίϯςφ͝ͱͷSSL ূ໌ॻͷॲཧͳͲɺWeb։ൃͰҰൠతʹඞཁͳઃఆΛࣗ෼Ͱఆٛ͠ͳ͘ ͯ΋ྑ͘ͳΔ – ಛఆͷ։ൃϢʔεέʔεʢDrupalɺPythonɺLaravelͳͲʣΛຬͨ͢αʔ ϏεͱπʔϧͷҰൠతͳ૊Έ߹ΘͤΛʮϨγϐʯ͔Β؆୯ʹηοτΞο

    ϓͰ͖Δ – ઃఆ͸YAMLϑΝΠϧͰࣗ༝ʹΧελϚΠζՄೳ ※͋͘·Ͱ؆୯ʹDockerίϯςφΛىಈͰ͖Δ΋ͷͳͷͰɺLandoͷഎޙʹ͋ΔDocker΍ίϯς φͷجૅ஌ࣝ΋ඞཁͰ͢ɻ .lando.yml ϑΝΠϧͷྫ
  11. Landoͷओͳૢ࡞ – lando initɿର࿩తʹઃఆϑΝΠϧ(.lando.yml)Λ࡞੒͢Δɻ – lando infoɿίϯςφͷ৘ใΛऔಘ͢Δɻ – lando startɿίϯςφΛىಈ͢Δɻ

    – lando stopɿίϯςφΛఀࢭ͢Δɻ – lando rebuildɿίϯςφΛ࠶ߏங͢Δɻ.lando.ymlϑΝΠϧΛฤूͨ͠ࡍʹɺ͜ͷίϚϯυΛ࣮ߦ ͢Δ͜ͱͰϑΝΠϧ಺༰Λίϯςφ؀ڥʹ൓өͰ͖Δɻ – lando sshɿίϯςφͷγΣϧʹΞΫηε͢Δɻະࢦఆͷ৔߹ɺσϑΥϧτͰΞϓϦέʔγϣϯ αʔόʔʹΞΫηε͢Δ͕ɺ-sΦϓγϣϯͰαʔϏε໊Λࢦఆͯ͠ΞΫηεͰ͖Δɻ – lando drushɿίϯςφͷΞϓϦέʔγϣϯαʔόʔ಺ͰdrushίϚϯυΛ࣮ߦ͢ΔɻComposerͰ drushΛΠϯετʔϧͨ͠৔߹ʹ࢖༻Ͱ͖Δɻ
  12. ࢀߟ) Drupalͱ͸ – 2001೥ʹ஀ੜͨ͠ɺΦʔϓϯιʔεͷCMS(ίϯςϯπ؅ཧγεςϜ) – LAMP(Linux, Apache, MySQL, PHP)Ͱಈ࡞͢Δ –

    ݱࡏ(2022೥11݄)ͷ࠷৽ϝδϟʔόʔδϣϯ͸ʮ9ʯ – 2022೥12݄ʹDrupal 10ϦϦʔε༧ఆʂ – Symfonyίϯϙʔωϯτͷ׆༻΍ΦϒδΣΫτࢦ޲ϓϩάϥϛϯά ΁ͷରԠ – ComposerʹΑΔύοέʔδґଘ؅ཧ – ϔουϨεCMSͷରԠ
  13. ࢀߟ) ΞΫΠΞͱDrupal ΞΫΠΞ͸ɺDrupalͷੜΈͷ਌Ͱ͋Δ 
 υϦεɾόΠλϧτ͕૑ۀͨ͠اۀ – Redhat͕LinuxΛࢿຊతʹࢧԉ͢ΔΑ͏ʹɺ 
 ΞΫΠΞ͕DrupalΛࢿຊతʹࢧԉ –

    ΤϯλʔϓϥΠζͰ΋҆৺ͯ͠DrupalΛѻ͑ΔΑ͏ʹ DrupalͷϗεςΟϯάͱ༗ঈαϙʔτΛఏڙ – Drupal։ൃʹίϛοτ͢ΔΤϯδχΞΛ࠾༻ – ੈքͰ།ҰɺDrupalೝఆࢼݧΛఏڙ
  14. ʲϋϯζΦϯᶃʳ LandoΛ࢖ͬͯCMS؀ ڥΛߏஙͯ͠ΈΑ͏

  15. ϋϯζΦϯͷྲྀΕ LandoͰDrupalϩʔΧϧ։ൃ؀ڥΛ্ཱͪ͛Α͏ 1. LandoͷઃఆϑΝΠϧͷ࡞੒ 2. ΞϓϦέʔγϣϯͷىಈ 3. DrupalϓϩδΣΫτͷ࡞੒ 4. DrupalͷॳظΠϯετʔϧ

  16. 1. LandoͷઃఆϑΝΠϧͷ࡞੒ ϓϩδΣΫτσΟϨΫτϦΛ࡞੒ͯ͠Ҡಈ͓͖ͯ͠·͢ɻ ϓϩδΣΫτσΟϨΫτϦԼͰlando initίϚϯυΛ࣮ߦͯ͠ɺLandoͷઃఆϑΝΠϧ(.lando.yml)Λ༻ҙ͠·͢ɻ $ mkdir my-d9app && cd

    my-d9app $ lando init ίʔυϕʔεͷ৔ॴΛฉ͔Ε͍ͯΔͷͰɺݱࡏͷ࡞ۀσΟϨΫτϦΛબ୒͠·͢ɻ ? From where should we get your app's codebase? current working directory drupal9ϨγϐΛબ୒͠·͢ɻ ? What recipe do you want to use? drupal9 υΩϡϝϯτϧʔτͷσΟϨΫτϦΛࢦఆ͠·͢ɻ ? Where is your webroot relative to the init destination? web ࠓճىಈ͢ΔLandoΞϓϦέʔγϣϯͷ໊લΛࢦఆ͠·͢ɻ ? What do you want to call this app? my-drupal9-app ର࿩͕ऴྃ͢Δͱɺϓϩ δΣΫτσΟϨΫτϦ௚ Լʹ .lando.ymlϑΝΠϧ͕ ੜ੒͞Ε·͢ɻ
  17. $ lando start …লུ NAME my-drupal9-app LOCATION /Users/hikarumaruyama/src/localonly/my-d9app SERVICES appserver,

    database APPSERVER URLS <https://localhost:55611> <http://localhost:55610> <http://my-drupal9-app.lndo.site/> <https://my-drupal9-app.lndo.site/> 2. ΞϓϦέʔγϣϯͷىಈ lando startίϚϯυͰDockerίϯςφΛىಈ͠·͢ɻ ΞϓϦέʔγϣϯ αʔόʔͱσʔλϕʔ ε͕ىಈ͠·ͨ͠ʂ
  18. 3. DrupalϓϩδΣΫτͷ࡞੒ ComposerίϚϯυͷ಄ʹlandoΛ෇͚ͯɺDrupalϓϩδΣΫτΛ࡞੒͢ΔίϚϯ υΛ࣮ߦ͠·͢ɻcomposerίϚϯυ͸landoͰىಈͨ͠ΞϓϦέʔγϣϯαʔ όʔ಺Ͱ࣮ߦ͞ΕΔͷͰɺϩʔΧϧ؀ڥʹcomposerΛೖΕΔඞཁ͸͋Γ·ͤΜɻ $ lando composer create-project drupal/recommended-project

    tmp && cp -r tmp/. . && rm -rf tmp ϓϩδΣΫτσΟϨΫ τϦ௚ԼʹɺDrupal ͷίʔυϕʔε͕ల։ ͞Ε·͢ʂ
  19. 4. DrupalͷॳظΠϯετʔϧ ϒϥ΢βͰ http://my-drupal9- app.lndo.site ʹΞΫηε͢Δ ͱɺର࿩తʹDrupalͷॳظΠ ϯετʔϧ͕ߦ͑·͢ɻ σʔλϕʔεͷ઀ଓઌ৘ใ͸ lando

    infoίϚϯυͰ֬ೝͰ͖ ·͢ɻ
  20. ϋϯζΦϯͷྲྀΕ LandoͰDrupalϩʔΧϧ։ൃ؀ڥΛ্ཱͪ͛Α͏ 1. LandoͷઃఆϑΝΠϧͷ࡞੒ 2. ΞϓϦέʔγϣϯͷىಈ 3. DrupalϓϩδΣΫτͷ࡞੒ 4. DrupalͷॳظΠϯετʔϧ

  21. ʲϋϯζΦϯᶄʳ ؀ڥม਺Λ௥Ճ͠Α͏

  22. ϋϯζΦϯͷྲྀΕ ىಈͨ͠Landoͷ؀ڥʹ؀ڥม਺Λ௥Ճͯ͠ΈΑ͏ 1. ؀ڥม਺ϑΝΠϧͷ࡞੒ 2. .lando.ymlϑΝΠϧͷฤू 3. Lando؀ڥͷ࠶ߏங

  23. 1. ؀ڥม਺ϑΝΠϧͷ࡞੒ ϓϩδΣΫτϧʔτ௚Լʹɺ.envͱ͍͏໊લͷϑΝΠϧΛ༻ҙ͠·͢ɻʢϑΝΠϧ໊͸Կ Ͱ΋େৎ෉Ͱ͢ʣ DB_HOST=database DB_NAME=drupal9 DB_USER=drupal9 DB_PASS=drupal9 .env ϑΝΠϧ

  24. 2. .lando.ymlϑΝΠϧͷฤू .lando.ymlϑΝΠϧͷτοϓϨϕϧʹ env_file ΩʔΛ௥Ճͯ͠ɺ؀ڥม਺Λ༻ҙͨ͠ϑΝΠϧͷ໊લΛهड़͠· ͢ɻ name: my-drupal9-app recipe: drupal9

    config: webroot: web # ؀ڥม਺Ληοτ͢Δ env_file: - .env .lando.yml ϑΝΠϧ
  25. 3. Lando؀ڥͷ࠶ߏங .lando.ymlϑΝΠϧΛฤूͨ͠ޙ͸ɺඞͣ lando rebuild ίϚϯυͰ؀ڥΛ࠶ߏங͠·͢ɻ ͜ΕͰΞϓϦέʔγϣϯʹ؀ڥม਺͕ಡΈࠐ·Ε·͢ɻ $ lando rebuild

    -y $ lando ssh app$ printenv | grep DB_ DB_USER=drupal9 DB_HOST=database DB_NAME=drupal9 DB_PASS=drupal9 appαʔόʔ಺Ͱ؀ڥ ม਺ҰཡΛ࣮ࡍʹ֬ ೝͯ͠ΈΑ͏ʂ
  26. ϋϯζΦϯͷྲྀΕ ىಈͨ͠Landoͷ؀ڥʹ؀ڥม਺Λ௥Ճͯ͠ΈΑ͏ 1. ؀ڥม਺ϑΝΠϧͷ࡞੒ 2. .lando.ymlϑΝΠϧͷฤू 3. Lando؀ڥͷ࠶ߏங

  27. ʲϋϯζΦϯᶅʳ ϝʔϧαʔόʔΛ ௥Ճ͠Α͏

  28. ϋϯζΦϯͷྲྀΕ ىಈͨ͠Landoͷ؀ڥʹϝʔϧαʔόʔΛ௥Ճ͠Α͏ 1. .lando.ymlϑΝΠϧͷฤू 2. Lando؀ڥͷ࠶ߏங

  29. 1. .lando.ymlϑΝΠϧͷฤू ʮdrupal9ʯϨγϐͰ͸ɺσϑΥϧτͰΞϓϦέʔγϣϯͱσʔλϕʔεΛ༻ҙͯ͘͠Ε·͢ɻϝʔϧαʔόʔ͸ࣗ෼ Ͱ.lando.ymlϑΝΠϧʹઃఆΛهड़͢Ε͹௥ՃͰ͖·͢ɻ name: my-drupal9-app recipe: drupal9 config: webroot:

    web env_file: - .env # ϝʔϧαʔόʔΛαʔϏεͱͯ͠௥Ճ services: mailhog: type: mailhog hogfrom: - appserver .lando.yml ϑΝΠϧ
  30. 3. Lando؀ڥͷ࠶ߏங .lando.ymlϑΝΠϧΛฤूͨ͠ޙ͸ɺඞͣ lando rebuild ίϚϯυͰ؀ڥΛ࠶ߏங͠·͢ɻ ͜ΕͰϝʔϧαʔόʔ͕ར༻Ͱ͖ΔΑ͏ʹͳΓ·͢ɻlando infoίϚϯυͰϝʔϧαʔόʔͷURL͕֬ೝͰ͖· ͢ɻDrupalαΠτͰൃੜͨ͠ϝʔϧΛϝʔϧαʔόʔͰӾཡͰ͖·͢ɻ $

    lando rebuild -y ...লུ http://my-drupal9-app.lndo.site/ https://my-drupal9-app.lndo.site/ MAILHOG URLS http://localhost:62716
  31. ϋϯζΦϯͷྲྀΕ ىಈͨ͠Landoͷ؀ڥʹϝʔϧαʔόʔΛ௥Ճ͠Α͏ 1. .lando.ymlϑΝΠϧͷฤू 2. Lando؀ڥͷ࠶ߏங

  32. ʲϋϯζΦϯᶆʳ VS CodeͰXdebugΛ ࢖༻͠Α͏

  33. ϋϯζΦϯͷྲྀΕ ىಈͨ͠Landoͷ؀ڥͰXdebug͕࢖͑ΔΑ͏ʹ͠Α͏ 1. VS Code༻ͷઃఆϑΝΠϧΛ௥Ճ 2. .lando.ymlϑΝΠϧͷฤू 3. Lando؀ڥͷ࠶ߏங

  34. 1. VS Code༻ͷઃఆϑΝΠϧΛ௥Ճ ϓϩδΣΫτϧʔτ௚Լʹ .vscode σΟϨΫτϦΛ࡞੒͠ɺlaunch.jsonͱphp.iniͷ2ͭͷϑΝΠϧΛ࡞੒͠· ͢ɻ { "version": "0.2.0",

    "configurations": [ { "name": "Listen for XDebug", "type": "php", "request": "launch", "port": 9003, "log": false, "pathMappings": { "/app/": "${workspaceFolder}/", } } ] } .vscode/launch.json [PHP] ; Xdebug xdebug.max_nesting_level = 256 xdebug.show_exception_trace = 0 xdebug.collect_params = 0 xdebug.mode = debug xdebug.start_with_request = yes xdebug.client_host = ${LANDO_HOST_IP} ; xdebug.log = /tmp/xdebug.log ; Remote settings xdebug.remote_enable = 1 xdebug.remote_autostart = 1 xdebug.remote_host = ${LANDO_HOST_IP} ; xdebug.remote_connect_back = 1 ; xdebug.remote_log = /tmp/xdebug_remote.log .vscode/php.ini
  35. 2. .lando.ymlϑΝΠϧͷฤू .lando.ymlϑΝΠϧʹ࣍ͷΑ͏ʹઃఆΛ௥Ճ͠·͢ɻ name: my-drupal9-app recipe: drupal9 config: webroot: web

    xdebug: true config: php: .vscode/php.ini env_file: - .env services: mailhog: type: mailhog hogfrom: - appserver .lando.yml ϑΝΠϧ
  36. 3. Lando؀ڥͷ࠶ߏங .lando.ymlϑΝΠϧΛฤूͨ͠ޙ͸ɺඞͣ lando rebuild ίϚϯυͰ؀ڥΛ࠶ߏங͠·͢ɻ ͜ΕͰVS CodeͰXdebugΛ࢖༻͢Δ४උ͕੔͍·ͨ͠ɻVS CodeʹҠಈͯ͠ɺӈϝχϡʔͷ஬ϚʔΫ(Run and

    Debug)ͰσόοάपΓͷ੍ޚ͕ߦ͑·͢ɻ $ lando rebuild -y
  37. VS CodeͰXdebugΛ࢖༻͢Δ 2. ΫϦοΫ 1. ϒϨʔΫ 
 ϙΠϯτΛషΔ 3. σόοά

    ελʔτ
  38. LandoͰىಈͨ͠DrupalαΠτΛ࠶ಡΈࠐΈ͢Δ VS CodeͰXdebugΛ࢖༻͢Δ

  39. VS CodeͰXdebugΛ࢖༻͢Δ ϒϨʔΫϙΠϯτ Ͱࢭ·Δ ม਺͕ݟΕΔ σόοάͷ੍ޚ ৭ʑ

  40. ϋϯζΦϯͷྲྀΕ ىಈͨ͠Landoͷ؀ڥͰXdebug͕࢖͑ΔΑ͏ʹ͠Α͏ 1. VS Code༻ͷઃఆϑΝΠϧΛ௥Ճ 2. .lando.ymlϑΝΠϧͷฤू 3. Lando؀ڥͷ࠶ߏங

  41. ϋϯζΦϯ ͓ർΕ༷Ͱͨ͠ʂ

  42. ࢀߟࢿྉ – Lando ެࣜαΠτ 
 https://lando.dev/ 
 – ʲϒϩάهࣄʳDocker+LandoͰ؆୯ɺDrupalϩʔΧϧ؀ڥͷߏஙํ๏ 


    https://www.acquia.com/jp/blog/how-to-use-lando-for-building-drupal-local-environment 
 – ʲAcquia DocsʳAcquia plugin for Lando 
 https://docs.acquia.com/lando/
  43. σδλϧମݧج൫ (DXP)ͷߏஙͳΒ Acquia Cloud Platform ʮAcquia Cloud Platformʯ͸ɺ͓٬༷ͷDrupalαΠτΛӡ༻ɺαϙʔτ͢Δ؀ڥΛPaaSͱͯ͠ ఏڙ͠·͢ɻ։ൃɺεςʔδϯάɺຊ൪؀ڥͰͷσϓϩΠϝϯτϓϩηεΛαϙʔτ͢ΔηΩϡ ΞͳΠϯϑϥͱ։ൃπʔϧΛඋ͍͑ͯ·͢ɻ

  44. LandoͷAcquiaϓϥάΠϯ – LandoͷϨγϐͷҰͭʹ 
 ʮAcquiaʯ͕ొ৔ʂ – ΞΫΠΞͷΫϥ΢υ؀ڥͷ ίʔυɺσʔλϕʔεɺϑΝ ΠϧΛAcquia CLIΛ௨ͯ͡

    Lando؀ڥͱಉظͰ͖·͢ AcquiaϨγϐʹؔ͢ΔυΩϡϝϯτ(Lando)
  45. ։ൃ؀ڥ΋Ϋϥ΢υԽʂ • Docker΍ߴػೳΤσΟλ͕ձࣾͷن ఆͰೖΕΒΕͳ͍ • ηοτΞοϓʹຖճ1-2೔͔͔Δ • ։ൃ؀ڥ͕֤ਓͰҟͳΓɺ͜ΕͰ໰ ୊͕ൃੜ͍ͯ͠Δ •

    ࢧڅPCͷϚγϯϦιʔεͷރׇ Acquia Cloud IDEͰ շదͳ։ൃ؀ڥΛखʹೖΕΔ ϩʔΧϧ։ൃ؀ڥͷߏஙʹ͓͚Δ 
 ੈքڞ௨ͷ໰୊
  46. ৄ͘͠͸11/21(݄)ͷηογϣϯΛཁνΣοΫʂ 100%Ϋϥ΢υϕʔεͷ σδλϧମݧج൫(DXP)։ൃϑϩʔ ηογϣϯ࣌ؒɿ2022/11/21(݄) 16:20-17:00 ొஃऀɿΞΫΠΞδϟύϯ ؛ ढ़ฌ ˜ৄࡉɾηογϣϯొ࿥͸ͪ͜Β https://event.cloudnativedays.jp/cndt2022

  47. ࠷ޙʹ – Ξϯέʔτͷ͝ڠྗΑΖ͓͘͠ئ͍͠·͢ʂ ʢ΢ΣϏφʔऴྃޙʹURL͕ڞ༗͞Ε·͢ʣ – ࣍ճͷ΢ΣϏφʔ์ૹ͸ͪ͜Β – 12/7։࠵ ϦϦʔε௚લʂ 


    Drupal 10ʹඋ͑ΔͨΊͷΩϟονΞοϓ΢ΣϏφʔ 
 https://www.acquia.com/jp/events/webinars/drupal-10-is-coming
  48. THANK YOU