Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
最近のtDiary
Search
MATSUOKA Kohei
April 24, 2016
Technology
1
1.6k
最近のtDiary
tDiary 15th Anniversary Party
MATSUOKA Kohei
April 24, 2016
Tweet
Share
More Decks by MATSUOKA Kohei
See All by MATSUOKA Kohei
ゼロからわかるRuby超入門の歩き方
machu
2
4.3k
ruby15
machu
0
470
ruby13
machu
0
400
ruby12
machu
1
280
ruby11
machu
0
290
ruby10
machu
0
290
ruby09
machu
0
240
ruby08
machu
0
220
ruby07
machu
0
380
Other Decks in Technology
See All in Technology
エンジニアが一生困らない ドキュメント作成の基本
naohiro_nakata
3
160
安心してください、日本語使えますよ―Ubuntu日本語Remix提供休止に寄せて― 2024-11-17
nobutomurata
0
190
RubyのWebアプリケーションを50倍速くする方法 / How to Make a Ruby Web Application 50 Times Faster
hogelog
2
870
2024年グライダー曲技世界選手権参加報告/2024 WGAC report
jscseminar
0
310
インフラとバックエンドとフロントエンドをくまなく調べて遅いアプリを早くした件
tubone24
1
380
スクラムチームを立ち上げる〜チーム開発で得られたもの・得られなかったもの〜
ohnoeight
2
330
Evangelismo técnico: ¿qué, cómo y por qué?
trishagee
0
320
DMARC 対応の話 - MIXI CTO オフィスアワー #04
bbqallstars
1
140
信頼性に挑む中で拡張できる・得られる1人のスキルセットとは?
ken5scal
2
480
The Role of Developer Relations in AI Product Success.
giftojabu1
0
110
mikroBus HAT を用いた簡易ベアメタル開発
tarotene
0
330
Can We Measure Developer Productivity?
ewolff
1
120
Featured
See All Featured
StorybookのUI Testing Handbookを読んだ
zakiyama
26
5.2k
Writing Fast Ruby
sferik
627
61k
The Art of Programming - Codeland 2020
erikaheidi
52
13k
BBQ
matthewcrist
85
9.3k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
250
21k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Building Applications with DynamoDB
mza
90
6.1k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
830
Into the Great Unknown - MozCon
thekraken
32
1.5k
Visualization
eitanlees
145
15k
Transcript
࠷ۙͷtDiary tDiary 15th Anniversary Party, 2016-04-24 MATSUOKA Kohei (@machu)
࠷ۙ: ͜͜5
U%JBSZ ࡀ͓ΊͰͱ͏͍͟͝·͢
ͲΕ͘Β͍ هΛॻ͍͍ͯΔ͔ ͑ͯΈΑ͏
ௐͯΈͨ $ find . -name '*.td2' | xargs grep -e
'^Date: \d\d\d\d' | cut -d' ' -f2 | sort -n > write-dates.csv هϑΝΠϧ (*.td2) ͔Β ͷߦ͚ͩΛൈ͖ग़ͯ͠CSV
0 50 100 150 200 250 300 2003 2004 2005
2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 هΛॻ͍ͨճ tDiaryͷίϛοτ 10 64 7 139 30 7 12 6 18 10 39 57 48 47 52 108 170 134 133 252 18 12 7 30 139 7 64 10
هΑΓ tDiaryΛ ॻ͍ͯΔਓͰ͢
tDiary4 2013.7~ gem, PaaS tDiary5 2016.4~ HTML5, HTTP2 docker tDiary3
2010.8~ rack
rackରԠ • ඪ४ΠϯλϑΣʔε • ϨϯαόҎ֎ͷରԠ • ؆୯ʹಈ͔ͤΔ • ApacheCGIͷߏஙෆཁ tDiary3
2010.8~ rack https://www.flickr.com/photos/122969584@N07/13780994204/
WebαʔόͷػೳΛRackͰ Rack Webαʔό tDiary CGI tDiary3 2010.8~ rack Rackαʔό ϛυϧΣΞ
tDiary .htaccess 63-ม ੩తϑΝΠϧ ೝূ
rackϛυϧΣΞΛॻ͍ͨ • URLม (tdiary/rack/html_anchor) #161 • “20160425.html”Λ”?date=20160425”ʹม • ੩తϑΝΠϧରԠ (tdiary/rack/static)
#160, #177 • /publicͷCSSը૾ϑΝΠϧΛฦ͢ • ֎෦ೝূ (tdiary/rack/auth) #163 • TwitterGitHubͷΞΧϯτͰೝূͰ͖Δ tDiary3 2010.8~ rack
֎෦ೝূΛ͑ΔΑ͏ʹͨ͠ https://github.com/tdiary/tdiary-core/blob/master/doc/HOWTO-authenticate-in-rack.md tDiary3 2010.8~ rack
ϥΠϒϥϦͰ؆୯ʹ࣮ݱ • OmniAuthͷΤϯυϙΠϯτΛݺͼग़͚ͩ͢ tDiary3 2010.8~ rack def call(env) if not
authenticate?(env) # phase 1: request phase login(env) elsif env['REQUEST_PATH'].match(%r|auth/#{@provider}/callback|) # phase 2: callback phase callback(env) else # phase 3: authorization phase auth = env['rack.session']['auth'] env['REMOTE_USER'] = "#{auth.uid}@#{auth.provider}" return forbidden unless @authz.call(auth) @app.call(env) end end tdiary/rack/auth/omniauth/authorization.rb
ۤ࿑͍ͯ͠Δͱ͜Ζ • CGIͱRackͷϋΠϒϦουڥ • ͲͬͪͰಈ͘ͷtDiary͘Β͍ʁ • μϯϩʔυ൛ʹϥΠϒϥϦΛಉࠝ • ͍·Ͱtar.gzΛల։͢Δ͚ͩͰಈ͘ •
RackʹରԠ͢Δ͜ͱͰಈ࡞ڥ͕͕ͬͨ tDiary3 2010.8~ rack
tDiary3 2010.8~ rack
ʊਓਓਓਓਓਓਓਓਓਓਓʊ ʼɹಥવͷtDiary Adminɹʻ ʉ:?:?:?:?:?:?:?:?:?:ʉ tDiary3 2010.8~ rack
tDiary4 2013.7~ gem, PaaS tDiary5 2016.4~ HTML5, HTTP2 docker tDiary3
2010.8~ rack
tDiaryΛRubyGemԽ • ͬͱָʹهΛઃஔ͍ͨ͠ tDiary4 2013.7~ gem, PaaS $ gem install
tdiary $ tdiary new diary $ cd diary $ bundle exec rackup https://rubygems.org/gems/tdiary/
contribΛ؆୯ʹՃͰ͖Δ • Ҏલ… • contribύοέʔδΛμϯϩʔυ͠ɺϓ ϥάΠϯͷύεΛtdiary.confʹॻ͘ • JavaScriptϑΝΠϧΛίϐʔ • ͍·Gemfile.localʹॻ͚ͩ͘ͰOK
tDiary4 2013.7~ gem, PaaS gem 'tdiary-contrib', github: 'tdiary/tdiary-contrib'
@tdtds++ PaaSରԠ (Heroku!!!) tDiary4 2013.7~ gem, PaaS
heroku-buildpack-tdiary • Heroku༻ʹηοτΞοϓ ͢ΔγΣϧεΫϦϓτ • masterϒϥϯνͰheroku ͕ಈ͘Α͏ʹ • ϓϧϦΫΛHerokuͰಈ࡞ ֬ೝͰ͖Δʂ
tDiary4 2013.7~ gem, PaaS
ۤ࿑͍ͯ͠Δͱ͜Ζ • ϥΠϒϥϦͷґଘؔ • tdiary-core࠷খϥΠϒϥϦʹґଘ • herokuͳͲͷPaaSͰՃϥΠϒϥϦཁ • heroku-buildpack-tdiaryͷΑ͏ͳϋοΫඞཁ •
͍Ζ͍ΖͳڥͰಈ͘Α͏ʹͳͬͯخ͍͠ tDiary4 2013.7~ gem, PaaS
tDiary4 2013.7~ gem, PaaS tDiary5 2016.4~ HTML5, HTTP2 docker tDiary3
2010.8~ rack
WebͷτϨϯυରԠ tDiary5 2016.4~ HTML5, HTTP2 docker • HTML5 (#534) •
ཁૉͷهड़Λͪΐͬͱม͑ͨఔ • ޓੑॏࢹ • HTTP2 • tDiaryతʹHTTPSεΩʔϜʹରԠɺ͋ͱWebαʔό • docker (#522)
ͱ͜ΖͰ
هαΠτ͋Δ͋Δ • ͍Ζ͍ΖखΛೖΕͯຬ • ͕࣌ؒܦͬͯԿΛ͔ͬͯͨΕΔ • ාͯ͘৮Εͳ͘ͳΓ์ஔ
αʔόࣜભٶ • 2ʙ3͝ͱʹαʔόΛ࡞Γ͠ • ڥΩϨΠʹͳΔ͕ͦΕͳΓʹ໘ • ࡞Γͨ͋͠ͱͬͺΓಉ͜͡ͱʹ
dockerͰ͡ΊΔ ࠷ࣜભٶܭը
https://www.docker.com/what-docker
https://www.docker.com The Docker Solution
dockerͰࣗαΠτΛཧ docker engine ͘͞ΒͷVPS (2G) ϓϩΩγ (nginx-proxy) tdiary pukiwiki rpaproxy
CoreOS (JU)VCʹ͓͍ͨ ઃఆϑΝΠϧྨΛͬͯ ຖճEPDLFSίϯςφΛ࡞Δ Dockerfile docker- compose.yml ઃఆϑΝΠϧྨ machu/machu-jp
dockerͰࣗαΠτΛཧ • αʔόͱಉ͡ڥΛϩʔΧϧͰ࡞Γ͍ͨ • ͏αʔό্Ͱσόοάͨ͘͠ͳ͍ • αʔόͷڥΛgithubͰཧ͍ͨ͠ • ͍ͭͰڥΛ࡞Γͳ͓ͤΔ҆৺ײ
Step1. ϩʔΧϧͰಈ͔͢ $ git clone https://github.com/tdiary/ tdiary-core.git $ atom .
(Կ͔ιʔεΛ͍͡Δ) $ docker build -t machu/tdiary . Step 1 : FROM ruby:2.3 2.3: Pulling from library/ruby (தུ) Successfully built b44f1cf5b5ee $ docker run -d -p 80:9292 machu/tdiary $ open http://192.168.99.101 tdiary/tdiary tdiary-core docker engine tdiary git clone docker build docker run
Dockerfile (Πϝʔδͷઃܭਤ) FROM ruby:2.3 MAINTAINER MATSUOKA Kohei @machu RUN mkdir
-p /usr/src/app WORKDIR /usr/src/app COPY [ "Gemfile", "Gemfile.lock", "/usr/src/app/" ] RUN bundle --path=vendor/bundle --without=development:test -- jobs=4 --retry=3 COPY . /usr/src/app/ RUN if [ ! -e tdiary.conf ]; then cp tdiary.conf.beginner tdiary.conf; fi && \ bundle && \ bundle exec rake assets:copy VOLUME [ "/usr/src/app/data", "/usr/src/app/public" ] EXPOSE 9292 CMD [ "bundle", "exec", "rackup", "-o", "0.0.0.0", "-p", "9292" ] EPDLFSެࣜͷ ΠϝʔδΛ͏ SVCZͷඞཁͳϥ ΠϒϥϦΛೖΕΔ UEJBSZΛίϐʔ ίϯςφΛىಈ͢ ΔͨΊͷઃఆ
Step2. ެࣜΠϝʔδΛ͏ $ docker pull tdiary/tdiary $ docker run -d
-p 80:9292 --name tdiary machu/tdiary tdiary/tdiary docker hub tdiary-core docker engine tdiary git push automated build docker pull docker run
Step3. ެࣜΠϝʔδΛ֦ு͢Δ FROM tdiary/tdiary:latest COPY . /usr/src/app/ RUN bundle &&
bundle exec rake assets:copy Dockerfile tdiary/tdiary machu/tdiary Gemfile.local .htaccess tdiary.conf $ docker build -t machu/tdiary . ΠϝʔδͷϏϧυ ಠࣗͷઃఆΛ ެࣜΠϝʔδʹՃ ※ ͏ͪΐͬͱެࣜΠϝʔδ͚ͩͰ͑ΔΑ͏ʹ͍ͨ͠
Step4. WebαʔόͱҰॹʹ͏ app: image: tdiary/tdiary environment: - RACK_ENV=production ports: -
"8080:9292" volumes_from: - db web: image: tdiary/nginx ports: - "80:80" links: - app volumes_from: - app docker-compose.yml nginx docker engine tdiary docker-compose up
dockerͰ͡ΊΔ࠷ࣜભٶ • ߋ৽ͷͨͼʹ৽͘͠ڥ͕Ͱ͖Δ • ઃఆϑΝΠϧΛgithubͰཧͰ͖Δ • dockerͷֶशίετͪΐͬͱߴ͍ • docker-cloudͰ͓ۚͰղܾ͋Γ
͓ΘΓʹ
ڥมΘΔ
هΛ ॻ͘ ruby1.8 CGI EUC-JP TrackBack HTTP/1.1 HTML4.1 Wikiه๏ Ϩϯαό
هΛ ॻ͘ ruby2.3 CGI UTF-8 TrackBack HTTP/2 HTML5 Wikiه๏ Ϩϯαό
Markdown Rack PaaS bundler docker
ه มΘΒͳ͍
͜Ε͔Β มΘΒͳ͍ͨΊʹ มΘΓ͚ͭͮΑ͏
U%JBSZ ࡀ͓ΊͰͱ͏͍͟͝·͢
0 50 100 150 200 250 300 2003 2004 2005
2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 هΛॻ͍ͨճ tDiaryͷίϛοτ 10 64 7 139 30 7 12 6 18 10 39 57 48 47 52 108 170 134 133 252 18 12 7 30 139 7 64 10 هΑΓ tDiaryΛ ॻ͍ͯΔਓͰͨ͠