Carton at OSDC.TW 2012

Carton at OSDC.TW 2012

B2d653d5d663e750a2cd57bfbc9b727f?s=128

Tatsuhiko Miyagawa

April 14, 2012
Tweet

Transcript

  1. Carton Tatsuhiko Miyagawa OSDC.TW 2012 Sunday, April 15, 12

  2. ࣗݾ঺հ • ٶ઒ ୡ඙ Tatsuhiko Miyagawa • github.com/miyagawa • Twitter

    @miyagawa • Lives in San Francisco, CA Sunday, April 15, 12
  3. Sunday, April 15, 12

  4. Sunday, April 15, 12

  5. Sunday, April 15, 12

  6. Sunday, April 15, 12

  7. Managing CPAN Dependencies Sunday, April 15, 12

  8. Case Study: Web App Development Sunday, April 15, 12

  9. You’re writing a new web app. You don’t wanna reinvent

    wheels. Want to use as many CPAN deps. Sunday, April 15, 12
  10. Fine. Get them from CPAN, install on your machine. Sunday,

    April 15, 12
  11. >  cpanm  Web::Framework installed  LWP-­‐5.912 installed  Plack-­‐0.9980 installed  Web-­‐Framework-­‐1.20 >

     cpanm  JSON::Fast installed  JSON-­‐Fast-­‐1.91 >  cpanm  MIME::Parser::XS installed  MIME-­‐Parser-­‐XS-­‐0.20 Sunday, April 15, 12
  12. Test it... Sunday, April 15, 12

  13. Works? Ship it! Sunday, April 15, 12

  14. Deployment Set up new production servers. Install used CPAN modules

    Sunday, April 15, 12
  15. Few weeks later... Sunday, April 15, 12

  16. Your website is popular! Need more web servers! Sunday, April

    15, 12
  17. Re-Deployment Set up new production servers. Install CPAN modules. Sunday,

    April 15, 12
  18. “Crap, Web::Framework has been updated to 1.4 and many APIs

    have been changed or deprecated!” Sunday, April 15, 12
  19. Rollback Log in to the old web server. Check Perl

    module versions. Install them on the new server. Sunday, April 15, 12
  20. “Crap, this author deleted the version 1.20 we want. Let’s

    go to BackPAN...” Sunday, April 15, 12
  21. “Crap, version 1.20 doesn’t actually work with the newer LWP

    6 that we just installed! Have to downgrade this too...” Sunday, April 15, 12
  22. Sunday, April 15, 12

  23. “Upgrading CPAN modules broke my app” Sunday, April 15, 12

  24. What was wrong? Sunday, April 15, 12

  25. • Dependency declaration • Isolated Perl environments • Version controls/history

    • Dependency analysis • Repeatable deployments • etc. Sunday, April 15, 12
  26. Many existing solutions MyCPAN, DPAN, CPAN::Mini::Inject, OrePAN, Shipwright Sunday, April

    15, 12
  27. None of those didn’t quite work for me. (Or I

    haven’t even tried) Sunday, April 15, 12
  28. So I wrote a new one. Sunday, April 15, 12

  29. Carton https://github.com/miyagawa/carton Sunday, April 15, 12

  30. Inspired by... Sunday, April 15, 12

  31. Sunday, April 15, 12

  32. • App-specific local environment • Fast and safe install •

    Dep-tree analysis, including versions • Locking module versions • Easy Redeployment • Single-file, VCS friendly • Safe and easy rollback Sunday, April 15, 12
  33. Local perl environment Using local::lib and cpanm -L Each app

    has an isolated local library path Sunday, April 15, 12
  34. Fast and safe install cpanm 1.5 Saves MYMETA.json and install

    meta info Sunday, April 15, 12
  35. Dep tree analysis Rebuild the dependency tree from meta info

    Checks if anything is missing/superfluous Sunday, April 15, 12
  36. Locking versions Versions are saved in carton.lock including dependencies Sunday,

    April 15, 12
  37. Easy Redeployment Reinstall exactly the same set of modules on

    another prod/development machines. Sunday, April 15, 12
  38. Single-file, VCS friendly You can add carton.lock to git update

    whenever you update modules Sunday, April 15, 12
  39. Safe and easy rollback revert the lock file and redeploy

    Sunday, April 15, 12
  40. Declaring CPAN dependencies Sunday, April 15, 12

  41. CPAN Distributions: Makefile.PL  or  Build.PL Sunday, April 15, 12

  42. Carton apps: cpanfile Sunday, April 15, 12

  43. cpanfile Module::Install + CPAN::Meta Sunday, April 15, 12

  44. requires  ‘Plack’,  0.99; on  ‘develop’  =>  sub  {    recommends

     ‘Devel::Cover’; }; test_requires  ‘Test::Warn’; requires  ‘Devel::NYTProf’,  ‘>=  3.2,  <  5’; conflicts  ‘MooseX::Declare’,  ‘<  0.99’; Sunday, April 15, 12
  45. WHY • Your applications are not CPAN dists. • GitHub

    scripts • PaaS • DotCloud • Heroku • Stackato Sunday, April 15, 12
  46. DEMO Sunday, April 15, 12

  47. >  cpanm  Carton Sunday, April 15, 12

  48. ܯࠂ It is beta software, some features are missing or

    not working correctly (yet). Sunday, April 15, 12
  49. TODO / Roadmap • Update specific modules • Make install

    and bundle faster • Inject old versions / patched versions • Install from git SHA Sunday, April 15, 12
  50. github.com/miyagawa/carton irc.perl.org #carton Sunday, April 15, 12

  51. Sunday, April 15, 12

  52. ໰୊ʁ Sunday, April 15, 12

  53. ँँʂ speakerdeck.com/u/miyagawa Sunday, April 15, 12