The deployment for Go

5d769d109697012317c09c6a27a6a4bf?s=47 linyows
October 04, 2018

The deployment for Go

Fukuoka.go#12 October 4, 2018 でお話しした 資料です

5d769d109697012317c09c6a27a6a4bf?s=128

linyows

October 04, 2018
Tweet

Transcript

  1. 5PNPIJTB0EB (.01FQBCP *OD 0DUPCFS  'VLVPLBHP ͜Ε͕(PΞϓϦͷσϓϩΠͩ

  2. 'VLVPLBHP (.0ϖύϘ ϓϦϯγύϧΤϯδχΞ !MJOZPXT CMPHUPNPIJTBPEBDPN

  3. 'VLVPLBHP দຊ྄հʹΑΔ࿦จʢ%*$0.0༧ߘʣਫ਼៛ʹ੍ޚՄೳͳ߃ৗੑͷ͋ΔߴूੵϚϧνΞΧ΢ϯτܕͷϝʔϧج൫ IUUQTSBOEQFQBCPDPNQBQFSTEJDPNPQSPDFFEJOHNBUTVNPUPSZQEG ࠷ۙͷ͓࢓ࣄ ओʹ'BTU$POUBJOFSʹΑΔϝʔϧج൫ݚڀ։ൃɺ࠷࣮ۙ૷ྫΛ(JU)VCͰެ։ IUUQTHJUIVCDPN'BTU$POUBJOFS

  4. 'VLVPLBHP 8&# %#13&44WPM )BTIJ$PSQ7BVMUͷهࣄدߘ ෱Ԭͷ(PMBOHίϛϡχςΟ 'VLVPLBHPͷओ࠵ͷਓ MJOVYϢʔβͷ໊લղܾΛ (JU)VC͔ΒϚοϐϯά͢Δ ιϑτ΢ΣΞͷ։ൃ

  5. 'VLVPLBHP "SFZPVEFQMPZJOH

  6. 'VLVPLBHP ๏ ϫϯόΠφϦͷσϓϩΠ໰୊Λղܾ͢Δ w IUUQTTQFBLFSEFDLDPNMJOZPXTTDBMBCMFEFQMPZNFOUUPPMUPEFQMPZPOZPVSPXO w !'VLVPLBHP w $BQJTUSBOPΛ(PΞϓϦͰ࢖͏ͷ͸ΦʔόʔΩϧײ͕͋ͬͯͲ͏ʹ͔͢Δͱ͍͏಺༰ ๏

    εέʔϥϒϧͰσϓϩΠΛҙࣝ͠ͳ͍௒ཱࣗܕσϓϩΠ w IUUQTTQFBLFSEFDLDPNMJOZPXTSFTPMWFXFCBQQMJDBUJPOEFQMPZNFOUQSPCMFNTGPSHP w !1)1$POGFSFODF'VLVPLBલ໷ࡇ3FKFDUDPO w ͜Ε·ͰͷσϓϩΠख๏Λ౿·͑ͭͭ৽͍͠σϓϩΠख๏ͷఏҊ ࠓ೥ʹೖͬͯ৽͍͠σϓϩΠख๏ʹ͍ͭͯ౓ఔൃද
  7. 'VLVPLBHP ͳͥɺ͍·Ͳ͖#MVF(SFFO͡Όͳ͍ͷ͔ʁ

  8. 'VLVPLBHP ๏ Πϯελϯε·ͨ͸ΠϝʔδΛߏ੒͢ΔΞϓϦͱͦͷ΄͔Λ෼͚ͯσϓϩΠ͢Δ ๏ Πϯελϯε·ͨ͸ΠϝʔδΛσϓϩΠͷͨΊʹมߋ͢ΔͷͰ*NNVUBCMF *OGSBTUSVDUVSFͰ͸ͳ͍ ๏ ͨͱ͑͹ɺ#MVF(SFFOσϓϩΠͰ΋੾Γସ͑લʹ͋Β͔͡ΊΞϓϦΛߋ৽͢Δ ৔߹ͳͲ ๏

    ΋ͪΖΜɺ*O1MBDFͷ৔߹΋ લఏΞϓϦͱͦͷ΄͔ΛผʹσϓϩΠ͢Δ
  9. 'VLVPLBHP "QQMJDBUJPO 04 .JEEMFXBSFʜ *OTUBODF

  10. 'VLVPLBHP ๏ फڭ্ͷཧ༝ͰΫϥ΢υ·ͨ͸ίϯςφ؀ڥΛ༻ҙͰ͖ͳ͍ ๏ ༧ࢉ͕গͳ͍ͷͰൺֱతίετΛඞཁͱ͢Δ#MVF(SFFOσϓϩΠ͕Ͱ͖ͳ͍ ๏ ϦϞʔτ͔ΒͷσϓϩΠ͸ݤͷ؅ཧ͕ඞཁʹͳΔͷͰ΍Γͨ͘ͳ͍ Α͏͢Δʹɺ͜͏͍͏ࣄ

  11. 'VLVPLBHP 1 #!/bin/bash 2 set -xe 3 4 readonly REMOTE_USER="linyows"

    5 6 function deploy () { 7 local sshc="ssh $1 -l $REMOTE_USER" 8 scp ./api.zip $REMOTE_USER@$1:/home/$REMOTE_USER 9 10 $sshc "unzip /home/$REMOTE_USER/api.zip" 11 $sshc 'sudo mv api /usr/local/bin' 12 $sshc 'sudo chown api /usr/local/bin/api' 13 $sshc 'sudo service api restart' 14 } 15 16 deploy 'api-1.example.test' 17 deploy 'api-2.example.test' 18 deploy 'api-3.example.test' ݱ৔ͷ༷ࢠͰ͢
  12. 'VLVPLBHP IUUQTHJUIVCDPNMJOZPXTEFXZ

  13. 'VLVPLBHP .VUBCMF؀ڥͰΞϓϦ͕ೳಈతʹσϓϩΠ͢Δ

  14. 'VLVPLBHP 8PSL'MPX 4UBSUTFSWFS 1VTIUPSFQP %FWFMPQ #VJME5FTU .BTUFSNFSHF 3FMFBTF 1VMMSFMFBTF 3FTUBSUTFSWFS

    "ENJO %FW %FW $* 0XOFS %FXZ %FXZ $*
  15. 'VLVPLBHP %FQMPZJOH%FNP

  16. 'VLVPLBHP %FQMPZJOH%FNP server: 1 $ export GITHUB_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx 2 $ dewy

    server \ 3 --repository linyows/dewy-testapp \ 4 --artifact dewy-testapp_darwin_amd64.tar.gz \ 5 --port 8000 \ 6 --log-level info -- \ 7 /var/www/my-app/current/my-app client: 1 $ while sleep 0.5; do curl localhost:8000; done dev: 1 $ export GITHUB_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 2 $ goreleaser --rm-dist
  17. 'VLVPLBHP ๏ )PPLܥͷ௥ՃλεΫ SFRVJSFE ๏ 1MVHJOػߏ ๏ ϩʔϧόοΫ SFRVJSFE ๏

    ΧφϦʔσϓϩΠ ๏ ෼ࢄ,74ͷରԠʢ&UDENC $POTVM,7LC ࠓޙͷ՝୊
  18. 'VLVPLBHP ๏ γεςϜن໛͕খ͍͞ͱίϯςφ؀ڥͰͳ͍͜ͱɺ#MVF(SFFO͕Ͱ͖ͳ ͍ࣄ͸Α͋͘Δ ๏ ͦͷΑ͏ͳ؀ڥͷ΋ͱɺ(PΒ͘͠ϫϯόΠφϦΛ(JUIVCSFMFBTFTʹ1045 ͢Δ͚ͩͰউखʹσϓϩΠ͞ΕΔ ๏ ͪΐͬͱͨ͠ΞϓϦέʔγϣϯͷσϓϩΠʹͪΐ͏Ͳ͍͍σϓϩΠπʔ ϧΛ࡞Γ·ͨ͠

    $PODMVTJPO
  19. 'VLVPLBHP 5IBOLZPV 8FSFIJSJOH