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

最近のtDiary

 最近のtDiary

tDiary 15th Anniversary Party

MATSUOKA Kohei

April 24, 2016
Tweet

More Decks by MATSUOKA Kohei

Other Decks in Technology

Transcript

  1. ௐ΂ͯΈͨ $ find . -name '*.td2' | xargs grep -e

    '^Date: \d\d\d\d' | cut -d' ' -f2 | sort -n > write-dates.csv ೔هϑΝΠϧ (*.td2) ͔Β ೔෇ͷߦ͚ͩΛൈ͖ग़ͯ͠CSV΁
  2. 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
  3. rackϛυϧ΢ΣΞΛॻ͍ͨ • URLม׵ (tdiary/rack/html_anchor) #161 • “20160425.html”Λ”?date=20160425”ʹม׵ • ੩తϑΝΠϧରԠ (tdiary/rack/static)

    #160, #177 • /publicͷCSS΍ը૾ϑΝΠϧΛฦ͢ • ֎෦ೝূ (tdiary/rack/auth) #163 • Twitter΍GitHubͷΞΧ΢ϯτͰೝূͰ͖Δ tDiary3 2010.8~ rack
  4. ϥΠϒϥϦͰ؆୯ʹ࣮ݱ • 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
  5. tDiaryΛRubyGemԽ • ΋ͬͱָʹ೔هΛઃஔ͍ͨ͠ tDiary4 2013.7~ gem, PaaS $ gem install

    tdiary $ tdiary new diary $ cd diary $ bundle exec rackup https://rubygems.org/gems/tdiary/
  6. WebͷτϨϯυ΁ରԠ tDiary5 2016.4~ HTML5, HTTP2 docker • HTML5 (#534) •

    ཁૉͷهड़Λͪΐͬͱม͑ͨఔ౓ • ޓ׵ੑॏࢹ • HTTP2 • tDiaryతʹ͸HTTPSεΩʔϜʹରԠɺ͋ͱ͸Webαʔό • docker (#522)
  7. dockerͰࣗαΠτΛ؅ཧ docker engine ͘͞ΒͷVPS (2G) ϓϩΩγ (nginx-proxy) tdiary pukiwiki rpaproxy

    CoreOS (JU)VCʹ͓͍ͨ ઃఆϑΝΠϧྨΛ࢖ͬͯ ຖճEPDLFSίϯςφΛ࡞Δ Dockerfile docker- compose.yml ઃఆϑΝΠϧྨ machu/machu-jp
  8. 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
  9. 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Λίϐʔ ίϯςφΛىಈ͢ ΔͨΊͷઃఆ
  10. 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
  11. 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 . ΠϝʔδͷϏϧυ ಠࣗͷઃఆΛ ެࣜΠϝʔδʹ௥Ճ ※ ΋͏ͪΐͬͱެࣜΠϝʔδ͚ͩͰ࢖͑ΔΑ͏ʹ͍ͨ͠
  12. 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
  13. 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Λ ॻ͍ͯΔਓͰͨ͠