Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I control a Dancer webapp's deployment?

Tags:

perl

dancer

Say I have a self-contained Dancer webapp. I can deploy it to a host by running a make dist, getting a tarball then installing it via cpanm or similar. However, I can't seem to find how to control this deployment. When I just make dist on the app, then install the application elsewhere, it just seems to install the application's modules. However, the application script, the various html files and templates, the environment config files aren't getting installed to the local filesystem.

What's the correct way to go from webapp on system a -> tarball -> webapp on system b?

Edit:

Sorry, I should have clarified that I understand I can do the whole thing manually. I'm simply surprised there's no quick way to do an installation with a couple commands, or specify in the app itself where it feels the various components can install.

As I use cpanm for the most part, that simplifies things on system B as I can just extract it to a directory, change to it, run 'cpanm .' and it installs dependencies and the app's modules to the system lib.

However, this leads to having the app modules both in <>/lib/ as well as the system perllib install path. It also means the user needs to understand a bit about perl.

I guess I'm just trying to find out if things have changed since What's the best system for installing a Perl web app? was asked three years ago. With all the advances in modern Perl state of the art it seems like this is the sort of problem that'd have been handled by now.

like image 879
Oesor Avatar asked Jun 10 '11 16:06

Oesor


1 Answers

Here is one way. Create your app on system-a:

dancer -a Foo
cd Foo
perl Makefile.PL
make dist
scp Foo-0.1.tar.gz system-b:
ssh system-b

On system-b:

sudo tar xf Foo-0.1.tar.gz -C /opt
cd /opt/Foo-0.1
perl Makefile.PL # this will tell you the deps you need to install
# install needed deps if any
make
sudo make install
./bin/app.pl # this starts your app

This approach installs your app to /opt/Your-App. All of your config files, scripts, etc. will be self contained in one folder.

Something you may want to consider is bundling all of your deps with your app. You would do this on system-a. (Note that this requires system-a and system-b to have the same architecture) An easy way to bundle your deps is with App::cpanminus:

cpanm -L extlib Dancer Plack YAML # and any other deps

Then when you deploy start your app, you would do something like:

perl -Ilib -Iextlib/lib/perl5 -Iextlib/lib/perl5/x86_64-linux ./bin/app.pl

This approach makes it so you don't have to install anything on system-b. You can just extract your app and run it.

like image 104
Naveed Avatar answered Sep 20 '22 15:09

Naveed