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

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

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

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

Other Decks in Programming

Transcript

  1. Landoͷओͳૢ࡞ – lando initɿର࿩తʹઃఆϑΝΠϧ(.lando.yml)Λ࡞੒͢Δɻ – lando infoɿίϯςφͷ৘ใΛऔಘ͢Δɻ – lando startɿίϯςφΛىಈ͢Δɻ

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

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

    ΤϯλʔϓϥΠζͰ΋҆৺ͯ͠DrupalΛѻ͑ΔΑ͏ʹ DrupalͷϗεςΟϯάͱ༗ঈαϙʔτΛఏڙ – Drupal։ൃʹίϛοτ͢ΔΤϯδχΞΛ࠾༻ – ੈքͰ།ҰɺDrupalೝఆࢼݧΛఏڙ
  4. 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ϑΝΠϧ͕ ੜ੒͞Ε·͢ɻ
  5. $ 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ίϯςφΛىಈ͠·͢ɻ ΞϓϦέʔγϣϯ αʔόʔͱσʔλϕʔ ε͕ىಈ͠·ͨ͠ʂ
  6. 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αʔόʔ಺Ͱ؀ڥ ม਺ҰཡΛ࣮ࡍʹ֬ ೝͯ͠ΈΑ͏ʂ
  7. 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
  8. 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 ϑΝΠϧ
  9. ࢀߟࢿྉ – 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/
  10. ։ൃ؀ڥ΋Ϋϥ΢υԽʂ • Docker΍ߴػೳΤσΟλ͕ձࣾͷن ఆͰೖΕΒΕͳ͍ • ηοτΞοϓʹຖճ1-2೔͔͔Δ • ։ൃ؀ڥ͕֤ਓͰҟͳΓɺ͜ΕͰ໰ ୊͕ൃੜ͍ͯ͠Δ •

    ࢧڅPCͷϚγϯϦιʔεͷރׇ Acquia Cloud IDEͰ շదͳ։ൃ؀ڥΛखʹೖΕΔ ϩʔΧϧ։ൃ؀ڥͷߏஙʹ͓͚Δ 
 ੈքڞ௨ͷ໰୊
  11. ࠷ޙʹ – Ξϯέʔτͷ͝ڠྗΑΖ͓͘͠ئ͍͠·͢ʂ ʢ΢ΣϏφʔऴྃޙʹURL͕ڞ༗͞Ε·͢ʣ – ࣍ճͷ΢ΣϏφʔ์ૹ͸ͪ͜Β – 12/7։࠵ ϦϦʔε௚લʂ 


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