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

DockerとJenkinsを使った開発速度と品質の向上 / docker and jenkins

DockerとJenkinsを使った開発速度と品質の向上 / docker and jenkins

【ヒカ☆ラボ】有名サービス開発エンジニア登壇のLT大会(https://hikalab-kansai.connpass.com/event/104702/) #ヒカラボ関西 に登壇しました。
WeblioでのDockerとJenkinsの開発実践例です。

Masashi Hirano

October 27, 2018
Tweet

More Decks by Masashi Hirano

Other Decks in Programming

Transcript

  1. %PDLFSجຊ $MJFOU 3FHJTUSZ EPDLFSIVC EPDLFSCVJME EPDLFSQVMM EPDLFSSVO %PDLFS)PTU %PDLFS%BFNPO $OUBJOFS

    *NBHF ड͚औͬͨίϚϯυΛݩʹ EPDLFSΠϝʔδΛ࡞ͬͨΓɺ EPDLFSίϯςφΛىಈͨ͠Γɺ EPDLFSΠϝʔδΛऔಘͨ͠Γ
  2. %PDLFSجຊ $MJFOU %PDLFS)PTU %PDLFS%BFNPO $OUBJOFS *NBHF EPDLFSCVJME EPDLFSQVMM EPDLFSSVO 3FHJTUSZ

    EPDLFSIVC EPDLFSΠϝʔδͷ഑෍΍؅ཧΛ͢Δ Ұൠެ։޲͚ʹ͸%PDLFS)VC͕͋Δ
  3. %PDLFSجຊ $MJFOU %PDLFS)PTU %PDLFS%BFNPO 3FHJTUSZ EPDLFSIVC $OUBJOFS *NBHF EPDLFSCVJME EPDLFSQVMM

    EPDLFSSVO %PDLFSʹࢦࣔ͢Δਓɺ ΠϝʔδɺίϯςφΛ࡞Δਓɺ Πϝʔδͷ഑෍΍؅ཧΛ͢Δਓ͕͍Δ
  4. '30.VCVOUV $01:pMFT 36/USVFa  BQUVQEBUFpYNJTTJOHa  CBTIWBSTDSJQUTQSFJOTUBMMTIa  BQUJOTUBMMZa 

     NBOTDSFFODSPOTVEPCBTIDPNQMFUJPOa   OHJOYa  ͦͷଞॾʑ a  BQUDMFBOa  CBTIWBSTDSJQUTQPTUJOTUBMMTIa  USVF &/53:10*/5<CJOCBTI WBSTDSJQUTPOCPPUTI> %PDLFSpMFྫ 04ͷΠϝʔδΛQVMM
  5. '30.VCVOUV $01:pMFT 36/USVFa  BQUVQEBUFpYNJTTJOHa  CBTIWBSTDSJQUTQSFJOTUBMMTIa  BQUJOTUBMMZa 

     NBOTDSFFODSPOTVEPCBTIDPNQMFUJPOa   OHJOYa  ͦͷଞॾʑ a  BQUDMFBOa  CBTIWBSTDSJQUTQPTUJOTUBMMTIa  USVF &/53:10*/5<CJOCBTI WBSTDSJQUTPOCPPUTI> %PDLFSpMFྫ 04ͷΠϝʔδΛQVMM ඞཁͳઃఆϑΝΠϧͳͲΛίϐʔ
  6. '30.VCVOUV $01:pMFT 36/USVFa  BQUVQEBUFpYNJTTJOHa  CBTIWBSTDSJQUTQSFJOTUBMMTIa  BQUJOTUBMMZa 

     NBOTDSFFODSPOTVEPCBTIDPNQMFUJPOa   OHJOYa  ͦͷଞॾʑ a  BQUDMFBOa  CBTIWBSTDSJQUTQPTUJOTUBMMTIa  USVF &/53:10*/5<CJOCBTI WBSTDSJQUTPOCPPUTI> %PDLFSpMFྫ 04ͷΠϝʔδΛQVMM ඞཁͳઃఆϑΝΠϧͳͲΛίϐʔ ύοέʔδΠϯετʔϧʹඞཁͳॲཧ
  7. '30.VCVOUV $01:pMFT 36/USVFa  BQUVQEBUFpYNJTTJOHa  CBTIWBSTDSJQUTQSFJOTUBMMTIa  BQUJOTUBMMZa 

     NBOTDSFFODSPOTVEPCBTIDPNQMFUJPOa   OHJOYa  ͦͷଞॾʑ a  BQUDMFBOa  CBTIWBSTDSJQUTQPTUJOTUBMMTIa  USVF &/53:10*/5<CJOCBTI WBSTDSJQUTPOCPPUTI> %PDLFSpMFྫ 04ͷΠϝʔδΛQVMM ඞཁͳઃఆϑΝΠϧͳͲΛίϐʔ ඞཁͳύοέʔδΛΠϯετʔϧ ύοέʔδΠϯετʔϧʹඞཁͳॲཧ
  8. '30.VCVOUV $01:pMFT 36/USVFa  BQUVQEBUFpYNJTTJOHa  CBTIWBSTDSJQUTQSFJOTUBMMTIa  BQUJOTUBMMZa 

     NBOTDSFFODSPOTVEPCBTIDPNQMFUJPOa   OHJOYa  ͦͷଞॾʑ a  BQUDMFBOa  CBTIWBSTDSJQUTQPTUJOTUBMMTIa  USVF &/53:10*/5<CJOCBTI WBSTDSJQUTPOCPPUTI> %PDLFSpMFྫ 04ͷΠϝʔδΛQVMM ඞཁͳઃఆϑΝΠϧͳͲΛίϐʔ ඞཁͳύοέʔδΛΠϯετʔϧ ύοέʔδΛ࢖ͬͨޙॲཧ ύοέʔδΠϯετʔϧʹඞཁͳॲཧ
  9. '30.VCVOUV $01:pMFT 36/USVFa  BQUVQEBUFpYNJTTJOHa  CBTIWBSTDSJQUTQSFJOTUBMMTIa  BQUJOTUBMMZa 

     NBOTDSFFODSPOTVEPCBTIDPNQMFUJPOa   OHJOYa  ͦͷଞॾʑ a  BQUDMFBOa  CBTIWBSTDSJQUTQPTUJOTUBMMTIa  USVF &/53:10*/5<CJOCBTI WBSTDSJQUTPOCPPUTI> %PDLFSpMFྫ 04ͷΠϝʔδΛQVMM ඞཁͳઃఆϑΝΠϧͳͲΛίϐʔ ඞཁͳύοέʔδΛΠϯετʔϧ ύοέʔδΛ࢖ͬͨޙॲཧ αʔϏεىಈ ύοέʔδΠϯετʔϧʹඞཁͳॲཧ
  10. '30.VCVOUV $01:pMFT 36/USVFa  BQUVQEBUFpYNJTTJOHa  CBTIWBSTDSJQUTQSFJOTUBMMTIa  BQUJOTUBMMZa 

     NBOTDSFFODSPOTVEPCBTIDPNQMFUJPOa   OHJOYa  ͦͷଞॾʑ a  BQUDMFBOa  CBTIWBSTDSJQUTQPTUJOTUBMMTIa  USVF &/53:10*/5<CJOCBTI WBSTDSJQUTPOCPPUTI> %PDLFSpMFྫ 04ͷΠϝʔδΛQVMM ඞཁͳઃఆϑΝΠϧͳͲΛίϐʔ ඞཁͳύοέʔδΛΠϯετʔϧ ύοέʔδΛ࢖ͬͨޙॲཧ αʔϏεىಈ ύοέʔδͷϦϙδτϦͷొ࿥ͳͲ ߏஙखॱ͕໌֬ʹΘ͔Δ
  11. '30.VCVOUV $01:pMFT 36/USVFa  BQUVQEBUFpYNJTTJOHa  CBTIWBSTDSJQUTQSFJOTUBMMTIa  BQUJOTUBMMZa 

     NBOTDSFFODSPOTVEPCBTIDPNQMFUJPOa   OHJOYa  ͦͷଞॾʑ a  BQUDMFBOa  CBTIWBSTDSJQUTQPTUJOTUBMMTIa  USVF &/53:10*/5<CJOCBTI WBSTDSJQUTPOCPPUTI> %PDLFSpMFྫ 04ͷΠϝʔδΛQVMM ඞཁͳઃఆϑΝΠϧͳͲΛίϐʔ ඞཁͳύοέʔδΛΠϯετʔϧ ύοέʔδΛ࢖ͬͨޙॲཧ αʔϏεىಈ ύοέʔδͷϦϙδτϦͷొ࿥ͳͲ ͔͠͠Ϗϧυʹ͕͔͔࣌ؒΔ
  12. version: "2" services: local_develop: hostname: “local_develop” container_name: "develop_container" image: “dockerrepo:5000/service_name“

    ports: - "80:80" - "443:443" volumes: - "./:/var/user/service" tty: true 1SJWBUFϦϙδτϦ͔Β1VMM EPDLFSDPNQPTFZNM಺Ͱ QSJWBUFϦϙδτϦʹ͋ΔΠϝʔδΛࢦఆ
  13. #!/bin/bash IMAGE_NAME=“some_docker_image” REMOTE_IMAGE_NAME="dockerrepo:5000/$IMAGE_NAME" docker build --pull -t $IMAGE_NAME . docker

    tag $IMAGE_NAME $REMOTE_IMAGE_NAME docker push $REMOTE_IMAGE_NAME %PDLFSΠϝʔδͷϏϧυͱ1VTIΛߦ͏TIFMM
  14. %PDLFSΠϝʔδίϯςφҰׅ࡟আํ๏ docker stop $(docker ps -q) docker rm $(docker ps

    -q -a) docker rmi $(docker images -q) શίϯςφΛఀࢭ શίϯςφΛ࡟আ શΠϝʔδΛ࡟আ
  15. version: "2" services: local_develop: hostname: “local_develop” container_name: "develop_container" image: “dockerrepo:5000/service_name“

    restart: “always“ ports: - "80:80" - "443:443" volumes: - "./:/var/user/service" tty: true ίϯςφͷࣗಈىಈํ๏ EPDLFSDPNQPTFʹ SFTUBSUlBMXBZTzΛ௥Ճ͢Δ
  16. +FOLJOTͱ͸ w $*޲͚ͷࣗಈԽιϑτ w 044 w +BWB w ΦϯϓϨͰಈ͔͢͜ͱ͕Ͱ͖Δ w

    ։ൃऀ͸೔ຊਓɻ઒ޱߞհ͞Μ w ଞͷ$*αʔϏεʹ͸5SBWJT$*΍$JSDMF$*ͳͲ͕͋Δ
  17. 3VO+PC 4MBWF 3VO+PC ɾUFTU
 ɾMJOU
 ɾCVJME 'FFECBDL 'FFECBDL 'FFECBDL 3VO

    .BTUFS δϣϒΛड͚෇͚Δਓ δϣϒΛ࣮ߦ͢Δਓ
  18. 'FFECBDL 'FFECBDL 'FFECBDL 3VO+PC ɾUFTU
 ɾMJOU
 ɾCVJME 4MBWF 3VO+PC 3VO

    .BTUFS $*ʹ͸δϣϒΛΩοΫ͢Δਓɺ δϣϒΛड͚෇͚Δਓɺ δϣϒΛ࣮ߦ͢Δਓɺ δϣϒͷ࣮ߦʹ࢖ΘΕΔਓ͕͍Δ
  19. .FSHF %FQMPZ 3VO+PC ɾUFTU
 ɾMJOU
 ɾCVJME ௨஌4VDDFTT'BJMVSF 4FSWJDF
 3FTUBSU 4MBWF

    4FSWFS .BTUFS )PPL 3VO 'FFECBDL ·ͩऴΘΒͳ͍ɻ࣍ͷϖʔδʹଓ͘ 1VMM
  20. 5IF+PZPG$* wࣗ෼͕௚઀ؔΘΔॴʹྗΛ͍ΕΔ w ଞͷϓϩδΣΫτͷ੹೚·ͰͱΒͳ͍ wࣗ෼ָ͕ʹͳΔࣄΛߟ͑Δ w ָʹϓϩδΣΫτϦεΫͱઓ͏ʹ͸Ͳ͏ͨ͠Β͍͍͔ wࣗ෼͕࢖͍͍ͨ෺Λಋೖ͢Δ w ͨͩ͠

    wࣗ෼͕ډͳͯ͘΋େৎ෉ͳঢ়ଶΛͭ͘Δɺͭ·ΓଐਓੑΛഉআ͢Δ w खಈͰ΍͍ͬͯΔखॱΛࣗಈԽ͢Δɺͭ·Γ$*͕ͳͯ͘΋࣮ݱͰ͖ΔܗΛ࢒͓ͯ͘͠ wશ෦ࣗಈԽ͠Α͏ͱߟ͑ͳ͍ w γϯϓϧͳํ๏Ͱɺੌָ͘ʹͳΔࣄʹूத͢Δ w ෳࡶͳํ๏ͰͪΐͬͱָʹͳΔҐͳΒखಈͰ΋Α͘ͳ͍ ͬͯߟ͑Λ࣋ͭ