How to create an installable web application with config/data/bin stuff?

I'm writing a Dancer2 web application which contains configuration (config.yml, development.yml, production.yml, and-so-on.xml), application data (js, css, templates) and application binary (Perl bootstrapper, Perl tools) parts.

Usualy a web distribution is installed via extracting a ZIP file and there you have your e.g. /public, /environments, /lib and /bin. You start your web application with perl ./bin/app.pl or similar.

What I currently think about is to actual install a Dancer2 web application like normal (linux/unix) applications would do. So /public would end up at /usr/share/mydist/public, /views would be /usr/share/mydist/views, /environments including /config.yml are located at /etc/mydist/environments and /etc/mydist/config.yml. /logs moved to /var/log/mydist and /lib is system wide installed like you install a normal dist with cpan. Scripts in /bin would "installed" to /usr/bin

Assuming I use Dist::Zilla to create dists how could I achieve this?

I remember there was a previous discussion about installing web application with CPAN but I can't find it anymore. Neither - IIRC - was the discussion concluded.

4 Comments

This may be useful to you:

https://metacpan.org/pod/File::ShareDir

Here is something I had bookmarked from YANICK as well:

http://techblog.babyl.ca/entry/app-chorus

YMMV. Good luck.

Different Linux/Unix flavours keep their files in different places.

I'd recommend installing stuff in the standard CPAN places, and rely on people packaging your application for specific distributions (Fedora, Debian, etc) to patch it to put everything in the right places.

I've used File::ShareDir to root website assets for a personal project, but I've been cautioned against putting config in there. Config you want to be able to edit without rereleasing.

Leave a comment

About burnersk

user-pic I blog about Perl.