Slide 1

Slide 1 text

%PDLFSܑ̏ఋ ʙɹܑͦͯ̐͠ఋ΁ɹʙ :"1$"TJB5PLZP !UPSJUPSJ

Slide 2

Slide 2 text

1SPpMF w ௗډɹ߶࢘ʢ!UPSJUPSJʣ w גࣜձࣾ)"30J% w IUUQXXXIBSPJEDPN w αʔόαΠυΤϯδχΞ w -VB(PMBOH1ZUIPO/PEFKT1FSM3VCZ w ೋࣇͷ෕

Slide 3

Slide 3 text

ΞδΣϯμ w %PDLFSܑ̏ఋͱ͸ʁ w %PDLFSܑ̏ఋͷ͸͡Ί͔ͨ w %PDLFSܑ̏ఋͷ͝঺հ w Ϣʔεέʔε w %PDLFSܑ̏ఋΛศརʹ࢖͏ w %PDLFSܑ̏ఋͷ͜Ε͔Β w ·ͱΊ w ͓·͚ɿ%PDLFS$PNQPTFΞοϓσʔτ

Slide 4

Slide 4 text

%PDLFSܑ̏ఋͱ͸

Slide 5

Slide 5 text

%PDLFSܑఋͱ͸ w %PDLFS.BDIJOFʢ%PDLFSϗετߏஙπʔϧʣ w %PDLFS$PNQPTFʢෳ਺ίϯςφఆٛʗߏஙπʔϧʣ w %PDLFS4XBSNʢ%PDLFSΫϥελϦϯάπʔϧʣ

Slide 6

Slide 6 text

%PDLFSܑ̏ఋͷ ͸͡Ί͔ͨ

Slide 7

Slide 7 text

%PDLFS5PPMCPY

Slide 8

Slide 8 text

