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

Acquia Cloud Platform入門:Drupalアプリケーション開発を始める [ロ...

Acquia Cloud Platform入門:Drupalアプリケーション開発を始める [ローカル編]

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

Other Decks in Programming

Transcript

  1. Acquia Cloud Platformೖ໳΢ΣϏφʔγϦʔζ • Acquia Cloud Platform͸ɺDrupalΞϓϦέʔγϣϯΛߏஙɺ؅ ཧ͢ΔͨΊͷεέʔϥϒϧͰ҆શͳϓϥοτϑΥʔϜͰ͢ɻ 
 •

    ຊ΢ΣϏφʔγϦʔζͰ͸ɺAcquia Cloud Platform͕ͲΜͳ΋ ͷ͔ڵຯ͕͋Δํɺ͜Ε͔Β࢖͍࢝ΊΔํ޲͚ʹɺAcquia Cloud PlatformͰߦ͏DrupalΞϓϦέʔγϣϯ։ൃߏஙํ๏΍ ศརͳπʔϧͳͲΛ͝঺հ͠·͢ɻ
  2. Lando ͱ͸ • DrupalͰ͸༷ʑͳϩʔΧϧ։ൃ؀ڥ͕ར༻͞Ε͓ͯΓɺ Lando΋ͦͷҰͭͰ͢ • Lando͸ɺΦʔϓϯιʔε੡ͷΫϩεϓϥοτϑΥʔϜͷ ϩʔΧϧ։ൃ؀ڥߏஙπʔϧ • Linux,

    Windows, MacOSͰར༻Ͱ͖·͢ • ϓϩδΣΫτ։ൃʹඞཁͳ؀ڥΛDocker্ʹల։͠·͢ • ಛఆͷ։ൃϢʔεέʔεʢDrupalɺPythonɺLaravelͳͲʣ Λຬͨ͢αʔϏεͱπʔϧͷҰൠతͳ૊Έ߹ΘͤΛʮϨ γϐʯ͔Β؆୯ʹηοτΞοϓͰ͖·͢ 
 • ཁ͸ɾɾɾdockerfile΍docker composeͰ௚઀ߦ͏ΑΓ΋ ؆୯ʹ؀ڥΛ্ཱͪ͛ΒΕ·͢ • ϓϩΩγɺURLɺωοτϫʔΩϯάɺϑΝΠϧڞ ༗ɺίϯςφ͝ͱͷSSLূ໌ॻͷॲཧɺetc... https://www.jeffgeerling.com/blog/2020/2020-drupal-local-development-survey-results DrupalͷϩʔΧϧ։ൃʹؔ͢Δௐࠪ(2020೥౓) .lando.yml ϑΝΠϧͷྫ
  3. LandoͱΞΫΠΞͷ౷߹ • 2020೥6݄ʹAcquia Dev Desktop͕αϙʔτऴྃΛܴ ͑·ͨ͠ • ΞΫΠΞ͕ఏڙ͢Δ։ൃ؀ڥͱͯ͠ɺCloud IDE͕ొ৔ •

    Ҿ͖ଓ͖ϩʔΧϧ؀ڥͰ։ൃ͍ͨ͠ਓ޲͚ʹɺLando Λ௨ͯ͡ϩʔΧϧ։ൃͷΦϓγϣϯΛఏڙ • LandoͷϨγϐʹʮAcquiaʯ͕௥Ճ͞Ε·ͨ͠ • ΞΫΠΞ؀ڥͷίʔυɺσʔλϕʔεɺϑΝΠϧΛ Lando؀ڥͱಉظͰ͖·͢ https://docs.lando.dev/config/acquia.html#getting-started/ AcquiaϨγϐʹؔ͢ΔυΩϡϝϯτ(Lando) https://dev.acquia.com/blog/acquia-cloud-lando-integration-tale-tryst
  4. LandoͷAcquiaϨγϐ × Acquia CMSͰߏங͢Δ 
 ϩʔΧϧ։ൃ؀ڥ LandoͷAcquiaϨγϐΛ࢖༻ͯ͠ɺϩʔΧϧ؀ڥͰAcquia CMSΛىಈ͢Δํ๏Λ͝঺հ͠·͢ɻ ओͳྲྀΕΛղઆ͢ΔͨΊʹɺඞཁ࠷௿ݶͷઃఆɾखॱͰߦ͍͖ͬͯ·͢ɻ 


    1. LandoͷઃఆϑΝΠϧ(.lando.yml)ͷ࡞੒ 2. DrupalϓϩδΣΫτͷ࡞੒ 3. αΠτͷΠϯετʔϧ 4. Site Studioͷॳظઃఆ 5. Acquia CMS StarterϞδϡʔϧͷ༗ޮԽ ※Acquia CMSͰ͸Site StudioΛ࢖༻͍ͯ͠·͢ɻSite StudioͷAPIΩʔΛࣄલʹ͝༻ҙ͍ͨͩ͘ඞཁ͕͋Γ·͢ɻProfessionalϓ ϥϯͷ৔߹ɺAcquia CMSͰ͸ͳ͘ɺૉͷDrupalɺٴͼଞσΟετϦϏϡʔγϣϯΛ࢖༻͍ͨͩ͘ͱಉ͡खॱͰ࣮ߦՄೳͰ͢ɻ
  5. 1. LandoͷઃఆϑΝΠϧ(.lando.yml)ͷ࡞੒ʢ̍ʣ • ࡞ۀσΟϨΫτϦΛ༻ҙͯ͠ɺσΟϨΫτϦʹҠಈ͓͖ͯ͠·͢ 
 $ mkdir my-demo-ace-pov3 && cd

    my-demo-ace-pov3
 • lando initίϚϯυΛ࣮ߦͯ͠ɺ.lando.ymlϑΝΠϧΛੜ੒͠·͢ 
 $ lando init
 
 ͍͔ͭ͘ͷϓϩϯϓτ͕දࣔ͞Ε·͢ ? From where should we get your app's codebase?ʢίʔυϕʔεͷ৔ॴʣ 
 → current working directoryʢݱࡏͷσΟϨΫτϦʣ 
 ? What recipe do you want to use?ʢར༻͢ΔϨγϐʣ 
 → acquia 
 ? Select an Acquia Cloud Platform API tokenʢAcquia Cloud PlatformͷAPIτʔΫϯʣ 
 → xxxxxx 
 ? Which site?ʢσϓϩΠ͢Δର৅ͷAcquia Cloud PlatformͷΞϓϦέʔγϣϯʣ 
 → povjapan3ʢର৅ͷΞϓϦέʔγϣϯͷ໊લΛબ୒͍ͯͩ͘͠͞ɻ͜͜Ͱ͸Ծʹ povjapan3 ͱ͠·͢ʣ • ͜ΕͰϓϩδΣΫτσΟϨΫτϦ௚Լʹ .lando.yml ϑΝΠϧ͕ੜ੒͞Ε·ͨ͠ https://docs.lando.dev/config/acquia.html
  6. • .lando.ymlϑΝΠϧΛ2Օॴ͍͡Γ·͢ 1. LandoͷઃఆϑΝΠϧ(.lando.yml)ͷ࡞੒ʢ̎ʣ • ϓϩδΣΫτσΟϨΫτϦ௚Լʹ .env ϑΝΠϧΛ࡞੒ͯ͠ɺͦ͜ʹDBͷೝূ৘ใΛೖΕ·͢ 
 DBͷೝূ৘ใ͸

    lando info ίϚϯυͰ֬ೝͰ͖·͢ 
 ※ ͜ͷ.envϑΝΠϧ͸.gitignoreʹ๨Εͣʹ௥Ճ͓͖ͯ͠·͢ name: povjapan3 recipe: acquia config : acli_version: latest ah_application_uuid: xxxxxxxx ah_site_group: povjapan3 php: '7.4' # 1. ͜͜Λ7.3͔Β7.4ʹ # 2. ؀ڥม਺Ληοτ͢Δ env_file : - .env DB_HOST=databas e DB_NAME=acqui a DB_USER=acqui a DB_PASS=acquia
  7. • ίϚϯυϥΠϯͰ࣍ͷίϚϯυΛ࣮ߦ͠·͢ 
 ΞΫΠΞ͕ఏڙ͢Δ acquia/drupal-recommended-project ͰdrupalϓϩδΣΫτΛ࡞੒͠·͢ 
 
 $ lando

    star t $ lando composer create-project acquia/drupal-recommended-project tmp && cp -r tmp/. . && rm -rf tm p 
 • sites/default/settings/local.settings.php ͷDBͷೝূ৘ใΛ؀ڥม਺͔Βऔͬͯ͘ΔΑ͏ʹमਖ਼͠·͢ 2. DrupalϓϩδΣΫτͷ࡞੒ $databases['default']['default'] = [ 'database' => getenv('DB_NAME') , 'username' => getenv('DB_USER') , 'password' => getenv('DB_PASS') , 'host' => getenv('DB_HOST') , 'port' => '3306' , 'driver' => 'mysql' , 'prefix' => '' , ];
  8. • Acquia CMSσΟετϦϏϡʔγϣϯ(acquia_cms)Λࢦఆͯ͠αΠτΛΠϯετʔϧ͠·͢ 
 lando drush site:install acquia_cms --yes --account-pass=admin

    [email protected] --account-name=admi n • ͜ΕͰϩʔΧϧʹAcquia CMSͰΠϯετʔϧͨ͠αΠτ͕ىಈ͢ΔͷͰɺΞΫηε͠·͢ 
 http://povjapan3.lndo.site 
 
 ※ϩʔΧϧ؀ڥͷΞϓϦέʔγϣϯURL 
 ͸ lando info ίϚϯυͰ֬ೝͰ͖·͢ 3. αΠτͷΠϯετʔϧ ίϚϯυͷΦϓγϣϯͰࢦఆͨ͠ Ϣʔβʔ໊ͱύεϫʔυͰϩάΠϯ ίϯςϯπ͸·ͩԿ΋ͳ͍ঢ়ଶͰ͢
  9. • ؅ཧը໘͔ΒɺSite StudioͷAPI KeyɺAgency KeyΛઃఆ͠·͢ 
 URLύε: /admin/cohesion/configuration/account-settings 
 


    [Save and import assets] ΛΫϦοΫͯ͠ઃఆΛ൓өͤ͞ΔͷͰ͕͢ɺ 
 Site StudioͷϏϧυʹ͍͕͔͔࣌ؒ͢͝ΔͷͰ஫ҙ͍ͯͩ͘͠͞ 
 ͜Ε͕ऴΘΔͱαΠτͰSite Studio͕ར༻Ͱ͖ΔΑ͏ʹͳΓ·͢ 4. Site Studioͷॳظઃఆ
  10. • Acquia CMSͰ͸ɺSite StudioΛ͙͢ʹ࢖͍࢝ΊΒΕΔΑ͏ʹɺςϯϓ ϨʔτͱσϞίϯςϯπ͕ηοτ͞Εͨ 
 Acquia CMS StarterϞδϡʔϧ͕༻ҙ͞Ε͍ͯΔͷͰ 


    ͔ͤͬ͘ͳͷͰ༗ޮԽ͠·͢ • ϞδϡʔϧΛ༗ޮԽ͢Δલʹɺ؅ཧϝχϡʔͷ[Tour] > [Get started]͔Β Google MapsͷAPIΩʔ͚ͩઃఆ͓͖ͯ͠·͢ 
 ͜ΕΛ͓͔ͯ͠ͳ͍ͱϞδϡʔϧ͕༗ޮԽͰ͖·ͤΜ 
 
 Google MapsͷAPIΩʔ͸࣍ͷURL͔ΒऔಘͰ͖·͢ 
 https://developers.google.com/maps/documentation/javascript/get-api-key • ؅ཧϝχϡʔͷ[Extend]͔ΒAcquia CMS StarterϞδϡʔϧΛ༗ޮԽ͠· ͢ 5. Acquia CMS StarterϞδϡʔϧͷ༗ޮԽ
  11. 1. ϦϞʔτgitϦϙδτϦͷઃఆ • ΞϓϦέʔγϣϯͷGit URL͕֬ೝͰ͖ͨΒɺίϚϯυϥΠϯ͔ΒϦϞʔτGitϦϙδτϦͱͯ͠ొ࿥͠·͢ 
 $ git remote add

    acquia [email protected]:povjapan3.git • Acquia Cloud PlatformͰ͸ΞϓϦέʔγϣϯ͝ͱʹɺίʔυϕʔεΛ؅ཧ͢ΔͨΊͷGitϦϙδτϦ͕༻ҙ͞Ε͍ͯ·͢ 
 GitϦϙδτϦͷURLΛ֬ೝ͢Δʹ͸ɺAcquia Cloud Platformͷ؅ཧը໘ʹͯɺର৅ͷΞϓϦέʔγϣϯͷը໘͔Βɺը໘ӈ্ͷ[Actions] > [View Git Information] ΛॱʹΫϦοΫ͍͖ͯ͠·͢
  12. 2. Acquia BLTͷઃఆ project : machine_name: my-demo-ace-pov 3 git :

    default_branch: master remotes : cloud: '[email protected]:povjapan3.git' • acquia/drupal-recommended-projectʹ͸Acquia BLT͕ಉࠝ͞Ε͍ͯ·͢ 
 Acquia BLTͱ͸ɺDrupalͷςετɾϏϧυɾσϓϩΠΛࣗಈԽ͢ΔͨΊͷίϚϯυϥΠϯπʔϧͰ͢ 
 ϓϩδΣΫτ௚Լͷ blt/blt.yml ϑΝΠϧΛ࣍ͷΑ͏ʹमਖ਼͠·͢
  13. • ϩʔΧϧͷίʔυϕʔεͷ಺༰ΛϦϞʔτgitϦϙδτϦʹڧ੍ϓογϡ͠·͢ 
 $ git push -f acquia master 


    ※ࣄલʹSSHΩʔͷઃఆΛߦ͏ඞཁ͕͋Γ·͢ 
 • ࣍ͷίϚϯυͰɺϏϧυΞʔςΟϑΝΫτͷ࡞੒ͱσϓϩΠΛ͓͜ͳ͍·͢ 
 ࣍ͷίϚϯυྫͰ͸ɺdevelop-build ϒϥϯνʹʮBLT-000: ίϛοτϝοηʔδʯͱ͍͏ίϛοτϝοηʔδͱڞʹɺੜ੒͞ΕͨϏϧυΞʔςΟϑΝ ΫτΛίϛοτ͍ͯ͠·͢ 
 $ vendor/bin/blt artifact:deploy --commit-msg 'BLT-000: ίϛοτϝοηʔδ' --branch 'develop-build' --no-interactio n 
 ੒ޭ͢Δͱɺ؅ཧը໘ͷ Task Log ʹ࣍ͷΑ͏ʹϩά͕දࣔ͞Ε·͢ 3. Ϋϥ΢υ؀ڥʹΞʔςΟϑΝΫτΛσϓϩΠ
  14. • LandoͷAcquiaϨγϐͰ͸ɺAcquia CLI͕σϑΥϧτͰར༻Ͱ͖ΔΑ͏ʹͳ͍ͬͯ·͢ 
 Acquia CLIΛ࢖༻ͯ͠ίϚϯυϥΠϯͰϩʔΧϧ؀ڥͷσʔλϕʔεͱϑΝΠϧ΋Ϋϥ΢υ؀ڥʹϓογϡ͠·͢ 
 
 ·ͣ͸Acquia Cloud

    PlatformΞΧ΢ϯτʹରͯ͠ೝূΛ͓͜ͳ͍·͢ 
 $ lando acli auth:logi n ࣍ͷίϚϯυͰɺLando؀ڥͷσʔλϕʔεͱϑΝΠϧΛΫϥ΢υ؀ڥʹϓογϡͰ͖·͢ 
 ίϚϯυͷୈҰҾ਺ͰɺϓογϡઌͷΞϓϦέʔγϣϯͷΤΠϦΞεΛࢦఆ͍ͯ͠·͢ $ lando acli push:database povjapan3.de v $ lando acli push:files povjapan3.dev
 
 drushίϚϯυ΋ɺlando acli remote:drush [ΤΠϦΞε] [drushίϚϯυ] ͷܗࣜͰϩʔΧϧ؀ڥ͔Β࣮ߦͰ͖·͢ 
 ࣍ͷίϚϯυͰ͸ɺ͋ΔΞϓϦέʔγϣϯͷDev؀ڥʹରͯ͠ΩϟογϡΛ࠶ߏங͠·͢ $ lando acli remote:drush povjapan3.dev cr 4. Acquia CLIͰDBɺϑΝΠϧΛίϐʔ
  15. • LandoͷAcquiaϨγϐͷ࢖͍ํ 
 https://docs.lando.dev/config/acquia.html#getting-started/ • acquia/drupal-recommended-project (github) 
 https://github.com/acquia/drupal-recommended-project •

    acquia/acquia-cms-project (github) 
 https://github.com/acquia/acquia-cms-project • Acquia CLI υΩϡϝϯτ 
 https://docs.acquia.com/acquia-cli/ • Acquia BLT υΩϡϝϯτ 
 https://docs.acquia.com/blt/ ࢀߟࢿྉ