Carton at London Perl Workshop 2013

Carton at London Perl Workshop 2013

B2d653d5d663e750a2cd57bfbc9b727f?s=128

Tatsuhiko Miyagawa

November 30, 2013
Tweet

Transcript

  1. Carton managing CPAN dependencies Tatsuhiko Miyagawa @miyagawa London Perl Workshop

    2013 Saturday, November 30, 13
  2. Me • Tatsuhiko Miyagawa • Lives in San Francisco •

    {github,twitter,CPAN}/miyagawa Saturday, November 30, 13
  3. Thank You! Saturday, November 30, 13

  4. Managing CPAN Dependencies Saturday, November 30, 13

  5. How many CPAN modules your app depends on? Saturday, November

    30, 13
  6. When is the last time upgrading a CPAN module broke

    your app? Saturday, November 30, 13
  7. Case Study: Web App Development Saturday, November 30, 13

  8. You’re writing a new web app using as many CPAN

    modules. Saturday, November 30, 13
  9. Get them from CPAN, install on your machine. Saturday, November

    30, 13
  10. john@local>  cpanm  Web::Framework installed  LWP-­‐5.912 installed  Plack-­‐0.9980 installed  Web-­‐Framework-­‐1.10 Saturday,

    November 30, 13
  11. Test it... Saturday, November 30, 13

  12. Works? Ship it! Saturday, November 30, 13

  13. What if ... Saturday, November 30, 13

  14. • Jul 2nd: Started working on project • using Web::Framework

    1.1 • Jul 9th: Finished version 1.0 • Jul 10-15th: internal beta, QA • Jul 16th: Deploy to the production Saturday, November 30, 13
  15. • Jul 2nd: Started working on project • using Web::Framework

    1.1 • Jul 9th: Finished version 1.0 • Jul 10-15th: internal beta, QA • Jul 15th: Web::Framework 1.2 is released • Jul 16th: Deploy to the cloud/production Saturday, November 30, 13
  16. root@prod>  cpanm  Web::Framework installed  LWP-­‐5.912 installed  Plack-­‐0.9980 installed  Web-­‐Framework-­‐1.20 Saturday,

    November 30, 13
  17. Web::Framework 1.2 API changes! Saturday, November 30, 13

  18. Saturday, November 30, 13

  19. “Upgrading CPAN modules broke my app” Saturday, November 30, 13

  20. Dependencies are part of your app. Saturday, November 30, 13

  21. a solution cpanm 1.6 Saturday, November 30, 13

  22. >  cpanm  Web::Framework@1.10 installed  Web-­‐Framework-­‐1.10 Saturday, November 30, 13

  23. >  cpanm  Web::Framework~">=  1.0,  <  1.2" installed  Web-­‐Framework-­‐1.19 Saturday, November

    30, 13
  24. ♥ MetaCPAN Saturday, November 30, 13

  25. a solution cpanfile + cpanm 1.6 Saturday, November 30, 13

  26. >  cat  cpanfile requires  'Web::Framework',  '==  1.10'; >  cpanm  -­‐-­‐installdeps

     . installed  Web-­‐Framework-­‐1.10 Saturday, November 30, 13
  27. cpanfile DSL to describe prereqs Saturday, November 30, 13

  28. requires  'Catalyst',  '5.8000';   recommends  'JSON::XS',  '2.0'; on  'test'  =>

     sub  {    requires  'Test::More',  '>=  0.96' }; on  'develop'  =>  sub  {    recommends  'Devel::NYTProf'; }; feature  'sqlite'  =>  sub  {    requires  'DBD::SQLite'; }; Saturday, November 30, 13
  29. inspired by: gemfile(5) Saturday, November 30, 13

  30. Compatible to: Module::Install(::DSL) Saturday, November 30, 13

  31. Converted to: CPAN::Meta::Prereqs Saturday, November 30, 13

  32. Toolset Module::CPANfile Module::Install::CPANfile Dist::Zilla plugins Saturday, November 30, 13

  33. Supported by dzil, Milla & cpanm 1.6 Saturday, November 30,

    13
  34. cpanfile + cpanm • Simple • Yet powerful and flexible

    way to describe dependencies and version requirements • Version control cpanfile Saturday, November 30, 13
  35. caveats • Locking each dependency with specific version is tedious

    work • Can only lock direct dependencies • MetaCPAN as SPOF • No easy/reliable way to rollback Saturday, November 30, 13
  36. Many other solutions Needs servers, Needs databases Too simple, Too

    complicated, etc. Saturday, November 30, 13
  37. the new Solution Saturday, November 30, 13

  38. Carton https://github.com/miyagawa/carton Saturday, November 30, 13

  39. Inspired by... Saturday, November 30, 13

  40. Saturday, November 30, 13

  41. Basic idea: Describe CPAN dependencies snapshot tarball pathnames Saturday, November

    30, 13
  42. Built on top of: cpanfile + cpanm 1.7 Saturday, November

    30, 13
  43. • App-specific local environment • Fast and safe install with

    caches • Dep-tree analysis, including versions • Freezing module versions • Conservative updates • Easy Redeployment, Rollback • Single-file, VCS friendly Saturday, November 30, 13
  44. Local perl environment Using local::lib and cpanm -L Each app

    has an isolated local library path Saturday, November 30, 13
  45. Fast and safe install Saves MYMETA.json and install meta info

    Saturday, November 30, 13
  46. Dep tree analysis Rebuild the dependency tree from snapshot Checks

    if anything is missing/superfluous Saturday, November 30, 13
  47. Freezing versions Versions are saved in snapshots including dependencies Saturday,

    November 30, 13
  48. Easy Redeployment Reinstall exactly the same set of modules on

    another prod/development machines. Saturday, November 30, 13
  49. Conservative Update Modules won't be upgraded unless it is required,

    or manually updated. Saturday, November 30, 13
  50. Single-file, VCS friendly You can add cpanfile.snapshot to git update

    whenever you update modules "Dependencies are part of your app." Saturday, November 30, 13
  51. Safe and easy rollback revert the lock file and redeploy

    Saturday, November 30, 13
  52. DEMO Saturday, November 30, 13

  53. Deployment with Carton Saturday, November 30, 13

  54.  @local>  carton  install  @local>  git  commit  cpanfile.snapshot  @local>  git  push

    @remote>  carton  install  -­‐-­‐deployment @remote>  carton  exec  plackup  ... Saturday, November 30, 13
  55. Example: github.com/miyagawa/cpanmetadb-perl capistrano, Server::Starter, carton, plackup (twiggy) Saturday, November 30,

    13
  56. PaaS/Cloud github.com/miyagawa/heroku-buildpack-perl Saturday, November 30, 13

  57. Saturday, November 30, 13

  58. http://weblog.bulknews.net Saturday, November 30, 13

  59. Support to come! Dokku, DotCloud, Travis CI, Cloud Foundry etc.

    Saturday, November 30, 13
  60. carton 1.0 on CPAN Saturday, November 30, 13

  61. >  cpanm  Carton Saturday, November 30, 13

  62. Preview: next major releases Saturday, November 30, 13

  63. cpanm 1.8 git (+ any URL) support in index Saturday,

    November 30, 13
  64. cpanfile 1.1 git syntax support Saturday, November 30, 13

  65. requires  'Plack',  '1.0000',    git  =>  'git://github.com/plack/Plack.git',    ref  =>

     'devel'; carton 1.1 Saturday, November 30, 13
  66. requires  'Plack',  '1.0011',    dist  =>  'MIYAGAWA/Plack-­‐1.0011.tar.gz'; carton 1.1 Saturday,

    November 30, 13
  67. requires  'Plack',  '1.0011',    dist  =>  'http://darkpan/Plack-­‐1.tar.gz'; carton 1.1 Saturday,

    November 30, 13
  68. (demo) Saturday, November 30, 13

  69. cpanm 1.8 • Rewrite internals • Backend API • Plugin

    support • CPAN Testers support (via plugins) Saturday, November 30, 13
  70. carton 1.1 • binstubs • configure args/hints support • safe

    exec on development • remember options (--path etc.) Saturday, November 30, 13
  71. github.com/miyagawa/carton irc.perl.org #carton Saturday, November 30, 13

  72. speakerdeck.com /miyagawa Saturday, November 30, 13

  73. gum.co/BmXz Saturday, November 30, 13

  74. Questions? Saturday, November 30, 13