%PDLFS5PPMCPY w %PDLFSΫϥΠΞϯτ w %PDLFS.BDIJOF w %PDLFS$PNQPTFʢ.BDͷΈʣ w %PDLFS,JUFNBUJDʢ%PDLFSίϯςφ(6*ʣ w 7JSUVBM#PY ˞طଘͷCPPUEPDLFSϚΠάϨʔγϣϯ΋ͯ͘͠ΕΔ

Slide 9

Slide 9 text

ʢ˞LJUFNBUJDಈ࡞σϞʣ

Slide 10

Slide 10 text

%PDLFSܑ̏ఋͷ঺հ

Slide 11

Slide 11 text

˞ͷલʹॾ஫ҙ

Slide 12

Slide 12 text

ʊਓਓਓਓਓਓਓਓਓਓਓਓਓਓਓʊ ʼɹܑ̏ఋશͯϕʔλόʔδϣϯɹʻ ʉ:?:?:?:?:?:?:?:?:?:?:?:?:?:

Slide 13

Slide 13 text

%PDLFS.BDIJOF

Slide 14

Slide 14 text

%PDLFS.BDIJOF w ೚ҙͷϓϩόΠμʢ7JSUVBMCPY"84 %JHJUBM0DFBOFUDʣ্ʹ͋Δ%PDLFSαʔόΛ ૢ࡞͢ΔͨΊͷπʔϧ w 7.ىಈʗఀࢭʗ࠶ىಈʗҰཡදࣔ w 7.্ͷ%PDLFSϗετͱͷ΍ΓͱΓ w CPPUEPDLFSͷ୅ସЋͱͯ͠࢖͑Δ

Slide 15

Slide 15 text

4VQQPSU%SJWFST w "NB[PO8FC4FSWJDFT w .JDSPTPGU"[VSF w %JHJUBM0DFBO w &YPTDBMF w (PPHMF$PNQVUF&OHJOF w (FOFSJD w .JDSPTPGU)ZQFS7 IUUQTEPDTEPDLFSDPNNBDIJOFESJWFST w 0QFO4UBDL w 3BDLTQBDF w *#.4PGUMBZFS w 0SBDMF7JSUVBM#PY w 7.XBSFW$MPVE"JS w 7.XBSF'VTJPO w 7.XBSFW4QIFSF

Slide 16

Slide 16 text

%PDLFS.BDIJOF2VJDL4UBSU # ৽ن࡞੒ docker-machine create … # Ϛγϯ੾Γସ͑ʗදࣔͳͲ docker-machine env docker-machine ls # VMૢ࡞ܥ docker-machine start docker-machine stop docker-machine restart # ssh / scp docker-machine ssh docker-machine scp # VM࡟আ docker-machine rm

Slide 17

Slide 17 text

MT % docker-machine ls NAME ACTIVE DRIVER STATE URL default virtualbox Running tcp://xxx:2376 ec2vm amazonec2 Running tcp://xxx:2376 dovm * digitalocian Running tcp://xxx:2376

Slide 18

Slide 18 text

%PDLFS$PNQPTF

Slide 19

Slide 19 text

%PDLFS$PNQPTF w ෳ਺ͷ%PDLFSίϯςφ͔Βߏ੒͞ΕΔ̍ͭͷαʔ ϏεΛ࣮ߦ͍ͨ͠৔߹ɺ:".-ϑΝΠϧͰఆٛ͢ Δ͚ͩͰҰܸͰߏஙʗ؅ཧ͢Δ͜ͱ͕Ͱ͖Δπʔ ϧ w ىಈʗఀࢭʗαʔϏε࠶ߏஙʗεςʔλεҰ ཡදࣔʗϩάදࣔʗ౎౓࣮ߦ w ݩʑ͸pHͱ͍͏໊લͰެ։͞Ε͍ͯͨ

Slide 20

Slide 20 text

%PDLFS$PNQPTF2VJDL4UBSU # ίϯςφىಈ docker-compose up … # ίϯςφεέʔϧ docker-compose scale = # େମDockerίϚϯυͱҰॹ docker-compose ps docker-compose build docker-compose pull docker-compose logs docker-compose run docker-compose start docker-compose stop docker-compose restart docker-compose kill docker-compose rm

Slide 21

Slide 21 text

4BNQMF:".- webapp: build: . ports: - "5000:5000" volumes: - .:/code links: - redis redis: image: redis ΄ͱΜͲͷ%PDLFSΦϓγϣϯʹରԠ͍ͯ͠Δ

Slide 22

Slide 22 text

:".-ิ଍ webapp: build: ./webapp environment: - DEBUG=false - SEND_EMAILS=false web: extends: file: common.yml service: webapp ports: - "8000:8000" links: - db environment: - DEBUG=true db: image: postgres • extends • ֎෦ͷdocker-compose.ymlΛར༻͢Δ͜ͱ͕Ͱ͖Δ DPNNPOZNM EPDLFSDPNQPTFZNM

Slide 23

Slide 23 text

:".-ิ଍ external_links: - redis_1 - project_db_1:mysql • external_links • docker-compose؅ཧ֎ͷίϯςφͱϦϯΫ͢Δ

Slide 24

Slide 24 text

%PDLFS4XBSN

Slide 25

Slide 25 text

%PDLFS4XBSN w %PDLFSϗετͷू߹Λந৅Խ͠ɺҰͭͷ%PDLFS Τϯδϯͱ࣮ͯ͠ߦ͢ΔͨΊͷπʔϧ w εέδϡʔϥʗαʔϏεσΟεΧόϦ w %PDLFS.BDIJOFͱ࿈ܞ

Slide 26

Slide 26 text

4XBSN$MVTUFS 4XBSN .BTUFS 4XBSN/PEF $POUBJO FS 4XBSN/PEF %JTDPWFSZ 4FSWJDF $POUBJO FS $POUBJO FS DMJFOU

Slide 27

Slide 27 text

%JTDPWFSZ w ͍͔ͭ͘ͷσΟεΧόϦɾόοΫΤϯυͱ࿈ܞ w )PTUFE%JTDPWFSZXJUI%PDLFS)VC w Ϋϥελ৘ใ͕هड़͞Εͨ੩తϑΝΠϧ w FUDE w DPOTVM w [PPLFFQFS w *1ΞυϨεϦετࢦఆ w *1ΞυϨεൣғࢦఆ IUUQTEPDTEPDLFSDPNTXBSNEJTDPWFSZ

Slide 28

Slide 28 text

'JMUFST w εέδϡʔϦϯάͷͨΊͷ͍͔ͭ͘ͷϑΟϧλΛఏڙ͍ͯ͠Δ w $POTUSBJOUϑΟϧλ w "⒏OJUZϑΟϧλ w ஥ྑ͠άϧʔϓʹΑΔϑΟϧλʢίϯςφʗΠϝʔδʗϥ ϕϧʣ w 1PSUϑΟϧλ w %FQFOEFODZϑΟϧλ w ಉҰϊʔυ্ͰͷґଘΛεέδϡʔϦϯάʢWPMVNFTGSPN ʗMJOLʗOFUʣ w )FBMUIϑΟϧλ IUUQTEPDTEPDLFSDPNTXBSNTDIFEVMFSpMUFS

Slide 29

Slide 29 text

4USBUFHJFT w 4XBSN͸͍͔ͭ͘ͷεέδϡʔϦϯάํ਑Λ͍࣋ͬͯΔ w TQSFBE EFGBVMU w Ͱ͖Δ͚ͩ෼ࢄ͢Δ w CJOQBDL w Ͱ͖Δ͚ͩू໿͢Δ w SBNEPN w ϥϯμϜ IUUQTEPDTEPDLFSDPNTXBSNTDIFEVMFSTUSBUFHZ

Slide 30

Slide 30 text

ܑ̏ఋͷྗΛ ू݁ͯ͠ΈΑ͏

Slide 31

Slide 31 text

ܑ̏ఋͷྗΛू݁ͯ͠ΈΑ͏ w ʢࣄલ४උʣ w TXBSNUPLFOΛੜ੒͓ͯ͘͠ w EPDLFSNBDIJOFͰTXBSNϚελʔ༻ʗ TXBSNϊʔυ༻Y̎ͷ7.Λىಈ w EPDLFSDPNQPTFͰVQ΍TDBMFΛ࣮ߦͯ͠ΈΔ

Slide 32

Slide 32 text

τʔΫϯੜ੒ʗ7.ىಈ # create token docker run --rm swarm create # create vm # master docker-machine create -d … \ --swarm --swarm-discovery token://$SWARM_TOKEN \ --swarm-master \ vm-swarm-master # node docker-machine create -d … \ --swarm --swarm-discovery token://$SWARM_TOKEN \ vm-swarm-nodex # env ઃఆ eval "$(docker-machine env --swarm vm-swarm-master)"

Slide 33

Slide 33 text

EPDLFSDPNQPTFZNM web: image: toritori0318/ubuntu-perl-dancer-demoapp ports: - "5000" environment: - REDIS_HOST redis: image: redis ports: - "6379:6379" environment: - constraint:node==vm-swarm-master ˞ݱ࣌఺͸MJOL͕ͦͷ··࢖͑ͳ͍ʜ

Slide 34

Slide 34 text

%BODFS"QQ package MyWeb::App; use Dancer2; use Redis; our $VERSION = '0.1'; my $redis_host = $ENV{REDIS_HOST} || 'localhost'; my $redis_port = $ENV{REDIS_PORT} || '6379'; my $redis = Redis->new(server => "${redis_host}:${redis_port}"); get '/' => sub { $redis->incr('hits'); return sprintf("Hello Dancer! I have been seen %s times.", $redis->get('hits')); }; true;

Slide 35

Slide 35 text

˞EPDLFSNBDIJOF EPDLFSDPNQPTFEPDLFS TXBSNಈ࡞σϞ

Slide 36

Slide 36 text

Ϣʔεέʔε

Slide 37

Slide 37 text

̍ɽ։ൃ؀ڥ഑෍ w ։ൃऀ͸ɺϦϙδτϦΛ$MPOF͢Δ͚ͩͰΞϓϦέʔγϣ ϯΛ։ൃ͢Δ؀ڥΛߏஙͰ͖Δ w EPDLFSNBDIJOFEPDLFSDPNQPTF w खॱ w ʢલఏʣΞϓϦέʔγϣϯϦϙδτϦʹEPDLFS DPNQPTFZNMЋΛؚΊ͓ͯ͘ w ར༻ऀ͸ϦϙδτϦΛDMPOFͯ͠EPDLFSDPNQPTFVQ w αʔόىಈ΍Ϣχοτςετ͕ͦͷ··ಈ͘

Slide 38

Slide 38 text

̎ɽ$*؀ڥ w EPDLFSDPNQPTF؀ڥΛͦͷ··$*Ͱಈ࡞ʗςετΛߦ͏ w EPDLFSDPNQPTF w खॱ w ʢલఏ৚݅ʣέʔε̍ͷ؀ڥΛ༻ҙ͓ͯ͘͠ w $*ͷதͰҎԼͷ༷ͳίϚϯυΛ࣮ߦ͢Δ w EPDLFSDPNQPTFCVJMEʜVQʜSVONBLFUFTUʜ w 3FG%SPOFpHͰ$*ςετͯ͠ΈΔ w IUUQRJJUBDPNUPSJUPSJJUFNT GDEBEE

Slide 39

Slide 39 text

̏ɽϚϧνΫϥ΢υΫϥελ w %PDLFS4XBSNͰ؆୯ϚϧνΫϥ΢υΫϥελʂʁʢະདྷͷ࿩ ʴໝ૝ؚΉʣ w %PDLFS.BDIJOF%PDLFS$PNQPTF%PDLFS4XBSN w खॱ w %PDLFS.BDIJOFͰ֤Ϋϥ΢υʹ7.ཱͯΔ w %PDLFS4XBSNͰΫϥελϦϯά w %PDLFS$PNQPTFͰίϯςφ഑ஔ w %/4Ͱ֤Ϋϥ΢υ؀ڥʹϧʔςΟϯά w σʔλετΞ͸3JBL΍$BTTBOESB

Slide 40

Slide 40 text

4XBSN$MVTUFS "[VSF ($& "84 4XBSN .BTUFS 4XBSN/PEF $POUBJOFS 4XBSN/PEF $POUBJOFS 4XBSN/PEF $POUBJOFS DMJFOU $POUBJOFS $POUBJOFS $POUBJOFS 4XBSN .BTUFS 4XBSN .BTUFS

Slide 41

Slide 41 text

%PDLFSܑ̏ఋΛศརʹ࢖͏ ͨΊͷ͍Ζ͍Ζ

Slide 42

Slide 42 text

"MJBT # docker-machine cli alias dm="docker-machine" dme() { command docker-machine $1 ${DOCKER_MACHINE_NAME};} # RPrompt get_docker_machine_name() { if [ "$DOCKER_MACHINE_NAME" != "" ]; then echo "(dm=$DOCKER_MACHINE_NAME)" else echo "" fi } RPROMPT=‘%{$fg[green]%}$(get_docker_machine_name)$ \ (git_prompt_info)%{$reset_color%}% '

Slide 43

Slide 43 text

"MJBT # fig sudo ln -s /usr/loca/bin/docker-compose \ /usr/local/bin/fig # fig recreate fig-recreate() { command \ fig stop -t 1 && fig rm —force \ && fig build && fig up -d; }

Slide 44

Slide 44 text

QFDP # docker-machine env function peco-docker-machine-change() { # docker-machine ls + eval local dm_name=$(docker-machine ls | awk '{print $1}' | grep -vw 'NAME' | peco --query "$LBUFFER") if [ -n "$dm_name" ]; then eval "$(docker-machine env ${dm_name})" fi zle reset-prompt } zle -N peco-docker-machine-change bindkey '^x^m' peco-docker-machine-change # docker-machine ssh function peco-docker-machine-ssh() { BUFFER="docker-machine ls | awk '{print \$1}' | grep -vw 'NAME' | peco | awk '{print \$1}' | xargs -o -n 1 docker-mac hine ssh" zle accept-line } zle -N peco-docker-machine-ssh bindkey '^x^s' peco-docker-machine-ssh

Slide 45

Slide 45 text

[FNCVUTV͞Μ w %PDLFSʗ)BTIJDPSQͳͲͷ৘ใ΍຋༁Λެ։͞Ε͍ͯΔ w %PDLFS.BDIJOFυΩϡϝϯτࢀߟ೔ຊޠ༁ w IUUQRJJUBDPN[FNCVUTVJUFNTEEBEDB w %PDLFS$PNQPTFυΩϡϝϯτࢀߟ೔ຊޠ༁ɾ໨࣍ w IUUQRJJUBDPN[FNCVUTVJUFNTDDEBCB w %PDLFS4XBSNυΩϡϝϯτࢀߟ೔ຊޠ༁ɾ໨࣍ w IUUQRJJUBDPN[FNCVUTVJUFNTBGBEEFF

Slide 46

Slide 46 text

%PDLFSܑ̏ఋͷ͜Ε͔Β

Slide 47

Slide 47 text

%PDLFS.BDIJOF3PBENBQ w ΰʔϧɿຊ൪؀ڥͰͷ؅ཧʗϓϩϏδϣχϯά Λ໰୊ͳ͘ಈ࡞ͤ͞Δ͜ͱ w $4ΞʔΩςΫνϟ w TXBSN౷߹ w ॊೈͳϓϩϏδϣχϯά

Slide 48

Slide 48 text

%PDLFS$PNQPTF3PBENBQ w ຊ൪؀ڥʹ޲͚ͯ w VQ࣌ͷվળ w θϩμ΢ϯλΠϜʗࣦഊ࣌ͷϩʔϧόοΫ w ։ൃ؀ڥͱͯ͠ΑΓΑ͍ػೳ w XBUDIػೳ w TXBSNͱͷ౷߹

Slide 49

Slide 49 text

%PDLFS$PNQPTF3PBENBQ include: # link using http servicea: http: http://localhost:8080/projects/servicea/fig.yml # local paths serviceb: path: ../projects/serviceb/fig.yml webapp: #... links: - servicea_webapp - serviceb_webapp w ෳ਺νʔϜ࿈ܞΛߟྀ

Slide 50

Slide 50 text

%PDLFS4XBSN3PBENBQ w ૊ΈࠐΈεέδϡʔϥͷվળ w Ծ૝ίϯςφ*%ʗϗετো֐࣌Ϧόϥϯεʗάϩʔόϧεέδϡʔϥɹɹɹ w 4XBSNϚελʔϦʔμʔબग़ w "1*Ϛονϯά w ϚϧνϗετωοτϫʔΫ w ֦ுੑͷߟྀ w εέδϡʔϥͷϓϥάΠϯԽ w NFTPTLVCFSOFUFT

Slide 51

Slide 51 text

ϩʔυϚοϓ·ͱΊ w શମతʹ͸ຊ൪Ͱ໰୊ͳ͘ಈ࡞͢Δ͜ͱΛ໨ࢦ͍ͯ͠Δ w ࣌ظ͸ʜʁ w NBDIJOFDPNQPTF͸TXBSN౷߹ͷॆ࣮ w ಛʹDPNQPTFपΓͱͷ࿈ܞ͕ڧԽ͞ΕΔͱָͦ͠͏ w NBDIJOFTXBSN͸ΑΓϓϥΨϒϧʹ

Slide 52

Slide 52 text

·ͱΊ

Slide 53

Slide 53 text

·ͱΊ w %PDLFSܑ̏ఋΛ࢖͏ͱ%PDLFSΛΏΔ;Θʹར༻͢Δ͜ͱ͕Ͱ͖Δ w ౷Ұ͞ΕͨΠϯλϑΣʔεʗϙʔλϒϧʗॊೈ w ։ൃ؀ڥͱͯ͠ͷར༻ w े෼ར༻Մೳ w ຊ൪؀ڥͱͯ͠ͷར༻ w ·ͩ·ͩ՝୊͸ଟ͍͕ɺ͖ͪΜͱϩʔυϚοϓ͕ఏࣔ͞Ε͍ͯΔ w %PDLFSܑ̏ఋʹ͸ɺເ͕͋Δοʂʂʂ

Slide 54

Slide 54 text

·ͱΊ w %PDLFSܑ̏ఋΛ࢖͏ͱ%PDLFSΛΏΔ;Θʹར༻͢Δ͜ͱ͕Ͱ͖Δ w ౷Ұ͞ΕͨΠϯλϑΣʔεʗϙʔλϒϧʗॊೈ w ։ൃ؀ڥͱͯ͠ͷར༻ w े෼ར༻Մೳ w ຊ൪؀ڥͱͯ͠ͷར༻ w ·ͩ·ͩ՝୊͸ଟ͍͕ɺ͖ͪΜͱϩʔυϚοϓ͕ఏࣔ͞Ε͍ͯΔ w %PDLFSܑ̏ఋʹ͸ɺເ͕͋Δοʂʂʂ ܑ̐ఋ

Slide 55

Slide 55 text

͓·͚ɿ%PDLFS$PNQPTFิ଍ w Ͱ࣮૷͞ΕͨػೳʢҰ෦ʣ w EPDLFSDPNQPTFVQͷվળ w EPDLFSDPNQPTFTUPQLJMMSNTDBMF͕ฒྻ࣮ߦ͢ΔΑ͏ʹͳͬͨ w DPOUBJOFS@OBNFͰίϯςφ໊ΛΧελϚΠζͰ͖ΔΑ͏ʹͳͬͨ w αʔϏε໊ʹʮʯʮʯʮ@ʯΛؚΊΕΒΕΔΑ͏ʹͳͬͨ w MPH@ESJWFSͰ೚ҙͷϩάυϥΠόΛར༻Ͱ͖ΔΑ͏ʹͳͬͨ w ඪ४ೖྗ͔Βߏ੒ΛಈతߏஙͰ͖ΔΑ͏ʹͳͬͨ w FDIPSFEJT\JNBHFSFEJT^cEPDLFSDPNQPTFpMFVQ

Slide 56

Slide 56 text

͓·͚ɿ%PDLFS$PNQPTFิ଍ w ʢ͓ͦΒ͘ʣͰ؀ڥม਺पΓͷվળ͕ߦΘΕΔʂ w IUUQTHJUIVCDPNEPDLFSDPNQPTFQVMM w γΣϧ؀ڥม਺Λͦͷ··:".-ϑΝΠϧ಺Ͱهड़͢Δ͜ͱ ͕Ͱ͖ΔΑ͏ʹͳΔ $ export POSTGRES_VERSION=9.3 db: image: "postgres:${POSTGRES_VERSION}"

Slide 57

Slide 57 text

એ఻

Slide 58

Slide 58 text

એ఻ גࣜձࣾ)"30J%Ͱ͸ ΤϯδχΞΛืू͍ͯ͠·͢ʂ

Slide 59

Slide 59 text

͝ਗ਼ௌ͋Γ͕ͱ͏͟͝ ͍·ͨ͠