I have used Capistrano to deploy a complex web site before, but I have recently looked to Makefiles for a simple solution.
I will describe the project and situation where I have successfully used a Makefile to deploy a static website - this situation does not require complex tasks that capistrano would be able to handle - and certainly can't do rollbacks. If you are deploying something complex then please use a proper deployment tool.
The project builds an HTML website using a yaml config file (config.yaml), a bunch of chapters written in markdown (input/*.md), templates written in Dotiac::DTL (template/*.html) and a Perl script build.pl.
Running build.pl builds HTML files in an output directory (output/*.html) using the aforementioned parts.
Some targets in our Makefile include:
Our Makefile looks like this:
ARCHIVENAME=$(shell grep Title config.yaml | sed -e 's/ *Title: //;s/ //g;')
DATESTAMP=$(shell date '+%Y%m%d')
ARCHIVEDIR=archive
OUTPUTDIR=output
HOST=targethost.com
HOSTCOPYDIR=/home/www/docroot
HOSTTARGETDIR=/home/www/docroot/mysite
all: clean input output
perl build.pl
archive: archivedir
cd ${OUTPUTDIR} && tar -cjf ../${ARCHIVEDIR}/${ARCHIVENAME}-${DATESTAMP}.tar.bz .
deploy: all archive
scp ${ARCHIVEDIR}/${ARCHIVENAME}-${DATESTAMP}.tar.bz ${HOST}:${HOSTCOPYDIR}
ssh ${HOST} mkdir -p ${HOSTTARGETDIR}
ssh ${HOST} tar -xjvf ${HOSTCOPYDIR}/${ARCHIVENAME}-${DATESTAMP}.tar.bz -C ${HOSTTARGETDIR}
archivedir:
mkdir -p ${ARCHIVEDIR}
clean:
rm -rf ${OUTPUTDIR}
rm -rf ${ARCHIVEDIR}
output:
mkdir ${OUTPUTDIR}
Now whenever I make a change to an input markdown file I can just run make deploy and the production site will get updated.
As you are no-doubt aware, I am developing this blog with the aid of Git. Since it is just me, I am working on master and intend on releasing straight from there. (On a larger project you might branch first, create release candidates etc, and then eventually tag and release from the branch.)
So, to tag and release from master, I followed this process:
$ git branch
* master
... confirms I'm on master.
$ git tag 0.1
... creates my 0.1 release as a tag from master.
$ git archive --format=tar --prefix=vnv-v0.1/ 0.1 | gzip > vnv-v0.1.tar.gz
... creates a gzipped tarball from the 0.1 tag. The prefix specifies the root directory that the tarball will explode to. (Don't forget that trailing slash.)
$ ls *tar.gz
vnv-v0.1.tar.gz
Nice!
$ mv vnv-v0.1.tar.gz /tmp/
$ cd /tmp/
$ tar -xzf vnv-v0.1.tar.gz
$ ls vnv*
vnv-v0.1.tar.gz
vnv-v0.1:
README SETUP* code/ db/ deploy.pl* dist/ doc/ media/ template/
... if prefix had been XXX then the tarball would still be called vnv-v0.1.tar.gz but it would have exploded to a directory called XXX/
Django Python 960.gs Git Vim NetBSD Nginx
This is the blog of Brad Willis, a software engineer living in Brisbane.
Help
Latest entries
*BSD Agile Apache Apple apt Athletics Best-Practice Censorship Comedy Cool Crosswords Deployment Django English Exim Firefox Git Hardcore Health irssi Javascript Jira Languages Linux Makefile Mathematics Mobile Broadband Mutt MySQL NetBSD nginx Nokia OpenVZ OSX Perl Privacy Python Rant Requirements rsync Ruby Shell Slackware SQL SQLite SSH Standards Subversion Television Testing ThisBlog Vim VMWare (Fusion) VPN X zsh
Checking for exceptions in doctests
Homer's Curling Speech
retry in Python
Vim Makefile tabs
Centos (or RH) IPTables
Converting ssh2 public keys to openssh
Vim comment hints
Context managers in Perl
Dish rotation
Git - fixing commit user
apt stuff
Using shell variables in AWK
Linux - Too many open files
Tell gvim to save and quit... remotely
Vim - automatically remove whitespace at EOL
Python - relative paths from within modules
TV Aspect Ratios
Git - Which commits are in your branch only?
Subversion setup cheat sheet
Force detach a screen session
Modify sudo's use of environment variables
Install all Perl modules
Mutt - delete old messages
OpenVZ VPS and swap space
fail2ban on NetBSD for ssh
NetBSD - Using sup
Python - testing for a sys.exit
Python Best Practice Link Dump
Python script names
Perl - Using an expensive module
Speed of git clone
Perl Modules with Custom Prefix
Perl: tr vs. s
Brilliant sysadmin Reference
Why is GRUB better than LILO?
Why is swap space important?
Perldoc Output
Git's Index
Jira Project Keys
Git GUI