Wednesday, July 13, 2011

Perl Module Versions in dotcloud

I just realized that I was running an older version in my dotcloud service. There was an update due to a security issue so it was kind of important.

I found that I needed to update (or put) a version number in the Makefile.PL. Here is an example of mine.

Before:
use strict;
use warnings;
use ExtUtils::MakeMaker;

WriteMakefile(
    NAME                => 'leecarmichael',
    AUTHOR              => q{Lee Carmichael },
    VERSION_FROM        => 'lib/leecarmichael.pm',
    ABSTRACT            => 'Home Site',
    ($ExtUtils::MakeMaker::VERSION >= 6.3002
      ? ('LICENSE'=> 'perl')
      : ()),
    PL_FILES            => {},
    PREREQ_PM => {
        'Test::More' => 0,
        'YAML'       => 0,
        'XML::RSS'   => 0,
        'URI'        => 0,
        'Date::Parse' => 0,
        'Digest::MD5' => 0,
        'Plack'       => 0,
        'Plack::Request' => 0,
        'Template'       => 0,
        'Dancer'         => 1.3040,
        'Dancer::Plugin::MobileDevice' => 0,
        'Dancer::Plugin::Email'        => 0,
        'Dancer::Plugin::FlashMessage' => 0,
        'Dancer::Plugin::Database'     => 0,
        'Dancer::Plugin::XML::RSS'     => 0,
        'Dancer::Session::Storable'    => 0,
        'DBI'        => 0,
        'DBD::mysql' => 0
    },
    dist                => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
    clean               => { FILES => 'leecarmichael-*' },
);

My updated one has version of Dancer changed to:
'Dancer' => 1.3060,

I like this approach to module version management. If you want to force the system to move to everything new you'd need to delete your service and recreate then push. If you want to force just a single CPAN module up to the most recent you update the version number.

It probably will require me to create a script to compare versions between the service and local dev/qa machines. Better put that on the TODO list :)

__END__

Making sure dotcloud serves static files not Dancer

Dancer is a great framework. It does a great job making a default development work out of the box. Its a nice alternative to some of the heavier ones that require quite a bit of setup (actually most Perl web frameworks do a great job of this).

Also it makes sure to serve static content (to avoid deployment issues, I assume). But compared to nginx or apache it is much slower at serving this (not a big surprise). In my dotcloud deployments I've found this to be a bit confusing to make sure nginx handles it instead of Dancer.

My first pass at this was setting up these symlinks in my source tree:
static/css         --> ../public/css
static/javascripts --> ../public/javascripts 
and such.

It felt wrong to have this inside source control so I dug around a bit and ran into the postinstall script that is supported by the deploy dotcloud command option.

I added the following link commands to mine to create those nice symlinks:
#!/bin/sh

# used for dotcloud deployment

# setup static symlinks
ln -s ../public/images static/
ln -s ../public/css static/ 
ln -s ../public/javascripts static/
ln -s ../public/favicon.ico static/favicon.ico

Nice, pretty and only used for dotcloud deployments.

__END__