Apr 10, 2012

Perl on dotCloud

Yes, it is !!! Soooo easy to deploy a demo about my Perl webapp on dotCloud.

Here it is: pnidemo-fibo.dotcloud.com

Powered by CPAN and thanks to this Mojolicious trick, all stuff I need is packed in my PNI distro, included JavaScript libs like jQuery and Kinetic, .css and other assets.

I red this article Mojolicious in the cloud, but it is outdated, since dotcloud "run" command seems to be deprecated.

My dotCloud app is called "pnidemo" and it is just a thin wrapper around my pni Mojolicious app.

I putted all inside a misc/dotcloud dir in my github repo.

Before you start, to make it work, stand up and click the next link

1. Install dotcloud CLI, refer to dotCloud docs.

2. Create dotcloud app.
$ dotcloud create pnidemo

3. Configure it.
$ mkdir -p misc/dotcloud
$ cd misc/dotcloud
$ vim dotcloud.yml

    type: perl
    approot: pnidemo

4. Add your deps, included your CPAN distro, for instance PNI.
Following dotCloud docs, Plack, Test::More and YAML should be always included.
$ mkdir pnidemo
$ cd pnidemo
$ vim Makefile.PL

#!/usr/bin/env perl
use ExtUtils::MakeMaker;
    PREREQ_PM => {
         'Plack'         => 0,
         'Test::More'  => 0,
         'YAML'       => 0,
         'PNI'           => 0,

5. Copy original Mojolicious app and create an app.psgi that requires it.
$ cp ../../../bin/pni .
$ vim app.psgi

require 'pni';

6. Now just deploy it with dotcloud CLI.
$ cd ..
$ dotcloud push pnidemo

It will install all deps with cpanm, and that's all !

Ah, one last cool feature is that when you are ready to upgrade your app, just release it on CPAN and update the Makefile.PL with last version,

for instance
         'PNI'           => 0.30,

then launch
$ dotcloud push pnidemo

and you're done! Soooo easy (: