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

Starting MOGOK - やさしい MOGOK の始めかた -

Starting MOGOK - やさしい MOGOK の始めかた -

IIJ の Ruby on Rails 向け PaaS である MOGOK の使い方。
Kanazawa.rb #6 (2013/02/16) の発表資料。

Cb057b585817007ba2a931a81ef9398f?s=128

Tomokazu Kiyohara

February 16, 2013
Tweet

Transcript

  1. 2013/02/16 Kanazawa.rb Meetup #6 Starting MOGOK ʙ ΍͍͞͠ MOGOK ͷ࢝Ί͔ͨ

    ʙ
  2. What is

  3. MOGOK ✤ IIJ (Internet Initiative Japan) ͕ఏڙ͢Δ ✤ Ruby on

    Rails ΞϓϦέʔγϣϯͷ ✤ ։ൃࢧԉ؀ڥͱ࣮ߦ؀ڥΛ ✤ ఏڙ͢ΔαʔϏε PaaS (Platform as a Service)
  4. MOGOK ✤ IIJ (Internet Initiative Japan) ͕ఏڙ͢Δ ✤ Ruby on

    Rails ΞϓϦέʔγϣϯͷ ✤ ։ൃࢧԉ؀ڥͱ࣮ߦ؀ڥΛ ✤ ఏڙ͢ΔαʔϏε PaaS (Platform as a Service) !ఏڙ : ࠓ͸͢΂ͯແঈ
  5. MOGOK ✤ http://mogok.jp

  6. MOGOK ʢ։ൃࢧԉ؀ڥʣ ✤ Web UI ✤ ΞϓϦέʔγϣϯ؅ཧ ✤ υΩϡϝϯτɾϑΥʔϥϜ ✤

    CLI (gem ͱͯ͠ఏڙ) ✤ Git ϦϙδτϦ (࠷େ 100MB)
  7. MOGOK ʢ࣮ߦ؀ڥʣ ✤ Web ✤ 1 process ✤ 400MB memory

    ✤ 150MB file (w/ gems) ✤ Thin/Ruby 1.9.3/RoR 3.x ✤ *.ruby.iijgio.com ✤ DB ✤ 1 connection ✤ 100MB memory ✤ 100MB data ✤ MySQL 5.5
  8. MOGOK ʢ࣮ߦ؀ڥʣ ✤ Web ✤ 1 process ✤ 400MB memory

    ✤ 150MB file (w/ gems) ✤ Thin/Ruby 1.9.3/RoR 3.x ✤ *.ruby.iijgio.com ✤ DB ✤ 1 connection ✤ 100MB memory ✤ 100MB data ✤ MySQL 5.5 ͍ͣΕ͸༗ঈϓϥϯ΋
  9. How to

  10. Flow ✤ Git ͷಋೖ ✤ RoR ΞϓϦέʔγϣϯͷίϯϑΟάมߋ ✤ MOGOK CLI

    ͷΠϯετʔϧ ✤ MOGOK ΁ͷσϓϩΠ ✤ ΞϓϦέʔγϣϯ؅ཧ
  11. Flow ✤ Git ͷಋೖ ✤ RoR ΞϓϦέʔγϣϯͷίϯϑΟάมߋ ✤ MOGOK CLI

    ͷΠϯετʔϧ ✤ MOGOK ΁ͷσϓϩΠ ✤ ΞϓϦέʔγϣϯ؅ཧ
  12. Git ͷಋೖ $ cd <your RoR app dir> $ git

    init $ git add . $ git commit -m "first commit"
  13. Flow ✤ Git ͷಋೖ ✤ RoR ΞϓϦέʔγϣϯͷίϯϑΟάมߋ ✤ MOGOK CLI

    ͷΠϯετʔϧ ✤ MOGOK ΁ͷσϓϩΠ ✤ ΞϓϦέʔγϣϯ؅ཧ
  14. RoRΞϓϦέʔγϣϯͷίϯϑΟάઃఆ ✤ Bundler (Gemfile) ✤ Env (config/environments/production.rb)

  15. Bundler : gem 'mysql2' gem 'therubyracer', :platforms => :ruby $

    vim Gemfile ✤ MOGOK ؀ڥͰඞཁͱͳΔ gem Λઃఆ
  16. Env $ vim config/environments/production.rb : config.serve_static_assets = true : ✤

    /public/* ౳ͷ static ίϯςϯπΛ༗ޮԽ ✤ (͓ͦΒ͘)͋Β͔͡Ί false ઃఆ͕͋ΔͷͰ true ʹมߋ
  17. Flow ✤ Git ͷಋೖ ✤ RoR ΞϓϦέʔγϣϯͷίϯϑΟάมߋ ✤ MOGOK CLI

    ͷΠϯετʔϧ ✤ MOGOK ΁ͷσϓϩΠ ✤ ΞϓϦέʔγϣϯ؅ཧ
  18. MOGOK CLI ͷΠϯετʔϧ ✤ gem ϑΝΠϧͷμ΢ϯϩʔυ

  19. MOGOK CLI ͷΠϯετʔϧ ✤ gem ϑΝΠϧͷΠϯετʔϧ $ gem install mogok-x.x.x.gem

    $ mogok list $ mogok --help ✤ MOGOK ΞΧ΢ϯτͷ "ID/Password" ͕ٻΊΒΕΔ ✤ ࠷ॳͷ1ճͷΈ
  20. Flow ✤ Git ͷಋೖ ✤ RoR ΞϓϦέʔγϣϯͷίϯϑΟάมߋ ✤ MOGOK CLI

    ͷΠϯετʔϧ ✤ MOGOK ΁ͷσϓϩΠ ✤ ΞϓϦέʔγϣϯ؅ཧ
  21. MOGOK΁ͷσϓϩΠ ✤ ΞϓϦέʔγϣϯొ࿥ ✤ ࢿࡐͷసૹ ✤ ΞϓϦέʔγϣϯߏங

  22. ΞϓϦέʔγϣϯొ࿥ $ mogok create <app name> ✤ RoR app dir

    Ͱ࣮ߦ͢Δ͜ͱΛڧ͘ਪ঑ ✤ Git remote ʹ MOGOK ؀ڥ͕ొ࿥͞ΕΔ ※ MOGOK CLI ͸͜ͷ஋Λࢀর͠ͳ͕Βಈ࡞͢Δ(--app option ΋͋Δ͕͔ͳΓ໘౗) ✤ <app name> ͸ MOGOKγεςϜશମͰҰҙ ✤ <app name>.ruby.iijgio.com
  23. ࢿࡐͷసૹ $ git push mogok master ✤ MOGOK ΞΧ΢ϯτͷ "ID/Password"

    ͕ٻΊΒΕΔ ✤ ຖճೖྗ͕ඞཁ ✤ "$ git config credential.helper store" ͓ͯ͘͠ͱָ ✤ "~/.git-credentials" ʹอଘ͞ΕΔͷͰѻ͍ʹ͸஫ҙ tips
  24. ΞϓϦέʔγϣϯߏங $ mogok build $ mogok rake db:migrate

  25. Flow ✤ Git ͷಋೖ ✤ RoR ΞϓϦέʔγϣϯͷίϯϑΟάมߋ ✤ MOGOK CLI

    ͷΠϯετʔϧ ✤ MOGOK ΁ͷσϓϩΠ ✤ ΞϓϦέʔγϣϯ؅ཧ
  26. ΞϓϦέʔγϣϯ؅ཧ $ mogok info $ mogok start $ mogok stop

    $ mogok restart ✤ MOGOK CLI ͔Βͷૢ࡞
  27. ΞϓϦέʔγϣϯ؅ཧ ✤ Web UI ͔Βͷૢ࡞

  28. Conclusion

  29. ·ͱΊ ✤ Ruby on Rails ͳ PaaS ✤ !൛͕ͩແྉͰ͔ͳΓͷػೳ͕࢖͑Δ ✤

    Git & mogok ίϚϯυͰσϓϩΠ ✤ mogok ίϚϯυ or Web UI Ͱίϯτϩʔϧ
  30. Thank you Tomokazu Kiyohara http://facebook.com/tomokazu.kiyohara http://twitter.com/kiyohara

  31. extra

  32. Bundler tips ✤ ։ൃ؀ڥͱMOGOK؀ڥͰґଘ gem Λ෼͚Δͱศར ✤ ։ൃ؀ڥʹ MySQL ͕ೖ͍ͬͯͳ͍ͱ͖ͳͲ

  33. group :mogok do gem 'mysql2' gem 'therubyracer', :platforms => :ruby

    end $ vim Gemfile ✤ MOGOK ؀ڥ޲͚ gem Λ group Խ Bundler tips
  34. : BUNDLE_WITHOUT: mogok $ vim .bundle/config ✤ ։ൃ؀ڥͰ͸ bundle command

    ͷର৅֎ʹࢦఆ Bundler tips
  35. ✤ config/database.yml ✤ ಛผʹฤू͢Δඞཁͳ͠ ✤ MOGOK؀ڥσϓϩΠ࣌ʹ͸ઐ༻ͷ΋ͷ͕ར༻͞ΕΔ Env tips

  36. ✤ "$mogok build" ͨ͠Β ✤ "$ mogok restart" →× ✤

    "$ mogok stop; mogok start" →◦ build & restart tips