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

MicroServices and sbt-native-packager

Fda899b3499ba4d6b2dbc763b3923759?s=47 s_edward
October 24, 2018

MicroServices and sbt-native-packager

Fda899b3499ba4d6b2dbc763b3923759?s=128

s_edward

October 24, 2018
Tweet

Transcript

  1. ϚΠΫϩαʔϏεͱ TCUOBUJWFQBDLBHFS 4IJHFLJ4IPKJ

  2. ࣗݾ঺հ w ΞʔΩςΫτʢϑϦʔϥϯεʣ w 5XJUUFS!UBLFTFDUJPO w -JOLFE*OIUUQTXXXMJOLFEJODPNJOUBLFTFDUJPO

  3. ϚΠΫϩαʔϏε Πϕϯτ ιʔε Πϕϯτ ιʔε 4FSWJDF" 4FSWJDF# #PVOEFE$POUFYU #PVOEFE$POUFYU

  4. r3FBDUJWF.JDSPTZTUFNT l%PO`U#VJME.JDSPMJUITz

  5. Ϟδϡʔϧͷߏ੒ ඪ४ϥΠϒϥϦ ϥΠϒϥϦ "LLB4USFBNT౳ υϝΠϯϩδοΫ ୯Ұͷ࣮ߦϞ δϡʔϧ ෳ਺ͷ࣮ߦϞ δϡʔϧ ෳ਺ͷ࣮ߦϞ

    δϡʔϧ΍ -BNCEB
  6. όΠφϦͷ؅ཧ w ඪ४ϥΠϒϥϦ͸04ʹόϯυϧ͞Ε͍ͯͨΓɺ+BWB࣮ߦ ؀ڥ΍4DBMBϥΠϒϥϦͱ࣮ͯ͠ߦ؀ڥʹଘࡏ w "LLB4USFBNT౳ͷϥΠϒϥϦ͸.BWFO$FOUSBM΍ #JOUSBZKDFOUFS͔Βऔಘ࣮ͯ͠ߦϞδϡʔϧʹόϯυϧ w υϝΠϯϩδοΫ΍ಠࣗͷϥΠϒϥϦ͸ɺϓϥΠϕʔτϦ ϙδτϦɺ/FYVT΍"SUJGBDUPSZͷΑ͏ͳΠϯϋ΢εϦϙ

    δτϦΛར༻࣮ͯ͠ߦϞδϡʔϧʹόϯυϧ
  7. ىಈํ๏

  8. &$4ͷ৔߹ w &$4΍'BSHBUF౳ͷ%PDLFS$POUBJOFS w %PDLFSpMF͕ඞཁ w '30.ʹ͸ެࣜͷPQFOKELΛ࢖͏ w ΞϓϦέʔγϣϯͷىಈʹ͸γΣϧεΫϦϓτ͕ඞཁ

  9. &$ͷ৔߹ w &$ͷΑ͏ͳ-JOVY7. w +7.ΛΠϯετʔϧ 0QFO+%,Ҏ߱  w αʔϏεͱͯ͠ىಈͤ͞ΔͨΊͷγΣϧεΫϦϓτ͕ඞཁ w

    4ZTUFN7 TZTUFNE 6QTUBSU 
 ৄ͍͠৬ਓ͞Μʹ͓ئ͍͢Δʁ
 ద౰ʹ͙͙ͬͯεΫϦϓτॻ͍ͯ΋ɺ҆શ͔Ͳ͏͔Α͘Θ ͔Βͳ͍ɻ

  10. TCUOBUJWFQBDLBHFS w TCUϓϥάΠϯͷҰͭ w "NB[PO-JOVY౳ͷZVNΛ࢖ͬͯΠϯετʔϧ͢Δ৔߹͸ SQN 6CVOUV΍%FCJBO͸EFC  w &$4

    'BSHBUF͸ɺ%PDLFSΠϝʔδ
  11. QMVHJOTTCU addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.6") addSbtPlugin(“com.typesafe.sbt" % “sbt-native-packager" %

    “1.3.5")
  12. %PDLFS lazy val root = (project in file(".")) .enablePlugins(JavaAppPackaging, AshScriptPlugin,

    DockerPlugin) .settings( name := "example", version := "0.1.0-SNAPSHOT", scalaVersion := "2.12.6", ).settings( dockerBaseImage := "openjdk:8-jre-alpine", dockerExposedPorts := Seq(8080), mainClass in assembly := Some("com.example.HelloWorld") )
  13. EPDLFSTUBHF w UBSHFUEPDLFSTUBHFPQUʹ%PDLFSpMF͕ੜ੒͞ΕΔ w UBSHFUEPDLFSTUBHFPQUEPDLFSCJOʹΞϓϦέʔγϣ ϯΛىಈ͢ΔͨΊͷγΣϧεΫϦϓτͱόονϑΝΠϧ͕ ੜ੒͞ΕΔ w UBSHFUEPDLFSTUBHFPQUEPDLFSMJCʹΞϓϦέʔγϣ ϯͷKBSͱґଘϥΠϒϥϦͷKBS͕഑ஔ͞ΕΔ

  14. FROM openjdk:8-jre-alpine WORKDIR /opt/docker ADD --chown=daemon:daemon opt /opt EXPOSE 8080

    USER daemon ENTRYPOINT ["/opt/docker/bin/example"] CMD []
  15. EPDLFSQVCMJTI-PDBM w %PDLFSpMF͔Β%PDLFSΠϝʔδ͕Ϗϧυ͞ΕΔɻΠϝʔ δ͸ϩʔΧϧʹొ࿥͞ΕΔ w Πϝʔδͷ3&104*503:͸ɺΞϓϦέʔγϣϯ໊ ྫ FYBNQMF ɺ5"(͸ɺΞϓϦέʔγϣϯͷόʔδϣϯ ྫ

    4/"14)05
  16. &$3΁ͷొ࿥ w %PDLFS)VC΍&$3౳ͷ%PDLFSϨδετϦʹΠϝʔδΛొ࿥ w EPDLFSMPHJOͰ%PDLFSϨδετϦʹϩάΠϯ w EPDLFSUBHͰϏϧυͨ͠Πϝʔδʹ%PDLFSϨδετϦͷϦϙδ τϦ໊΍λάΛઃఆ
 
 EPDLFSUBHFYBNQMF4/"14)05FYBNQMFFYBNQMFMBUFTU

    w EPDLFSQVTIͰΠϝʔδΛొ࿥
 
 EPDLFSQVTIFYBNQMFFYBNQMFMBUFTU
  17. 31. lazy val root = (project in file(".")) .settings( name

    := "example", version := "0.1.0-SNAPSHOT", scalaVersion := "2.12.6" ) .enablePlugins(JavaServerAppPackaging, UpstartPlugin, RpmPlugin) .settings( rpmVendor := "Example", rpmLicense := Some("MIT") )
  18. w SQNʹύοέʔδϯά͢ΔͨΊʹ͸ɺSQNCVJME౳ͷί Ϛϯυ͕ඞཁɻ%PDLFSΛ࢖ͬͯύοέʔδϯά͢Δͷ͕ ָ
 
 EPDLFSSVOJUSNa
 WAQXEATSDa
 W)0.&JWZSPPUJWZa
 QJHVNFSHSPVQEPDLFSTCUEFCJBOQMVTOCJOTI
 BQUVQEBUFBQUJOTUBMMBMJFOZ


    DETSD
 TCU
  19. SQNTUBHF w SQNTUBHF͸CVJMETCUͷΦϓγϣϯ౳͕ͲͷΑ͏ʹ൓ ө͞ΕΔ͔Λ֬ೝ͍ͨ͠ͱ͖ʹ࢖༻

  20. w UBSHFUSQN41&$4ʹΞϓϦέʔγϣϯͷ41&$ϑΝΠϧ ͕ੜ੒͞ΕΔ w UBSHFUSQNUNQCVJMESPPUVTSTIBSF<OBNF>CJOʹγ ΣϧεΫϦϓτ͕ੜ੒͞ΕΔ w UBSHFUSQNUNQCVJMESPPUVTSTIBSF<OBNF>MJCʹΞϓ ϦέʔγϣϯͷKBSͱґଘϥΠϒϥϦͷKBS͕഑ஔ͞ΕΔ w

    UBSHFUSQNUNQCVJMESPPUFUDʹىಈγΣϧεΫϦϓτ΍ Φϓγϣϯઃఆ౳ͷϑΝΠϧ͕ੜ੒͞ΕΔ w UBSHFUSQNUNQCVJMESPPUWBS͕ੜ੒͞ΕΔ
  21. SQNQBDLBHF#JO w UBSHFUSQN31.4<BSDIUZQF>ʹSQNϑΝΠϧ͕ੜ੒ ͞ΕΔ w ੜ੒͞ΕͨSQNϑΝΠϧͷΠϯετʔϧ
 
 ZVNJOTUBMMZ<SQNϑΝΠϧύε>

  22. ࢀߟ w IUUQTXXXMJHIUCFOEDPNCMPHSFBDUJWF NJDSPTZTUFNTUIFFWPMVUJPOPGNJDSPTFSWJDFTBU TDBMFGSFFPSFJMMZSFQPSUCZKPOBTCPOFS w IUUQTHJUIVCDPN1JHVNFS(SPVQ w IUUQTHJUIVCDPNTCUTCUOBUJWFQBDLBHFS w

    IUUQTHJUIVCDPNTCUTCUBTTFNCMZ
  23. ·ͱΊ w TCUOBUJWFQBDLBHFΛ࢖ͬͯΞϓϦέʔγϣϯΛύοέʔ δϯά͢Δͱɺ%PDLFS 31. %&#౳ͷ੾ସ͕͑ίʔυ ͷमਖ਼ͳ͠ʹCVJMETCUͷগ͠ͷมߋͰͰ͖Δ w %PDLFSpMF΍31.ͷ41&$ϑΝΠϧɺىಈͷͨΊͷγΣ ϧεΫϦϓτͷ஌͕ࣝͳͯ͘΋%PDLFSΠϝʔδ΍31.౳

    ʹύοέʔδϯάͰ͖Δ w +7.ʹΘͨ͢Φϓγϣϯͷઃఆ΍ɺγΣϧεΫϦϓτ౳ ͷΧελϚΠζΛߦ͏͜ͱ͕Ͱ͖Δ