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

ローカル開発環境にDockerを導入した話

D8becf939cfb6d977394016667eca429?s=47 Makoto Henmi
December 23, 2017

 ローカル開発環境にDockerを導入した話

合同勉強会 in 大都会岡山 - 2017 Winter -での発表資料

D8becf939cfb6d977394016667eca429?s=128

Makoto Henmi

December 23, 2017
Tweet

Transcript

  1. ϩʔΧϧ։ൃ؀ڥʹ DockerΛಋೖͨ͠࿩ ߹ಉษڧձ in େ౎ձԬࢁ -2017 Winter- ҳݟ੣(@mako_wis)

  2. ࣗݾ঺հ w ҳݟ੣ ΁ΜΈ·͜ͱ  w 5XJUUFS!NBLP@XJT w גࣜձࣾΫϨΦϑʔΨʢԻૉࡐൢചɺ ԻָίϯςεταΠτӡӦʣ

    w ϑϩϯταʔόʔαΠυ৘γε
  3. None
  4. αʔϏεΠϯ౰࣌ͷߏ੒ EC2(App) EC2(Batch) RDS

  5. S3 ૿͑ΔawsαʔϏε EC2(App) EC2(Batch) RDS

  6. S3 ૿͑ΔawsαʔϏε EC2(App) EC2(Batch) RDS CloudSearch

  7. S3 ૿͑ΔawsαʔϏε EC2(App) EC2(Batch) RDS CloudSearch SQS

  8. S3 ૿͑ΔawsαʔϏε EC2(App) EC2(Batch) RDS CloudSearch SQS SNS

  9. ͜͜Ͱͪΐͬͱ໰୊͕

  10. ൃੜ͍ͯͨ͠໰୊ • ֤ࣗͦΕͧΕͰઃఆͯͨ͠ͷͰൿ఻ͷλϨԽ • S3Λ։ൃ༻ʹڞ௨ͷόέοτΛݟ͍ͯͨΓ͠ ͯσʔλͷॏෳ͕ൃੜ • Ϛγϯങ͍ସ͑ͱ͔Ͱ؀ڥߏங΍Γ௚͠ͷ৔ ߹ʹ͕͔͔࣌ؒΔ

  11. ؀ڥߏங͕ϘτϧωοΫʹ

  12. ؀ڥߏஙΛ؆୯ʹͯ͠ޮ཰UP

  13. ରॲํ๏ • ϩʔΧϧʹAWS୅ସαʔϏεΛར༻ͯ͠ຊ൪ ͱಉ౳ͷ؀ڥΛߏங • ։ൃऀຖʹຊ൪ͱಉ౳ͷ؀ڥΛAWS্ʹߏங

  14. ରॲํ๏ • ϩʔΧϧʹAWS୅ସαʔϏεΛར༻ͯ͠ຊ൪ ͱಉ౳ͷ؀ڥΛߏங • ։ൃऀຖʹຊ൪ͱಉ౳ͷ؀ڥΛAWS্ʹߏங ࠓճ͸ͬͪ͜

  15. DockerͰϩʔΧϧʹ؀ڥߏங

  16. ࠓճͷํ਑ • DockerΛར༻ͯ͠ϩʔΧϧʹ։ൃ؀ڥΛߏங • खܰʹ؀ڥΛ্ཱ͍ͪ͛ͨͷͰdocker- composeͰίϯςφΛ؅ཧ • ୅ସ͑αʔϏε͕ແ͍΋ͷ͸ผ్ରࡦߟ͑Δ

  17. ϝΠϯΞϓϦ όον S3 MySQL SQSɾSNS SQSɾSNSॳظԽ

  18. S3ͷஔ͖׵͑ • MinioΛ࢖༻ • https://github.com/minio/minio • dockerΠϝʔδΛར༻ͯ͠΋ӬଓԽ͕༰қ • σΟϨΫτϦ=όέοτͱͯ͠Έͳͯ͘͠ΕΔ ͷͰόέοτ࡞੒ࡁͰ഑෍Ͱ͖Δ

  19. SQSɾSNSͷஔ͖׵͑ • Localstack • https://github.com/localstack/localstack • ֤छawsαʔϏεͷ୅ସ͑αʔϏεΛఏڙ • s3͸minioͷํ͕࢖͍΍͍͢ͷͰࠓճ͸ະ࢖༻ •

    SNS΋SQSͷ྆ํରԠͯ͘͠Ε͍ͯΔ • Ωϡʔ࡞੒͸ผ్ઃఆόονΩοΫ༻ͷΠϝʔδΛ࡞੒ͯ͠ docker-compose up࣌ʹ࣮ߦ
  20. RDSͷஔ͖׵͑ • ฐࣾMySQLͳͷͰMySQLͷdockerΠϝʔδΛ ࢖༻ • ֤ࣗೖΕ͍ͯΔMySQLΛ࢖༻͢Δख΋͋ͬͨ ͕ઃఆ΍όʔδϣϯ͕όϥͭ͘Մೳੑ΋͋Δ ͷͰ౷Ұ

  21. CloudSearchɾɾɾ • ϕʔλ൛͔ͩΒͳͷ͔୅ସ͑αʔϏε͕ΠϚΠν • ݩʑΫϥ΢υαʔνͷઃఆ͕ͳ͔ͬͨΒDB΁ͷ ݕࡧʹ੾Γସ͑ΔϩδοΫ͕͋ͬͨͷͰͦΕΛ ར༻ • ʢͦͷ͏ͪElasticSearchʹ৐Γ׵͑Δ͔΋͠Ε ͳ͍ͷͰҰ୴ஔ͍͓ͯ͘

  22. όονΞϓϦͷରԠ • όονͷDockerΠϝʔδͷ࡞੒ • DockerԽʹ൐͏ίʔυमਖ਼ • SQSʹґଘͯ͠ΔͷͰSQSͷ४උ׬ྃΛ଴ͭίʔυΛ௥Ճ • ϝΠϯΞϓϦͱಉ࣌ʹىಈ͍ͨ͠ •

    όονͷDockerϑΝΠϧΛϏϧυͯ͠ΠϝʔδΛ࡞੒͢ΔํࣜΛબ୒ • ϦϙδτϦ͕ผͳͷͰgit submoduleΛར༻ͯ͠ϝΠϯΞϓϦͷϦϙ δτϦʹ௥Ճ
  23. ϝΠϯΞϓϦͷରԠ • RailsΞϓϦέʔγϣϯ • ࠷ॳ͸DockerΛར༻ͤͣͦͷ··ىಈ͢Δ༧ఆͰ͕ͨ͠ɾɾɾ • όονଆ͔ΒϝΠϯΞϓϦͷAPIΛୟ͘ඞཁ͕͋Γ • Dockerଆ͔ΒϗετOSͷΞυϨεΛऔಘ͢Δํ๏͕OSຖʹ·ͪ· ͪ

    • ϝϯόʔͷOS͸WindowsɺMacOSࠞࡏ • ϦϙδτϦϧʔτʹDockerϑΝΠϧΛஔ͍ͯΠϝʔδϏϧυ
  24. Docker-compose up Ͱ։ൃ؀ڥ্ཱ͕͕ͪΔ

  25. ·ͱΊ • docker-compose upͰඞཁͳ։ൃ؀ڥ্ཱ͕͕ͪΔͷ͸ศར • ֤ࣗͦΕͧΕͰઃఆ͢Δख͕ؒল͚ͨ • Railsͷ֤छίϚϯυΛ࣮ߦ͢Δͷ͕໘౗ • ͍͍ͪͪdocker-compose

    run ~Λ࣮ߦ͢Δͷ͕ΊΜͲ͍͘͞ • γΣϧεΫϦϓτΛ४උͯ͠লྗԽ • DockerΠϝʔδ΍S3ϩʔΧϧԽͰPCͷ༰ྔ͕ඞཁ
  26. ͓ΘΓ