My Perl deployment setup
How I make deployments convenient
For some of my modules, I also run a demo website that shows off the features and use of each module. Case in point, HTTP::Request::FromCurl has an online converter on my website.
I like to use
git as my deployment tool, becuase it conveniently abstracts
the packaging and transport. Basically, a deployment becomes
git push demo
The main magic is just a small program (called a "git hook") on the remote
machine that gets run by
git whenever I push a new version to the remote
repository. This git hook is a shell script which looks like the following:
#!/bin/sh git --work-tree=/home/corion/github-rss --git-dir=/home/corion/GitHub-RSS.git checkout -f PERL5LIB= /home/corion/perl-5.24/bin/cpanm --installdeps /home/corion/github-rss -l /home/corion/github-rss/extlib # Migrate the database # We use the system Perl here... PERL5LIB= /home/corion/bin/update-db.pl --from dbi:SQLite:dbname=/home/corion/corion.net/github-rss/issues.sqlite --to HEAD --file sql/create.sql --git-dir /home/corion/GitHub-RSS.git/
The second line checks out the git repository from
The third line updates all prerequisites from CPAN into a local directory
/home/corion/github-rss. This means that for every demo site, I have
a complete library installation. The upside of that is that I can migrate each
demo site to a new Perl version individually.
The fourth statement is for database migrations and . automatically migrates the database to the new version. Hopefully all my schema changes can be done lossless or I have an intermediate change that introduces the new schema without destroying the old schema.
The code for
update-db.pl and the
post-receive hook live in
the deployment/ directory of my distribution template.