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

Acquia Cloud Platform入門:CI/CDツールで開発ワークフローを自動化しよう

Acquia Cloud Platform入門:CI/CDツールで開発ワークフローを自動化しよう

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

Other Decks in Programming

Transcript

  1. Acquia Cloud Platformೖ໳ ɹΞδΣϯμ • ΞʔςΟϑΝΫτͱ͸ • Acquia Pipelinesͱ͸ •

    Acquia PipelinesΛ͸͡ΊΑ͏ • ఆٛϑΝΠϧͷղઆ • Q&A CI/CDπʔϧͰ։ൃϫʔΫϑϩʔ ΛࣗಈԽ͠Α͏
  2. Acquia Cloud Platformೖ໳΢ΣϏφʔγϦʔζ • Acquia Cloud Platform͸ɺDrupalΞϓϦέʔγϣϯΛߏஙɺ؅ ཧ͢ΔͨΊͷεέʔϥϒϧͰ҆શͳϓϥοτϑΥʔϜͰ͢ɻ 
 •

    ຊ΢ΣϏφʔγϦʔζͰ͸ɺAcquia Cloud Platform͕ͲΜͳ΋ ͷ͔ڵຯ͕͋Δํɺ͜Ε͔Β࢖͍࢝ΊΔํ޲͚ʹɺAcquia Cloud PlatformͰߦ͏DrupalΞϓϦέʔγϣϯ։ൃߏஙํ๏΍ ศརͳπʔϧͳͲΛ͝঺հ͠·͢ɻ
  3. աڈ์ૹ 1. Acquia Cloud Platformͱ͸ͳʹ͔ 2. DrupalΞϓϦέʔγϣϯ։ൃΛ࢝ΊΔ [ϩʔΧϧฤ] 3. DrupalΞϓϦέʔγϣϯ։ൃΛ࢝ΊΔ

    [Cloud IDEฤ] 4. ΞϓϦέʔγϣϯ؅ཧํ๏Λֶ΅͏ 5. Ϣʔβʔ؅ཧํ๏Λֶ΅͏ 6. ։ൃϫʔΫϑϩʔΛֶ΅͏ Acquia Cloud Platformೖ໳΢ΣϏφʔγϦʔζ
  4. ։ൃݱ৔ͱΞʔςΟϑΝΫτͷίʔυͷҧ͍ʢ̎ʣ #navbar { 
 width: 80%; 
 border: solid red

    1px; 
 float: left; 
 padding: 5px; 
 
 ul { 
 list-style-type: none; 
 } 
 li { 
 float: right; 
 a { 
 font-weight: bold; 
 color: red; 
 } 
 } 
 } #navbar { 
 width: 80%; 
 border: solid red 1px; 
 float: left; 
 padding: 5px; 
 } 
 
 #navbar ul { 
 list-style-type: none; 
 } 
 
 #navbar ul li { 
 float: right; 
 } 
 
 #navbar ul li a { 
 font-weight: bold; 
 color: red; 
 } ΞʔςΟϑΝΫτ ։ൃݱ৔
  5. ։ൃݱ৔ͱΞʔςΟϑΝΫτͷίʔυͷҧ͍ʢ̏ʣ .drush-use .git/ .gitignore .idea/ .travis.yml .vagrant/ README.md Vagrantfile blt.sh*

    box/ build/ composer.json composer.lock config/ docroot/ drush/ drush.wrapper* example.project.local.yml factory-hooks/ hooks/ patches/ project.local.yml project.yml readme/ reports/ scripts/ tests/ vendor/ .gitignore composer.json composer.lock config/ docroot/ drush/ factory-hooks/ hooks/ reports/ scripts/ vendor/ ΞʔςΟϑΝΫτ ։ൃݱ৔
  6. Acquia Pipelines ͱ͸ • ΞΫΠΞͰఏڙ͢ΔCI/CDπʔϧ • Acquia Cloud Platform, Acquia

    Cloud Site FactoryαϒεΫϦϓγϣϯͷΞυϯػೳ • Github, Bitbucketͱ࿈ܞͯ͠γʔϜϨεʹ σϓϩΠ
  7. YAMLϑΝΠϧͰϏϧυΛఆٛ version: 1.3.0 services: - mysql - php: version: 7.4

    variables: global: COMPOSER_BIN: $SOURCE_DIR/vendor/bin BLT_DIR: $SOURCE_DIR/vendor/acquia/blt events: build: steps: - setup-env: type: script script: - composer validate --no-check-all --ansi - composer install --ansi - source ${BLT_DIR}/scripts/pipelines/setup_env post-deploy: steps: - deploy: script: - pipelines-deploy pr-merged: steps: - deploy: script: - pipelines-deploy ϓϩδΣΫτσΟϨΫτϦ௚Լʹ acquia-pipelines.yaml ͱ͍͏ ໊લͰϑΝΠϧ࡞੒
  8. Acquia PipelinesΛ͸͡ΊΔલʹ֬ೝ • PipelineΛ࣮ߦ͢Δݖݶ͕෇༩͞Ε͍ͯΔ͔֬ೝ • Cloud CD؀ڥͷ༗ແ • Acquia PipelineΛ࢖༻͢Δʹ͸CD؀ڥ͕ඞཁͰ͢

    • ͝ܖ໿಺༰ʹΑͬͯ͸CD؀ڥ͕෇༩͞Ε͍ͯͳ͍͜ ͱ΋ • Coud Platformͷ؅ཧϝχϡʔʹ 
 ʮPipelineʯ͕දࣔ͞Ε͍ͯΔ͔֬ೝ • දࣔ͞Ε͍ͯΕ͹ར༻ՄೳͰ͢
  9. 1. Githubͱͷ઀ଓʢ̍ʣ • Pipelinesͱ֎෦ͷϦϙδτϦΛ઀ଓ͢Δ৔߹͸ɺ࠷ॳʹઃఆΛߦ͍·͢ɻ 
 ※ Acquia Pipelines͸Gihtub, BitbucketͷύϒϦοΫɺϓϥΠϕʔτϦϙδτϦʹରԠ͍ͯ͠·͢ɻ 


    ※ ֎෦ϦϙδτϦͱ઀ଓ͠ͳͯ͘΋PipelinesΛ࢖༻͢Δ͜ͱ͕Ͱ͖·͢ɻ • ͜͜Ͱ͸Githubʹ༻ҙͨ͠ϓϥΠϕʔτϦϙδτϦͱ઀ଓ͢Δํ๏Λ͝঺հ͠·͢ɻ
  10. 1. Githubͱͷ઀ଓʢ̏ʣ • ਅΜதͷGithubΞΠίϯͷԼͷʮConfigureʯ > ʮConnect to GithubʯΛΫϦοΫ͠·͢ɻ • Cloud

    Platform͕GithubϦϙδτϦ΁ͷΞΫηεΛߦ͏ࢫΛڐՄ͢Δ֬ೝϖʔδ͕දࣔ͞ΕΔͷͰ ʮAuthorizeʯΛΫϦοΫ͢Ε͹઀ଓ׬ྃͰ͢ɻ GitHubϦϙδτϦ΁ͷΞΫηε ΛCloud PlatformʹڐՄ͢Δͱ ઀ଓ͕׬ྃ͠·͢ɻ
  11. 2. ఆٛϑΝΠϧͷ࡞੒ʢ̍ʣ • DrupalϓϩδΣΫτͷϧʔτσΟϨΫτϦʹ acquia-pipelines.yaml ϑΝΠϧΛ࡞੒͠·͢ɻ • खಈͰ࡞੒Ͱ͖·͕͢ɺAcquia BLTͷίϚϯυ blt

    recipes:ci:pipelines:init Λ࣮ߦ͢Δͱ਽ܗϑΝΠ ϧΛ࡞ͬͯ͘ΕΔͷͰָͰ͢ɻ version: 1.2.0 services: - mysql - php: version: 7.3 variables: global: COMPOSER_BIN: $SOURCE_DIR/vendor/bin BLT_DIR: $SOURCE_DIR/vendor/acquia/blt events: build: steps: - setup-env: type: script script: - composer validate --no-check-all --ansi
  12. version: 1.2.0 services: - mysql - php: version: 7.3 variables:

    global: COMPOSER_BIN: $SOURCE_DIR/vendor/bin BLT_DIR: $SOURCE_DIR/vendor/acquia/blt ..লུ.. 2. ఆٛϑΝΠϧͷ࡞੒ʢ̎ʣ • BLTίϚϯυͰ࡞੒ͨ͠ acquia-pipelines.yaml ϑΝΠϧʹ2Օॴमਖ਼ΛՃ͑·͢ɻ • ͜ΕͰఆٛϑΝΠϧͷ࡞੒͸׬ྃͰ͢ɻ version: 1.3.0 # PipelinesόʔδϣϯΛ1.3.0ʹ services: - mysql - php: version: 7.4 # PHPόʔδϣϯΛ7.4ʹ variables: global: COMPOSER_BIN: $SOURCE_DIR/vendor/bin BLT_DIR: $SOURCE_DIR/vendor/acquia/blt ..লུ..
  13. • ࣍ͷίϚϯυͰGithubϦϙδτϦʹมߋΛϓογϡ͠·͢ɻ 
 
 
 
 
 
 
 •

    GithubϦϙδτϦʹίϛοτ͕ϓογϡ͞Εͨ͜ͱʹΑΓɺύ ΠϓϥΠϯͷϏϧυ͕։࢝͞Ε·͢ɻৄࡉΛCloud Platformͷ ؅ཧը໘͔Β֬ೝͰ͖·͢ɻ 3. δϣϒͷ࣮ߦʢ̍ʣ $ git checkout -b add-pipelines $ git add acquia-pipelines.yaml $ git commit -m “ύΠϓϥΠϯػೳͷ௥Ճ” $ git push origin add-pipelines Githubը໘ Cloud Platformը໘
  14. 3. δϣϒͷ࣮ߦʢ̎ʣ • δϣϒ͕ਖ਼ৗʹ׬ྃ͢Δͱɺ 
 pipelines-build-[BRANCHNAME] ͱ͍͏ 
 ϒϥϯν໊ͰΞʔςΟϑΝΫτΛ 


    ࣗಈతʹੜ੒͠·͢ɻ 
 ྫʣpipelines-build-pipelines-master 
 • ͜ΕʹΑΓɺΞϓϦέʔγϣϯͷ೚ҙͷEnvironmentʹରͯ͠ΞʔςΟϑΝΫτͷσϓϩΠ͕ՄೳͰ͢ɻ • ྫ͑͹Dev؀ڥʹ pipelines-build-master Λઃఆͯ͠ 
 ͓͘ͱɺmasterϒϥϯνͷϏϧυΞʔςΟϑΝΫτ 
 ͕ৗʹσϓϩΠ͞ΕΔΑ͏ʹͳΓ·͢ɻ
  15. ఆٛϑΝΠϧͱ͸ • Acquia PipelinesͷఆٛϑΝΠϧͱ͸ɺacquia-pipelines.yaml ͱ͍͏໊લͷYMLܗࣜͷ ϑΝΠϧΛࢦ͠·͢ɻ • ఆٛϑΝΠϧʹ͸ɺϏϧυΛ࣮ߦ͢ΔͨΊʹඞཁͳશͯͷ৘ใؚ͕·Ε·͢ɻ • Ϗϧυ͸60෼ޙʹλΠϜΞ΢τ͞ΕΔͨΊɺϏϧυதʹ࢖༻͢Δશͯͷεςοϓͱϓϩ

    ηε͕λΠϜΞ΢τதʹ࣮ߦ׬ྃ͢Δඞཁ͕͋Γ·͢ɻ • ϑΝΠϧ໊͸ acquia-pipelines.yaml ʹ׬શҰக͢Δඞཁ͕͋Γʢ֦ுࢠ͸yml, yamlͲͪΒ Ͱ΋ՄೳʣɺϓϩδΣΫτͷϧʔτσΟϨΫτϦʹଘࡏ͢Δඞཁ͕͋Γ·͢ɻ https://docs.acquia.com/cloud-platform/pipelines/yaml/
  16. ఆٛϑΝΠϧ͸key/valueΛهड़͢Δ͜ͱͰఆٛ͠·͢ɻ 
 ఆٛϑΝΠϧͰ࢖༻ՄೳͳΩʔΛҰ෦͝঺հ͠·͢ɻ version: 
 ඞਢɻPipelineͷόʔδϣϯΛࣔ͢ɻ࠷৽͕1.3.0ɻ services: 
 δϣϒͷ࣮ߦதʹར༻͢ΔαʔϏεΛࣔ͢ɻ variables:

    
 Ϗϧυʹඞཁͳ؀ڥม਺͕͋Δ৔߹ɺvariablesͰࢦఆɻ events: 
 ඞਢɻ͍ͭͲΜͳεΫϦϓτΛ૸ΒͤΔͷ͔Λఆٛ͢Δɻ ఆٛϑΝΠϧͷॻ͖ํ version: 1.3.0 services: - mysql - php: version: 7.4 variables: global: COMPOSER_BIN: $SOURCE_DIR/vendor/bin BLT_DIR: $SOURCE_DIR/vendor/acquia/blt events: build: steps: - setup-env: type: script script: - composer validate --no-check-all --ansi - composer install --ansi - source ${BLT_DIR}/scripts/pipelines/setup_env - validate: type: script script: - source ${BLT_DIR}/scripts/pipelines/validate - setup-app: type: script script: - source ${BLT_DIR}/scripts/pipelines/setup_app - tests:
  17. Πϕϯτͷهड़ํ๏ eventsΩʔͷதʹ͸ɺ࣍ͷΩʔΛࢦఆՄೳͰ͢ɻͦΕ ͧΕͷΩʔ಺ʹ steps: Ͱ࣮ߦ಺༰Λهड़͢Δඞཁ͕͋ Γ·͢ɻ Ωʔ ඞਢʁ આ໌ build

    Yes ϫʔΫεϖʔεΛͲͷΑ͏ʹߏங͢Δ͔Λ هड़͠·͢ɻbuildΩʔ͸ɺeventsΩʔͷத Ͱඞͣࢦఆ͢Δඞཁ͕͋Γ·͢ɻ fail-on-build No ϏϧυΠϕϯτ͕ࣦഊͨ͠ࡍʹ࣮ߦ͞Ε· ͢ɻ post-deploy No ϏϧυΠϕϯτͷޙʹ࣮ߦ͞Ε·͢ɻ pr-merged No GithubϓϧϦΫΤετ͕ϕʔεϒϥϯνʹ Ϛʔδ͞Εͨࡍʹ࣮ߦ͞Ε·͢ɻ pr-closed No GithubϓϧϦΫΤετ͕Ϛʔδ͞Εͣʹด͡ ΒΕͨࡍʹ࣮ߦ͞Ε·͢ɻ events: build: steps: - setup-env: type: script script: - composer validate --no-check-all --ansi - composer install --ansi - source ${BLT_DIR}/scripts/pipelines/setup_env - validate: type: script script: - source ${BLT_DIR}/scripts/pipelines/validate post-deploy: steps: - deploy: script: - pipelines-deploy pr-merged: steps: - deploy: script: - pipelines-deploy pr-closed: steps: - deploy:
  18. ࢖༻ՄೳͳίϚϯυ • Acquia Pipelines͸ɺఆٛϑΝΠϧͰ࢖༻ՄೳͳΧελϜίϚϯυΛ༻ҙ͍ͯ͠·͢ɻ ίϚϯυ આ໌ pipelines-artifact Node.jsΞϓϦέʔγϣϯͷΞʔςΟϑΝΫτΛϏϧυ/Ξοϓϩʔυ͠· ͢ɻ pipelines-deploy

    ࣮ߦ͞ΕͨΠϕϯτʹԠͯ͡ɺCD؀ڥΛ࡞੒ɺσϓϩΠɺ·ͨ͸࡟আ͠· ͢ɻpost-deployΠϕϯτͰ࣮ߦ͞Εͨ৔߹ɺCD؀ڥͷ࡞੒ͱΞʔςΟϑΝ ΫτͷσϓϩΠΛߦ͍·͢ɻpr-marged/pr-closedΠϕϯτͰ࣮ߦ͞Εͨ৔ ߹ɺର৅ͷCD؀ڥΛ࡟আ͠·͢ɻ pipelines_metadata Ϗϧυ࣮ߦ͔Βಘͨ৘ใΛଞͷεςοϓͰ࢖༻͢ΔͨΊʹ࢖༻͠·͢ɻ pipelines-sync-dbs Dev, StageͳͲͷ؀ڥͷσʔλϕʔεΛCD؀ڥʹಉظ͠·͢ɻpipelines- sync-dbsίϚϯυΛ࢖༻͢Δ৔߹ɺpipelines-deployίϚϯυ͕ඞਢͰ͢ɻ https://docs.acquia.com/cloud-platform/pipelines/commands/
  19. Acquia Cloud Platformೖ໳ ɹΞδΣϯμ • ΞʔςΟϑΝΫτͱ͸ • Acquia Pipelines ͱ͸

    • Acquia PipelinesΛ͸͡ΊΑ͏ • ఆٛϑΝΠϧͷղઆ • Q&A CI/CDπʔϧͰ։ൃϫʔΫϑϩʔ ΛࣗಈԽ͠Α͏