Slide 1

Slide 1 text

Carton Tatsuhiko Miyagawa YAPC::Asia 2011 Tokyo Friday, October 14, 2011

Slide 2

Slide 2 text

Managing CPAN Dependencies Friday, October 14, 2011

Slide 3

Slide 3 text

Case Study: (Poor) Web Development Friday, October 14, 2011

Slide 4

Slide 4 text

You’re writing a new web app. You don’t wanna reinvent wheels. Want to use as many CPAN deps. Friday, October 14, 2011

Slide 5

Slide 5 text

Fine. Get them from CPAN, install on your machine. Friday, October 14, 2011

Slide 6

Slide 6 text

>  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 Friday, October 14, 2011

Slide 7

Slide 7 text

Test it... Friday, October 14, 2011

Slide 8

Slide 8 text

Works? Ship it! Friday, October 14, 2011

Slide 9

Slide 9 text

Deployment Set up new production servers. Install CPAN modules (until the errors are gone) Friday, October 14, 2011

Slide 10

Slide 10 text

Few weeks later... Friday, October 14, 2011

Slide 11

Slide 11 text

Your website is popular! Need more web servers! Friday, October 14, 2011

Slide 12

Slide 12 text

Re-Deployment Set up new production servers. Install CPAN modules (until the errors are gone) Friday, October 14, 2011

Slide 13

Slide 13 text

“Crap, Web::Framework has been updated to 1.4 and many APIs have been changed or deprecated!” Friday, October 14, 2011

Slide 14

Slide 14 text

Rollback Log in to the old web server. Check Perl module versions. Install them on the new server. Friday, October 14, 2011

Slide 15

Slide 15 text

“Crap, this author deleted the version 1.20 we want. Let’s go to BackPAN...” Friday, October 14, 2011

Slide 16

Slide 16 text

“Crap, version 1.20 doesn’t actually work with the newer LWP 6 that we just installed! Have to downgrade this too...” Friday, October 14, 2011

Slide 17

Slide 17 text

and so on. Friday, October 14, 2011

Slide 18

Slide 18 text

What was wrong? Friday, October 14, 2011

Slide 19

Slide 19 text

• Dependency declaration • Isolated Perl environments • Version controls/history • Dependency analysis • Repeatable deployments • etc. Friday, October 14, 2011

Slide 20

Slide 20 text

Many existing solutions MyCPAN, DPAN, CPAN::Mini::Inject, OrePAN, Shipwright Friday, October 14, 2011

Slide 21

Slide 21 text

None of those didn’t quite work for me. (Or I haven’t even tried) Friday, October 14, 2011

Slide 22

Slide 22 text

So I wrote a new one. Friday, October 14, 2011

Slide 23

Slide 23 text

Carton https://github.com/miyagawa/carton Friday, October 14, 2011

Slide 24

Slide 24 text

Inspired by... Friday, October 14, 2011

Slide 25

Slide 25 text

Friday, October 14, 2011

Slide 26

Slide 26 text

• 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 Friday, October 14, 2011

Slide 27

Slide 27 text

Local perl environment Using local::lib and cpanm -L Each app has an isolated local library path Friday, October 14, 2011

Slide 28

Slide 28 text

Fast and safe install cpanm 1.5 Saves MYMETA.json and install meta info Friday, October 14, 2011

Slide 29

Slide 29 text

Dep tree analysis Rebuild the dependency tree from meta info Checks if anything is missing/superflous Friday, October 14, 2011

Slide 30

Slide 30 text

Locking versions Versions are saved in carton.lock including dependencies Friday, October 14, 2011

Slide 31

Slide 31 text

Easy Redeployment Reinstall exactly the same set of modules on another prod/development machines. Friday, October 14, 2011

Slide 32

Slide 32 text

Single-file, VCS friendly You can add carton.lock to git update whenever you update modules Friday, October 14, 2011

Slide 33

Slide 33 text

Safe and easy rollback revert the lock file and redeploy Friday, October 14, 2011

Slide 34

Slide 34 text

DEMO Friday, October 14, 2011

Slide 35

Slide 35 text

>  cpanm  Carton Friday, October 14, 2011

Slide 36

Slide 36 text

WARNING It is beta software, some features are missing or not working correctly (yet). Friday, October 14, 2011

Slide 37

Slide 37 text

github.com/miyagawa/carton irc.perl.org #carton Friday, October 14, 2011

Slide 38

Slide 38 text

Questions? Friday, October 14, 2011

Slide 39

Slide 39 text

Thanks! twitter.com/miyagawa Friday, October 14, 2011