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

複数サービスを運用しやすい理想のコンテナ環境をVPS上に構築する #camphor_day / Building ideal container environment on VPS

複数サービスを運用しやすい理想のコンテナ環境をVPS上に構築する #camphor_day / Building ideal container environment on VPS

CAMPHOR- DAY 2020 ( #camphor_day )の登壇スライドです。

個人開発におけるバックエンドシステムのデプロイ先として、VPSはコスト面から今でも最有力候補の1つです。しかし、複数のサービスを1つのVPSで運用する良い方法があまり知られていないという問題があります。私はDocker ContextsとGitHub Actionsを使って複雑性の少ないコンテナ運用環境を構築しました。このトークでは、それに至るまでの考えであったり、実際に構築したアーキテクチャを紹介したいと思います。

ぷらす

March 29, 2020
Tweet

More Decks by ぷらす

Other Decks in Programming

Transcript

  1. ෳ਺αʔϏεΛӡ༻͠΍͍͢
    ཧ૝ͷίϯςφ؀ڥΛ
    714্ʹߏங͢Δ
    $".1)03 %":
    /BPLJ,JTIJ !QBTT


    View full-size slide

  2. 714Λ࢖ͬͨझຯ։ൃͰޮ཰ྑ͘
    ΞϓϦέʔγϣϯΛӡ༻͍ͯ͘͠؀ڥΛߏங͢Δ
    ࠓ೔ͷ໨ඪ

    View full-size slide

  3. ର৅
    ˔ ݸਓ։ൃΛ͍ͯ͠Δਓ
    ˔ 714ͷӡ༻ํ๏ʹ೰ΜͰ͍Δਓ
    ର৅͡Όͳ͍ਓ
    ˔ େن໛ͳαʔϏεΛ։ൃ͍ͯ͠Δਓ
    ˔ ݎ࿚ͳγεςϜΛ࡞Γ͍ͨਓ

    View full-size slide

  4. ࣗݾ঺հ

    ؛ ௚ً
    ژେ޻ֶ෦ిి ৽#
    $".1)03 ظ୅ද
    αʔόαΠυ
    όΠτͰ(PΛॻ͍͍ͯΔ
    ΀Β͢ QBTT

    View full-size slide

  5. "HFOEB

    ⁞ ཧ૝ͷίϯςφӡ༻ͱ͸ʁ
      ӡ༻ํ๏ͷݕ౼
    ⁠ (JU)VC"DUJPOTͱ૊Έ߹ΘͤͨܧଓతσϓϩΠ
    ⁡ (SBGBOB-PLJΛ༻͍ͨϩά؂ࢹ
    ⁢ ࠓޙͷ՝୊ɾ·ͱΊ

    View full-size slide

  6. લఏ %PDLFS
    ˔ ϩʔΧϧͱຊ൪؀ڥͷࠩҟ͕গͳ͍
    ˓ ͦͷ··ຊ൪؀ڥʹ͖͍࣋ͬͯͨ
    ˔ ϛυϧ΢ΣΞͷಋೖָ͕
    ˓ .Z42-
    ˓ 3FEJT
    ˓ /HJOY
    ˔ 714؀ڥΛԚͨ͘͠ͳ͍
    ˓ ґଘϥΠϒϥϦΛZVNJOTUBMMͨ͘͠ͳ͍

    View full-size slide

  7. લఏ झຯ։ൃ

    ਓ։ൃ
    খ͍͞ϓϩμΫτ͕ෳ਺

    View full-size slide

  8. ٘ਜ਼ʹͯ͠Α͍΋ͷ

    ֦ுੑ Մ༻ੑ ৑௕ੑ

    View full-size slide

  9. ཧ૝ͷӡ༻ͱ͸ʁ ʙͭͷΩʔϫʔυʙ

    ࣗಈԽ γϯϓϧ ϩΪϯά

    View full-size slide

  10. ࣗಈԽ
    ࠓ·ͰखಈͰ44)ͯ͠σϓϩΠ͍ͯͨ͠
    ˔ ߴ଎ͳΠςϨʔγϣϯΛճͮ͠Β͍
    ˔ ώϡʔϚϯΤϥʔΛى͜͠΍͍͢
    ˔ ਺೥ؒ์ஔ͍ͯͨ͠αʔϏεͷσϓϩΠํ๏͕෼͔Βͳ͘ͳΔ!

    σϓϩΠ͸ίʔυΛ༻͍ͯࣗಈԽ
    個人開発だと往々にして
    ドキュメントが未整備

    View full-size slide

  11. γϯϓϧ
    714ʹΠϯετʔϧ͞Ε͍ͯΔ΋ͷ͕೺ѲͰ͖ͳ͍
    ˔ σϓϩΠ࣌ʹΠϯετʔϧͨ͠ґଘϥΠϒϥϦ
    ෳࡶͳϛυϧ΢ΣΞΛΠϯετʔϧͨ͘͠ͳ͍
    ˔ ෳࡶ 㲈ߴػೳ ˠٻΊ͍ͯͳ͍
    ˔ ͦ΋ͦ΋εϖοΫෆ଍ͷՄೳੑ
    ˔ ֶशɾӡ༻ίετ

    ௚઀Πϯετʔϧ͢Δ΋ͷ͸࠷খݶɺγϯϓϧ΋ͷΛ࢖
    ͏

    View full-size slide

  12. ϩΪϯά
    όάൃੜ࣌ʹຖճ44)ͯ͠ϩάΛUBJM͍ͯ͠Δ
    ˔ ͔ͤͬ͘σϓϩΠΛࣗಈԽͨ͠ͷʹ
    ˔ ͔͠΋ϩάΛݟΔස౓͸ߴ͍

    ϩάΛू໿ͯ͠ϒϥ΢β͔ΒݟΕΔΑ͏ʹ

    View full-size slide

  13. ཧ૝ͷӡ༻ͱ͸ʁ ʙͭͷΩʔϫʔυʙ ʢ࠶ܝʣ

    ࣗಈԽ γϯϓϧ ϩΪϯά

    View full-size slide

  14. "HFOEB

    ᶃ ཧ૝ͷίϯςφӡ༻ͱ͸ʁ
      ӡ༻ํ๏ͷݕ౼
    ⁠ (JU)VC"DUJPOTͱ૊Έ߹ΘͤͨܧଓతσϓϩΠ
    ⁡ (SBGBOB-PLJΛ༻͍ͨϩά؂ࢹ
    ⁢ ࠓޙͷల๬ɾ·ͱΊ

    View full-size slide

  15. ༷ʑͳํ๏
    ˔ ,VCFSOFUFT
    ˔ 4XBSN
    ˔ %PDLFS$PNQPTF
    ࣗಈԽͱγϯϓϧͷ؍఺͔Β୳͢

    View full-size slide

  16. ,VCFSOFUFT
    ίϯςφΦʔέετϨʔλͷσϑΝΫτελϯμʔυ
    $POT
    ˔ εέʔϦϯά΍৴པੑ͸ෆඞཁ
    ˔ γϯϓϧͰ͸ͳ͍
    (,&Ͱ8FCαʔϏεΛӡ༻͕ͨ͠ݸਓͰ΍ΔϨϕϧͰ͸ͳ͍

    View full-size slide

  17. 4XBSN
    %PDLFSʹରԠ͢ΔΫϥελϦϯά༻πʔϧ
    ಛ௃
    ˔ %PDLFS"1*Ͱૢ࡞Մೳ
    ˔ %PDLFS$PNQPTFͱޓ׵ੑ
    1SPT
    ˔ ,VCFSOFUFTΑΓ͸γϯϓϧɺඞཁͳػೳ͸ଗ͍ͬͯΔ
    $POT
    ˔ ΫϥελϦϯάػೳ͸ෆඞཁʢϚωʔδϟ͕༨ܭʣ

    View full-size slide

  18. %PDLFS$PNQPTF
    ෳ਺ͷίϯςφߏ੒ΛZBNMΛ༻͍ͯ؅ཧͰ͖Δπʔϧ
    1SPT
    ˔ ࢖͍͍ͨػೳ͕ଗ͍ͬͯΔ
    ˔ ֶशίετ͕௿͍
    ˔ ֎෦͔Βૢ࡞Ͱ͖Δ

    View full-size slide

  19. %PDLFS%BFNPO
    %PDLFS͸ΫϥΠΞϯτɾαʔόϞσϧΛ࠾༻

    IUUQTEPDTEPDLFSDPNFOHJOFEPDLFSPWFSWJFXEPDLFSFOHJOF

    View full-size slide

  20. %0$,&3@)045
    %PDLFS%BFNPO΁ͷΞΫηε͢Δෳ਺ͷखஈ
    ˔ 6/*9%PNBJO4PDLFUʢσϑΥϧτʣ
    ˔ 44)
    ˔ 5$1

    IUUQTEPDTEPDLFSDPNFOHJOFEPDLFSPWFSWJFXEPDLFSFOHJOF

    View full-size slide

  21. %PDLFS$POUFYUT
    )PTUͷ੾Γସ͕͑Ͱ͖ΔίϚϯυ

    EPDLFSDPOUFYUDSFBUFSFNPUFEPDLFSlIPTUTTIVTFS!SFNPUFNBDIJOFz
    EPDLFSDPOUFYUMT
    /".&%&4$3*15*0/%0$,&3&/%10*/5,6#&3/&5&4&/%10*/503$)&453"503
    EFGBVMU$VSSFOU%0$,&3@)045ʜVOJYWBSSVOEPDLFSTPDLTXBSN
    SFNPUFTTIVTFS!SFNPUFNBDIJOF
    EPDLFSDPOUFYUSFNPUFQTϗετΛࢦఆͯ͠ίϚϯυΛ࣮ߦ
    EPDLFSDPOUFYUVTFSFNPUF σϑΥϧτΛઃఆ
    IUUQTXXXEPDLFSDPNCMPHIPXUPEFQMPZPOSFNPUFEPDLFSIPTUTXJUIEPDLFSDPNQPTF

    View full-size slide

  22. %PDLFS$PNQPTFͷ$POUFYUTରԠ
    ࠓ·ͰରԠ͍ͯ͠ͳ͔͕ͬͨSD൛Ͱαϙʔτ͞Ε࢝Ίͨʂ

    IUUQTHJUIVCDPNEPDLFSDPNQPTFSFMFBTFTUBHSD

    View full-size slide

  23. ϦϞʔτ؀ڥʹίϯςφΛཱͯΔ
    EPDLFSDPNQPTFDPOUFYUSFNPUFVQE

    View full-size slide

  24. ͦͷଞͷϝϦοτ

    %PDLFS3FHJTUSZ͕ෆཁ
    $*͔ΒͷσϓϩΠ͕༰қ

    View full-size slide

  25. %PDLFS$PNQPTF͕ྑͦ͞͏
    ͜͜·Ͱͷ·ͱΊ

    View full-size slide

  26. "HFOEB

    ᶃ ཧ૝ͷίϯςφӡ༻ͱ͸ʁ
    ᶄ ӡ༻ํ๏ͷݕ౼
    ⁠ (JU)VC"DUJPOTͱ૊Έ߹ΘͤͨܧଓతσϓϩΠ
    ⁡ (SBGBOB-PLJΛ༻͍ͨϩά؂ࢹ
    ⁢ ࠓޙͷ՝୊ɾ·ͱΊ

    View full-size slide

  27. (JU)VC"DUJPOT
    (JU)VCެࣜͷ$*$%πʔϧ
    ಛ௃
    ˔ (JU)VCͱͷ࿈ܞͷ͠΍͢͞
    ˔ ଞͷਓ͕࡞੒ͨ͠"DUJPOTΛ࢖͏͜ͱ͕Ͱ͖Δ
    ˔ ൿಗ৘ใͷ؅ཧ͕Ͱ͖Δ
    ˔ QSJWBUFSFQPͰ΋෼ϲ݄ແྉ

    View full-size slide

  28. σϓϩΠϑϩʔ
    ࠷৽ͷ%PDLFS$PNQPTFΛΠϯετʔϧ
    44)ݤͷ४උ
    44)ܦ༝ͰEPDLFSDPNQPTFVQ

    View full-size slide

  29. 44)ݤͷ४උ
    TIJNBUBSPTTILFZBDUJPOΛ࢖༻

    OBNF*OTUBMM44)LFZ
    VTFTTIJNBUBSPTTILFZBDUJPO!W
    XJUI
    QSJWBUFLFZ\\TFDSFUT44)@,&:^^
    QVCMJDLFZ\\TFDSFUT44)@,&:@16#-*$^^
    OBNFJE@STB
    LOPXOIPTUT\\TFDSFUT,/08/@)0454^^

    View full-size slide

  30. EPDLFSDPNQPTFVQͰσϓϩΠ

    OBNF4FUEPDLFSDPOUFYU
    SVOc
    EPDLFSDPOUFYUDSFBUFEFGBVMUTUBDLPSDIFTUSBUPSTXBSNEPDLFS
    IPTUTTI\44)@64&3/".&^!\44)@*1^\44)@1035^SFNPUF
    FOW
    44)@64&3/".&VTFSOBNF
    44)@*1
    44)@1035
    OBNF%FQMPZ
    SVOc
    EPDLFSDPNQPTFDPOUFYUSFNPUFTUPQ
    EPDLFSDPNQPTFDPOUFYUSFNPUFVQCVJMEE

    View full-size slide

  31. ྑ͞ΈϙΠϯτ
    ˔ ൿಗ৘ใΛ714্ʹஔ͘ඞཁ͕ͳ͍
    ˔ 714ʹιʔείʔυΛDMPOF͢Δඞཁ͕ͳ͍

    View full-size slide

  32. ΞʔΩςΫνϟਤ

    714
    EPDLFSDPNQPTFVQ
    (JU)VC
    "DUJPOT
    %PDLFS಺

    View full-size slide

  33. "HFOEB

    ᶃ ཧ૝ͷίϯςφӡ༻ͱ͸ʁ
    ᶄ ӡ༻ํ๏ͷݕ౼
    ᶅ (JU)VC"DUJPOTͱ૊Έ߹ΘͤͨܧଓతσϓϩΠ
    ⁡ (SBGBOB-PLJΛ༻͍ͨϩά؂ࢹ
    ⁢ ࠓޙͷ՝୊ɾ·ͱΊ

    View full-size slide

  34. ٻΊ͍ͯΔ΋ͷ
    ϩάΛू໿͠ɺϒϥ΢β͔ΒΫΤϦΛൃߦͯ͠ݟΔ

    View full-size slide

  35. ͍͔ͭ͘ͷํ๏
    ˔ &MBTUJDTFBSDI'MVFOUE,JCBOB
    ˔ (SBGBOB(SBGBOB-PLJ

    ࠓճ͸ͪ͜ΒΛ࠾༻
    IUUQTHJUIVCDPNHSBGBOBMPLJCMPCNBTUFSEPDTPWFSWJFXDPNQBSJTPOTNE

    View full-size slide

  36. (SBGBOB
    044ͷϞχλϦϯάɾՄࢹԽγεςϜ

    IUUQTHSBGBOBDPN

    View full-size slide

  37. (SBGBOB-PLJ
    (SBGBOB-BCT͕࡞͍ͬͯΔϩάऩूγεςϜ
    ಛ௃
    ˔ ϩάͷશମʹΠϯσοΫεΛషΒͣɺϥϕϧΛࣄલʹ෇͚ͯݕࡧ͢Δ
    ˔ -PH2-ͱ͍͏ΫΤϦݴޠͰΫΤϦΛ࣮ߦ
    ˔ (SBGBOBͰՄࢹԽ͕༰қ

    View full-size slide

  38. -PLJ%PDLFS-PHHJOH%SJWFS
    %PDLFSQMVHJOͱͯ͠-PLJ༻ͷ%SJWFS͕४උ͞Ε͍ͯΔ

    EPDLFSQMVHJOJOTUBMMHSBGBOBMPLJEPDLFSESJWFSMBUFTUBMJBTMPLJHSBOUBMMQFSNJTTJPOT
    TVEPWJNFUDEPDLFSEBFNPOKTPO
    \
    EFCVH USVF
    MPHESJWFSMPLJ
    MPHPQUT\
    MPLJVSMIUUQMPDBMIPTUBQJQSPNQVTI
    MPLJCBUDITJ[F
    ^
    ^

    View full-size slide

  39. ϩάΛݟΔྲྀΕ
    -PHHJOH%SJWFSΛ௨ͯ͡-PLJʹૹ৴
    (SBGBOBΛ௨ͯ͡ΫΤϦΛൃߦ͢Δ

    -PLJ%PDLFS
    -PHHJOH%SJWFS

    View full-size slide

  40. ΫΤϦΛ࣮ߦ͍ͯ͠Δ༷ࢠ

    ΫΤϦ
    ϩά

    View full-size slide

  41. ΞʔΩςΫνϟਤ

    714
    EPDLFSDPNQPTFVQ
    (JU)VC
    "DUJPOT
    %PDLFS಺
    -PLJ%PDLFS
    -PHHJOH%SJWFS

    View full-size slide

  42. ΞʔΩςΫνϟਤ ʢݱࡏʣ

    714
    EPDLFSDPNQPTFVQ
    (JU)VC
    "DUJPOT
    %PDLFS಺
    -PLJ%PDLFS
    -PHHJOH%SJWFS
    TZT
    QSPD
    %PDLFSNFUSJDT

    View full-size slide

  43. "HFOEB

    ᶃ ཧ૝ͷίϯςφӡ༻ͱ͸ʁ
    ᶄ ӡ༻ํ๏ͷݕ౼
    ᶅ (JU)VC"DUJPOTͱ૊Έ߹ΘͤͨܧଓతσϓϩΠ
    ᶆ (SBGBOB-PLJΛ༻͍ͨϩά؂ࢹ
    ⁢ ࠓޙͷ՝୊ɾ·ͱΊ

    View full-size slide

  44. ࠓޙͷ՝୊
    ˔ ϘϦϡʔϜͷόοΫΞοϓ
    ˓ .Z42-ͳͲͷεςʔτϑϧͳίϯςφΛఆظόοΫΞοϓ͍ͨ͠
    ˔ DSPOδϣϒͷ؅ཧ
    ˓ (JU)VC"DUJPOTͷDSPOͰίϯςφΛىಈ͢Ε͹ྑͦ͞͏

    View full-size slide

  45. ·ͱΊ
    㾎 ࣗಈԽɾγϯϓϧɾϩΪϯά
    㾎 %PDLFS$PNQPTFͱ(JU)VC"DUJPOTΛ࢖ͬͨσϓϩΠ
    㾎 (SBGBOB-PLJΛ࢖ͬͨϩάऩू
    Έͳ͞Μ΋շదͳ714ӡ༻Λ࢝Ί·͠ΐ͏ʂ

    View full-size slide