CartonTatsuhiko MiyagawaYAPC::Asia 2011 TokyoFriday, October 14, 2011
View Slide
Managing CPANDependenciesFriday, October 14, 2011
Case Study:(Poor) Web DevelopmentFriday, October 14, 2011
You’re writing a new web app.You don’t wanna reinvent wheels.Want to use as many CPAN deps.Friday, October 14, 2011
Fine.Get them from CPAN,install on your machine.Friday, October 14, 2011
> cpanm Web::Frameworkinstalled LWP-‐5.912installed Plack-‐0.9980installed Web-‐Framework-‐1.20> cpanm JSON::Fastinstalled JSON-‐Fast-‐1.91> cpanm MIME::Parser::XSinstalled MIME-‐Parser-‐XS-‐0.20Friday, October 14, 2011
Test it...Friday, October 14, 2011
Works? Ship it!Friday, October 14, 2011
DeploymentSet up new production servers.Install CPAN modules(until the errors are gone)Friday, October 14, 2011
Few weeks later...Friday, October 14, 2011
Your website is popular!Need more web servers!Friday, October 14, 2011
Re-DeploymentSet up new production servers.Install CPAN modules(until the errors are gone)Friday, October 14, 2011
“Crap, Web::Framework has beenupdated to 1.4 and many APIshave been changed or deprecated!”Friday, October 14, 2011
RollbackLog in to the old web server.Check Perl module versions.Install them on the new server.Friday, October 14, 2011
“Crap, this author deletedthe version 1.20 we want.Let’s go to BackPAN...”Friday, October 14, 2011
“Crap, version 1.20 doesn’t actually workwith the newer LWP 6 that we justinstalled! Have to downgrade this too...”Friday, October 14, 2011
and so on.Friday, October 14, 2011
What was wrong?Friday, October 14, 2011
• Dependency declaration• Isolated Perl environments• Version controls/history• Dependency analysis• Repeatable deployments• etc.Friday, October 14, 2011
Many existing solutionsMyCPAN, DPAN, CPAN::Mini::Inject,OrePAN, ShipwrightFriday, October 14, 2011
None of thosedidn’t quite work for me.(Or I haven’t even tried)Friday, October 14, 2011
So I wrote a new one.Friday, October 14, 2011
Cartonhttps://github.com/miyagawa/cartonFriday, October 14, 2011
Inspired by...Friday, October 14, 2011
Friday, October 14, 2011
• 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 rollbackFriday, October 14, 2011
Local perl environmentUsing local::lib and cpanm -LEach app has an isolated local library pathFriday, October 14, 2011
Fast and safe installcpanm 1.5Saves MYMETA.json and install meta infoFriday, October 14, 2011
Dep tree analysisRebuild the dependency tree from meta infoChecks if anything is missing/superflousFriday, October 14, 2011
Locking versionsVersions are saved in carton.lockincluding dependenciesFriday, October 14, 2011
Easy RedeploymentReinstall exactly the same set of moduleson another prod/development machines.Friday, October 14, 2011
Single-file, VCS friendlyYou can add carton.lock to gitupdate whenever you update modulesFriday, October 14, 2011
Safe and easy rollbackrevert the lock file and redeployFriday, October 14, 2011
DEMOFriday, October 14, 2011
> cpanm CartonFriday, October 14, 2011
WARNINGIt is beta software, some features aremissing or not working correctly (yet).Friday, October 14, 2011
github.com/miyagawa/cartonirc.perl.org #cartonFriday, October 14, 2011
Questions?Friday, October 14, 2011
Thanks!twitter.com/miyagawaFriday, October 14, 2011