Category Archives: Dotcloud

Deploying My Perl Application to dotCloud

dotCloud provides an easy way for you to show your Web application to the world.

This is how I deployed my Moving Company Travel Time Calculator on dotCloud.

Create the dotCloud application.

traveltime > dotcloud create traveltime
    ==> Creating a live application named "traveltime"
    ==> Application "traveltime" created.
        Connect the current directory to "traveltime"? [Y/n]: Y
    ==> Connecting with the application "traveltime"
    ==> Connected with default push options: --rsync

It looks like the application has been created. I then created a configuration file, “dotcloud.yml”.

www:
  type: perl
  approot: traveltime
  requirements:
    - App::cpanminus

Then connect..

traveltime > dotcloud connect traveltime
    ==> Connecting with the application "traveltime"
    ==> Connected with default push options: --rsync

I need to tell “app.psgi” who my Dancer2 script is.


traveltime > echo "require 'bin/app.pl';" > app.psgi
  

Then deploy the application


traveltime > dotcloud push
    ==> Pushing code with rsync from "./" to application traveltime
        building file list ... done
        ./
        dotcloud.yml
        .dotcloud/
        .dotcloud/config
        traveltime/
        traveltime/Changes
        traveltime/MANIFEST
        traveltime/MANIFEST.SKIP
        traveltime/Makefile.PL
        traveltime/README.pod
         ...
         14:34:17.360184: [www] Successfully installed Dancer2-0.04
         14:34:17.539632: [www] <== Installed dependencies for .. Finishing.
         14:34:17.540369: [www] 49 distributions installed
         14:34:22.529592: [www] Build completed successfully. Compiled image size is 11MB
         14:34:22.548716: [www] Build successful for service (www)
         14:34:22.563869: --> Application (traveltime) build is done
         14:34:22.582326: --> Provisioning services... (This may take a few minutes)
         14:34:22.599485: [www] Using default scaling for service www (1 instance(s)).
         14:34:22.651213: [www] Using limits for service "www": ram=64M
         14:34:22.696068: [www.0] Provisioning service (www) instance #0
         14:34:27.002331: --> All services' instances have been provisioned. Installing code...
         14:34:27.015045: [www.0] Installing build revision rsync-1371306712243 for service (www) instance                    #0
         14:34:34.852233: [www.0] Running postinstall script...
         14:34:35.582842: [www.0] Launching...
         14:34:36.905954: [www.0] Waiting for the instance to become responsive...
         14:34:37.910787: [www.0] Re-routing traffic to the new build...
         14:34:38.031666: [www.0] Successfully installed build revision rsync-1371306712243 for service  (www) instance #0
         14:34:38.039928: [www.0] Installation successful for service (www) instance #0
         14:34:38.043176: --> Application (traveltime) fully installed
    ==> Application is live at http://traveltime-aibistin.dotcloud.com
    [10:34 - 0.20]
    traveltime > 


I then checked the URL http://traveltime-aibistin.dotcloud.com, which gave me an error.

"uWSGI Error
Perl application not found"

So off to the log files to check what went wrong.

 traveltime > dotcloud logs www
[www.0] ==> /var/log/supervisor/supervisord.log <==
...
cloud/rsync-1371314776610/traveltime/config.conf: Cannot load /home/dotcloud/rsync-1371314776610/traveltime/config.conf: required support modules are not available.
[www.0] Please install Config::General at /home/dotcloud/perl5/lib/perl5/Dancer2/Core/Role/Config.pm line 97
[www.0]  at (eval 35) line 19
[www.0] BEGIN failed--compilation aborted at bin/app.pl line 3.
...
[www.0] ==> /var/log/nginx/access.log <==

So it looks like dotCloud couldn’t find Config::General CPAN module. It looks like I didn’t do such a good job managing my modules dependencies. I could have used the Behemoth of Module creation Dist::Zilla to do this. However as this is not an app that I wish to upload to CPAN, or install on my laptop I wanted an easier way.

I came across this new “Bundle I searched the CPANfor another way. r for Perl” developed by the prolific and excellent Pearl developer Tatsuhiko Miyagawa. So I figured it must be good. And it is. I won’t bore you with the details here, as you can read his documentation yourself.

I now seem to have all my dependencies in order and I ran the “dotcloud push” command again. I ran into another problem. I was running Perl 5.12 on my Ubuntu laptop, and dotCloud needs at least Perl 5.14. Well I guess it was about time that I upgraded my Perl version. This took a while, as I decided to load perlbrew to manage my Perl installations.

I ran into a few glitches here and there, but I finally got it working with lots of help from KENTNL’s perlbrew blog,and a little help from DA Golden’s blog.
So, it’s time to try again from scratch.


traveltime > dotcloud destroy
    Destroy the application "traveltime"? [y/N]: y
    ==> Destroying "traveltime"


dotcloud create traveltime
    ==> Creating a live application named "traveltime"
    ==> Application "traveltime" created.
    Connect the current directory to "traveltime"? [Y/n]: y
    ==> Connecting with the application "traveltime"
    ==> Connected with default push options: --rsync

OK, looking good so far. Now, I have my dotCloud “traveltime” application up and running. I’m not too happy with the domain name that I have been issued by dotCloud, “http://traveltime-aibistin.dotcloud.com”.
So, I decided to change this to one that I already have.


TravelTime > dotcloud domain add www www.carryonmoving.net
    ==> domain "www.carryonmoving.net" created for "www"
    ==> Now please add the following DNS record:
        www.carryonmoving.net. IN CNAME gateway.dotcloud.com.

Then update my DNS settings on CloudFlare and I’m done.

The “finished” (well almost) App Moving Company Travel Time Calculator can be viewed here.

Useful Links

This is where I got lots of helpful advice for this endeavour.

  1. dotCloud Perl Tutorial
  2. Dancer2 Deployment With dotCloud
  3. Marco Fontani’s Dancer Deployment with dotCloud piece, on blogs.perl.org
  4. Perl Mongers dotCloud Presentation (which I just found)
  5. Phillip Smith’s Catalyst with dotCloud piece, on blogs.perl.org