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

Docker + Jenkinsでバッチ実行 / Using Docker and Jenki...

Docker + Jenkinsでバッチ実行 / Using Docker and Jenkins execution batch

2018.4.11 社内勉強会で発表した
Batch実行環境のスライド

yutachaos

April 12, 2018
Tweet

More Decks by yutachaos

Other Decks in Technology

Transcript

  1. Batch࣮ߦͷྲྀΕ scheduled trigger (ఆظ࣮ߦ) Batch࣮ߦ༻ͷEC2 Jenkins༻ͷEC2 1. docker image pull


    (imageͷऔಘ) ECR 2. docker-compose run (batchॲཧͷ࣮ߦ) DB ,S3 ͳͲ 3. log͸CloudWatch logsʹग़ྗ
  2. Jenkins Pipelineͱ͸ • Jenkins2͔Βඪ४ར༻ग़དྷΔΑ͏ʹͳͬͨ(چpipeline plugin) • ֤Jobͷॲཧͷॱ൪΍ґଘؔ܎Λ੔ཧɾ࣮ߦ͢ΔͨΊͷػೳ • git؅ཧͯ͠ɺgit͔Β௚઀ϑΝΠϧΛಡΈग़࣮ͯ͠ߦ΋Մೳ •

    ॲཧ಺༰ΛGroovyͰॻ͘͜ͱ͕ग़དྷΔͷͰಈతͳॲཧ΋هड़ग़དྷΔ • pipelineܗࣜͰॻ͘ͱɺjobͷ಺༰͕visualize͕ग़དྷΔ(·ͩΠϚΠνͳ෦෼΋ ଟ͍͕ɺɺɺ) • doc • https://jenkins.io/doc/book/pipeline/

  3. Jenkinsfile ײ૝ • ೉͍͠ॴ • ৘ใ͕গͳ͍ͷͰֶशίετ͕͋Δ • ·ͩ৽͍͠ͷͰɺػೳͷมԽ͕ૣ͍ • ྑ͔ͬͨॴ

    • ίʔυϕʔεͰJobͷґଘੑΛॻ͚Δ • pipelineͷܗͰJobΛهࡌ͢ΔͱɺJobͷґଘੑ͕ݟ΍͍͢ • ScriptͰಈతͳparameter΋࡞੒ग़དྷΔ
  4. Docker BuildͷྲྀΕ Github Developer CircleCI ECR (Elastic Container Registry) git

    push build trigger docker push githubͷίʔυΛར༻ͯ͠ɺ
 dockerͷimageΛbuildΛߦ͏
  5. Batch࣮ߦ؀ڥͷ·ͱΊ • ೉͍͠ॴ • DockerΛར༻ͨ͠ࡍͷ؀ڥ৘ใͷ੔ཧ • 12 factors appతʹ͸؀ڥม਺ʹ੾Γग़͢ͷ͕ͩɺ؅ཧ͕େม •

    Parameter StoreΛ࢖ͬͯΈ͕ͨɺ·ͩ࢖͍ͮΒ͔ͬͨͷͰࠓճ͸அ೦͠·͠ ͨɻɻɻ • ྑ͔ͬͨॴ • DockerΛར༻ͨ͠෦෼ • ࣮ߦ؀ڥͷґଘΛ੔ཧ͠΍͘͢ͳͬͨ • Docker͑͞ೖ͍ͬͯΕ͹ɺಉ͡αʔόʔ্Ͱ৭ʑͳݴޠΛಈ͔ͤͨ • CloudWatch Logs΁ͷઃఆ͕͠΍͍͢