(WebαΠτͷ)ܧଓతσϓϩΠͱʁʁ
w $POUJOVPVT%FQMPZNFOU $%
w (JU)VCͱ͔ʹQVTIʢΞοϓϩʔυʣ͢ΔͱɺΣϒαʔ
όʔʹEFQMPZʢΞοϓϩʔυʣͯ͘͠ΕΔ
w ҙ༁ɿͲΜͲΜָʹΞοϓϩʔυ͍ͯ͜͠͏ʂ
w ʢָɺΤϯδχΞతͳओ؍Ͱ͢ʣ
w ʢ࣮ࡍͬͱߴঘͰ͢ʣ
Slide 4
Slide 4 text
ʮUL͢Ε͍͍ͷͰʁʯ
w ࢲʮྲྀߦ͍ͬͯΔ͔ΒͳʂԶΖ͏ʂʯ
w ྲྀߦ͍ͬͯΔ͜ͱ͕Ͱ͖ΔͱͳΜ͔ΠΠΑͶ
w ʮ'51ͰΞοϓϩʔυʁͦΜͳͷݹ͍Ͱ͢Ͷɺ࣌QVTI
͢ΕσϓϩΠͰ͢Αʢϑοʣʯ
w ͍͍͍ͨʜ͍͍ͨ͘ͳ͍ʁ
Slide 5
Slide 5 text
ͱ͜ΖͰgitͱʁ
w ϓϩδΣΫτ αΠτ
ͷ୯ҐͰ
w ϑΝΠϧͷߋ৽ཤྺΛอଘͰ͖
w ͦͷཤྺͷࠩΛݫ֨ʹཧͰ͖
w (JU)VCΛ͑ߋ৽ΛνʔϜʹڞ༗Ͱ͖Δ
w ͱ͍͏ײ͡ͷπʔϧ
w ଟ͘ͷ$%ͰHJUΛ׆༻͠ɺαΠτʹө͢Δ
Slide 6
Slide 6 text
gitཧ͞ΕΕ…
w ө࿙ΕɺઌฦΓʢר͖Γʣɺ͓͔͍͕ࠩ͠ͳ͍
w ࡞ۀऀ͕ಛఆͰ͖Δ
w ר͖ͤΔʢHJUͰཧ͍ͯ͠ΔϑΝΠϧʹݶΔʣ
w ΣϒαΠτ੍࡞ͷࣄނ͕ݮΔʂ
w ୠ͠ɺօେ͖ʮ͍͖ͳΓ'51मਖ਼ʯͰ͖ͳ͘ͳΔ
w ࣮ࡍͰ͖Δ͚Ͳɺී௨͠ͳ͍Α͏ʹ͢Δ
Slide 7
Slide 7 text
CD͕Ͱ͖ΔPaaSαʔϏεྫ
w /FUMJGZIUUQTXXXOFUMJGZDPN
w (JU)VCQBHFTIUUQTQBHFTHJUIVCDPN
w )FSPLVIUUQTKQIFSPLVDPN
w "[VSF8FC"QQTIUUQTB[VSFNJDSPTPGUDPNKBKQTFSWJDFTBQQ
TFSWJDFXFC
w ϩϦϙοϓʂϚωʔδυΫϥυIUUQTNDMPMJQPQKQ
Slide 8
Slide 8 text
͔͠͠…
w 1)1͕ಈ͔ͳ͍
!
ʢ(JU)VCQBHFTɺ/FUMJGZͷ߹ʣ
w ૉੑ͕-JOVYͰͳ͍
"
ʢ"[VSFͷ͍҆ϓϥϯͷ߹ʣ
w ػೳจ۟ແ͍͕ߴ͍
#
ʢओ؍ʣʢ)FSPLVɺϚωΫϥͷ
߹ʣ
w ̍υϝΠϯͳΒແྉͷࣄଟ͍
w ̍ͭͰෆศɺԶؾܰʹ৭ʑͳͷΛ࡞Γ͍ͨʂ
w ʢʜͰ͖Ε҆͘ʂʣ
Slide 9
Slide 9 text
ʮ͍҆ͨ͘͠ͳΒVPSͰ͠ΐʁʯ
w 714Λʮ͖ͪΜͱཧ͍ͯ͘͠ʯ࿑
ྗΛແࢹ͍͚ͯ͠ͳ͍
w ͪΌΜͱόʔδϣϯΞοϓͯ͠·͢
͔ʁ
w ͪΌΜͱઃఆͰ͖ͯ·͔͢ʁ
w ͪΌΜͱࢹ͍ͯ͠·͔͢ʁ
w ͤΒΕΔͳΒͤΔํ͕ྑ͍
Slide 10
Slide 10 text
ͦ͏͍͑…
w ϨϯαόͬͯυϝΠϯ͕ແ੍ݶ
ʢܖʹΑΔʣͰɺαΠτΛͭ͘Ε
Δͳʁ
w Ͱɺ'514'51Ͱຖճ6-ͨ͠
ΓɺόοΫΞοϓͨ͠Γͷཧ
͏໘ͩͳʜ
w ϨϯαόͰ$%Ͱ͖Ε͍͍ͷʹ
ͳʁ
Slide 11
Slide 11 text
ͱ͍͏͜ͱͰ
ϨϯαόͰ
CD
͢Δͧʂ
Slide 12
Slide 12 text
w ʢ܁Γฦ͠ʹͳΓ·͕͢ɿ͔͜͜Β
ઌͷ͜ͱͨͱ͑/FUMJGZϩϦ
ϙοϓϚωʔδυΫϥυͬͯͭ
Λ͏খݣ͍͕͋Εɺ΄΅ແ༻Ͱ
͢͠ɺݸͳΒϚωΫϥ͍͍ͳͱ
͓͍·ͨ͠ʣ
w ʢ͕ɺࡒͱ૬ஊͳ͠ʹϓϩ
δΣΫτΛͨ͘͞Μͭ͘Γ͍ͨ͠ɺ
Ϩϯλϧαʔόʔ͕͖ͬͯͭͳ
ͷͰɺ͜͜ͰϨϯαόΛ͕Μͬ
ͯ͏ಓΛબͼ·ͨ͠ɻʣ
Slide 13
Slide 13 text
༻ҙ͢Δͷ
w (JU)VC
w ϨϯαόʢࠓճTTIͰ͖Δͭʣ
Slide 14
Slide 14 text
ՃͷVHΛ࡞
w ίϯύω͔ΒՃͷόʔνϟϧϗετΛͭ͘Δ
w ʢৄࡉলུɺαϙʔτ͞Μʹฉ͜͏ʂʣ
ॳظυϝ7)ͩΖͬͯʁ·͋ͦ͏ͳΜ͚ͩͲ
Slide 15
Slide 15 text
ྫ
Domain : http://lop.8oji.tokyo/
DocmentRoot : {ॳظυϝΠϯDir}/lop.8oji.tokyo/public
w ެ։σΟϨΫτϦʢ%PD3PPUʣʹ
w ϓϩδΣΫτ໊ʢϑϧͳυϝΠϯ໊ʣΛ͚ͭ
w ͏ҰஈԼ͛Δ publicwebroothtdocsʣ͜ͱΛ
w ڧ͘ਪ͢Δ ͜ͷ͋ͨΓޙड़
Slide 16
Slide 16 text
దʹGithubʹrepoΛͭ͘Δ
w ʢলུʣ
w SFQP໊ʹ%PD3PPUͰࢦఆͨ͠ϓϩδΣΫτ໊ʢϑϧ
ͳυϝΠϯ໊ʣʹ͓ͯ͘͠ʢͱɺࠓճ͠·͢ʣ
w QSJWBUFSFQPͰΑ͍Ͱ͢
w public/index.htmlΛͭͬͯ͘DPNNJU
QVTI͓ͯ͘͠
Slide 17
Slide 17 text
SSH४උ
w ʢϩϦϙͳΒʣίϯύω͔Β44)Λ
༗ޮԽ
Slide 18
Slide 18 text
Ωʔੜ(͍·Θ͠ෆՄ)
$ ssh-keygen -t rsa -b 4096 \
-C "lop.8oji.tokyo" -f ~/.ssh/lop.8oji.tokyo.key
w ϨϯαόʹTTIͯ͠Δͱָ
w ੜ͞Εͨެ։伴lop.8oji.tokyo.key.pubΛ(JU)VC
ͷEFQMPZLFZʹొ
w "MMPXXSJUFBDDFTTෆཁ
Slide 19
Slide 19 text
ॳճσϓϩΠ
# (ʙ/lop.8oji.tokyo/publicͰͳ͍ʣ
$ cd ~/web/
# طଘϑΝΠϧ͕͋Εফ͢
$ rm -ir ~/web/lop.8oji.tokyo
# cloneɺlop.8oji.tokyo͕࡞͞ΕΔ
$ git clone [email protected]:uzulla/lop.8oji.tokyo.git
w ޙड़ͷʮయܕతͳηΩϡϦςΟϦεΫʯΛΑΜͰͶ
w ϩϦϙͰɺBHFOUసૹΛ͢Δ͔ɺޙड़ͷ.git/config
मਖ਼
Slide 20
Slide 20 text
͜ΕͰͱΓ͋͑ͣσϓϩΠͰ͖ͨ
w αΠτʹ(JU)VCʹQVTI͍ͯͨ͠public/index.html
͕ݟ͍͑ͯΔͣ
w ʢຖճTTIͰϩάΠϯͯ͠HJUQVMM͢ΔͳΒɺ͜͜·ͰͰ
0,ʣ
Slide 21
Slide 21 text
Α͠CDͩʂࣗಈԽͩʂ
Slide 22
Slide 22 text
CronͰpull͢Δ(͑ͬ)
*/30 * * * * git -c core.sshCommand="ssh -i ~/.ssh/deploy.key" \
-C ~/web/lop.8oji.tokyo/
>> ~/lop.8oji.tokyo.pull.log 2>&1
w ҙ༁ɿʹҰɺDSPOͰHJUIVC͔ΒϑΝΠϧΛ%-ͯ͠
͍Δ
w ॳΊͯݟͨࢲͷײʮʜΊͪΌΊͪΌݡ͍ͳ͜Εʯ
w ಥͰ͕͢ɺ্ϩϦϙͰବ
༨ஊ
$ git -C ~/web/lop.8oji.tokyo/
Unknown option: -C
## ??
$ git --version
git version 1.8.3.1
## ?????? `-c core.sshCommand`͔ͭ͑ͳ͍…
$ git --git-dir= --work-tree=~/web/lop.8oji.tokyo status
fatal: Could not switch to '~/web/': ??????????????????????
## ??????????????????????
Slide 26
Slide 26 text
ʢͳΜͱ͔ͳͬͯ΄͍͠ͳ͊ʜʢνϥονϥο
Slide 27
Slide 27 text
ʢΛͯ͠ʣͰ͜Εͬͯ…
w ୯७ͰָͰ͋Δ͕ʜ
ѹతͳʮےྗͰղܾʯײ
w ϋΠύʔແବ͕ଟ͍ɺϊοτΤί
w ͍͔ʹౖΒΕͦ͏ʢཁग़యʣ
w ٿڥྙཧʹ͍ͭͯཧੑతʹߟ͑ͨ݁Ռɺ
$SPOִؒΛ͛Δͱөʹ͕͔͔࣌ؒͬͯετϨε
w ͲΜͲΜͱͷͮ͘ΓΛ͍͖͍ͯͨ͠ͷʹʂ
Slide 28
Slide 28 text
͍͞͠Ύ͏͖ͯͳΓΖΜ
w (JU)VCʹQVTI͞ΕͨΒ
w ͦͷλΠϛϯάͰϨϯαό͔ΒHJUQVMM͍ͨ͠
Slide 29
Slide 29 text
ͱ͍͏͜ͱͰɺCIͷྗΛआΓΔ
w (JUIVC"DUJPOT
w IUUQTHJUIVCDPNGFBUVSFTBDUJPOT
w (JU)VC͕ఏڙ͢Δ$*πʔϧ
w ·ͩϕʔλ͚ͩͲɺ͏͑Δɺ͏ͦΖͦΖຊαʔϏε
w 1VCMJDSFQPͳΒແྉɺ
1SJWBUFͰճ͕গͳ͚ΕແྉʢͬΆ͍ʣ
Slide 30
Slide 30 text
CIͱʁ
w ܧଓతΠϯςάͳΜͱ͔ɺΠϚυΩͰ͖ͳ͍ͱͩΊΒ͠
͍
w (JUIVCʹQVTI
͢ΔͱΫϥυͰ͖ͳॲཧ͕Ͱ͖Δ
w ྫɿunit testɺcomposerɺdeployer
w ʢ͕ΜΕେମͳΜͰͰ͖Δʣ
w ʢͭ·Γɺ$%વͰ͖Δʣ
w ࣮ࡍͷॴɺ'51ͰΞοϓϩʔυͩͬͯͰ͖Δ͆
͏Ұखඞཁ
w (JU)VCʹQVTI͞ΕͨΒ
w 1VTI͞ΕͨΒˠ()"DUJPOTͰͳʹ͔Ͱ͖Δ
w ͦͷλΠϛϯάͰϨϯαό͔ΒHJUQVMM͍ͨ͠
w QVMMαʔόʔ͔Βૢ࡞͕ඞཁɺ۩ମతʹͲ͏͢
Δʜʁ
w curl http://XXX/gitpull.phpʁˠා͍
w ࠓճTTIࣗಈԽ͠·͢
Slide 33
Slide 33 text
sshͰΩοΫ͢Δ
$ ssh {ུ} "~/lop.8oji.tokyo/pull_for_lolipop.bash"
w γΣϧૢ࡞͠ͳͯ͘ɺίϚϯυͰ͏͘͝Α͏ʹ४උ
w खݩͷ1$͔Β࣮ߦͰ͖Δ͜ͱΛ֬ೝ͢Δ͜ͱ
w खݩ1$ͷTTIBHFOU͕͖͍ͪΌͬͯΔͱɺ伴͕ͪΌΜ
ͱͰ͖ͯͳͯ͘ಈ͍ͪΌ͏ͷͰҙ
GitHub Ac*ons͔Βssh࣮ߦ͢Δʹʁ
w ී௨ʹrunॻ͍ͯͰ͖Δ͕ɺTTIൿີ伴ͷѻَ͍͕
w ύεϫʔυΛHJUʹίϛοτʢຒΊࠐΈʣˠ࿙ΕΔˠࢮ
w ൿີ伴Λίϛοτˠ࿙ΕΔˠࢮ
Slide 36
Slide 36 text
ac#ons/remote-ssh-commands
w "DUJPOT4FDSFUͰ࣮ߦ͚࣌ͩऔΓग़ͤΔྖҬ͕͋Δ
w 4FDSFUʹ͍ΕͨΩʔΛ͔ͭͬͯTTIͰ͖Δ
w IUUQTHJUIVCDPNNBSLFUQMBDFBDUJPOTSFNPUFTTI
DPNNBOET
w ͜Εܥࢁ͋ΓɺͲΕ͕͍͍͔ਖ਼Θ͔Βͳ͍ʣ
w ࠷ߴศརʂ
Slide 37
Slide 37 text
SecretʹൿີใΛอଘ
w SFQPTFUUJOHT4FDSFUTͰϗε
τɺϙʔτɺϢʔβʔɺ伴Λઃఆ
w ࡉ͔͍͜ͱলུɺϙνϙνͰ͢
·ͱΊ
w (JU)VCͱϨϯαόͰࡶͳ$%Ͱ͖Δʂ
w Ϩϯαό1)1͕͏͘͝ʂʂʂʂ
w ͔͍҆͠ʂ
w ʮϫΠͷՈʹ͏)FSPLV͍Βͳ͍Μʂʂʯ
͍͍͗͢
w ةݥͳ'51ΞΧϯτڞ༗ཧ͕(JU)VCͷDPNNJUݖݶ
ཧʹͳΓɺҰཡͰ͖ͯ҆શ໌֬؆ศ
Slide 44
Slide 44 text
ൃలܕ
w /VYUͱ͔+4ͷϓϩδΣΫτͳΒී௨ʹ"DUJPOTͰϏϧυ͢
Ε0,
w ੩తαΠτδΣωϨʔλͪΖΜ0,
w ·ͱʹΔͳΒ%FQMPZFSΛʢ1)1FSͷͰ͢ʣ
w εέʔϧΞτʁී௨ʹϚωΫϥ)FSPLVआΓͯͩ͘͞
͍ʜ
Slide 45
Slide 45 text
ʂ
w ϓΞϚϯζͳϨϯαόಓଓ͘ʜ
w ʢࢼ࣌࣍͢ϖʔδҎ߱ݟ͍ͯͩ͘͞ʣ
Slide 46
Slide 46 text
Ϩϯαόʹ͓͚ΔయܕతͳηΩϡϦςΟϦεΫ
w HJUDMPOF͢Δͱ.git͕Ͱ͖Δ
w SFQPԼʹJOEFYIUNMΛஔ͘ͳΒ
͜ΕͷΞΫηε੍ݶΛ
͠ͳ͍ͱବ
/index.html
/.git/ ← ΞΫηε͞Εͨ͘ͳ͍ʂ
http://my.example.jp/.git/ ͰΞΫηεͰ͖Δʢʁʣ
ͷͰΞΫηε੍ݶ͕ඞཁ
Slide 47
Slide 47 text
ͦͦԼʹindex.htmlஔ͘ͷͲ͏ͳͷʁ
w ৗࣝత
ʹߟ͑ͯɺpublicͱ͔htdocsͱ͔ҰݸσΟϨ
ΫτϦΛ࡞Δ
w όʔνϟϧϗετʢ7)ʣઃఆͰʙ/public/ʹ͘ΔΑ͏
ʹઃఆ͢Ε͍͍ΑͶ
/public/index.html
/.git
# …ͱࢥ͍͖ɺ͜Ε͚ͩͰବʂʂ
Slide 48
Slide 48 text
w ʮଟ͘ͷʯϨϯαόͷ7)ػೳॳظυϝΠϯͷ%PD3PPU
ҎԼʹ͔͠7)ͷ%PD3PPU͕ͭ͘Εͳ͍
w ྫɿ/home/hoge/www/virtual.host.example
w ͢ΔͱҎԼͷ63-ͰΞΫηε͕Ͱ͖Δ ࣄ͕ଟ͍
w http://{ॳظυϝ}/virtual.host.example/.git
w ͳͷͰɺʢͨͱ͑ʣ)PTUϔομΛݟͯʮਖ਼͍͠ʯ)PTU
Ͱ͜ͳ͍ͳΒɺ͘ඞཁ͕͋Δ
w ~/.ssh/authorized_keysʹcommand=ʙΛهड़
w TTI࣌ʹࢦఆͷίϚϯυ࣮ߦʹʮݶΔʯˠͪΐͬͱ҆৺
w ʢΩʔઐ༻ʹ࡞Δ͖ɺੜํ๏લड़ͱಉ༷ʣ
w ͜ΕͰʮಛఆίϚϯυ͚ͩୟ͚ΔTTIʯ͕ൃੜ͠ɺ
ੈքʹฏ͕๚ΕͨͷͰ͋ͬͨʜɻ
Slide 59
Slide 59 text
ͱɺ͓͍ͬͯͨΜ͚ͩͲ
w Ͳ͏ϩϦϙͷTTIͰcommand=͕͖͔ͳ͍ͬΆ͍
w ผͷۀऀͰಈ͘ͷͰʜʁ
w ݟͳ͔ͬͨ͜ͱʹ͠·ͨ͠
Slide 60
Slide 60 text
ผͷߴͳ༨ஊʢҙʣ
w ssh-agent͕͏͍͍ͯ͝Δͱɺ-iࢦఆ͕ͯͦͬͪ͠༏
ઌ͞ΕͯγΣϧ্͕͕Δ͜ͱ͕͋Δʢςετ࣌ʹϋϚΔʣ
w unset SSH_AUTH_SOCK
w DPNNBOEʮϩάΠϯγΣϧ্Ͱ࣮ߦ͞ΕΔʯΑʂ
w ྫ͑chsh͢Δͷ͕͜Θͯ͘.***rcͱ͔Ͱbashͱ͔
ͬͯγΣϧΓସ͑ͯ͠ΔͱɺγΣϧʹͲͬͪΌ͏
ͷͰҙɻ
ͪΌΜͱ੍ݶ͞Ε͍ͯΔ͜ͱ֬ೝ͠·͠ΐ͏ʂ