Static Website with Hyde
Preconditions: nginx, gitolite
Create /etc/nginx/sites-available/www-example-com
and symlink to sites-enabled:
server {
listen 80;
server_name www.example.com;
server_name_in_redirect off;
access_log /var/log/nginx/www-example-com.access.log;
root /srv/www/www-example-com;
index index.html;
try_files $uri $uri.html $uri/index.html /index.html;
}
Create docroot:
# mkdir /srv/www/www-example-com
# chown git:git /srv/www/www-example-com
# chmod 755 /srv/www/www-example-com
Install Python and Hyde within an virtualenv:
# aptitude install python python-pip python-virtualenv
# umask 0022
# virtualenv /srv/www/hyde-virtualenv
# source /srv/www/hyde-virtualenv/bin/activate
# pip install --upgrade distribute
# pip install hyde
Create repository in gitolite-admin conf/gitolit.conf
:
repo www-example-com
RW+ = foobar
Add a post-receive hook /srv/gitolite/repositories/www-example-com.git/hooks/post-receive
that generates and publishes the website on git push
:
#!/bin/bash
GIT_REPO=$HOME/repositories/www-example-com.git
TMP_GIT_CLONE=/tmp/www-example-com
HYDE_VIRTUALENV_ACTIVATE=/srv/www/hyde-virtualenv/bin/activate
DOCROOT=/srv/www/www-example-com
echo
echo Cloning repo:
git clone $GIT_REPO $TMP_GIT_CLONE
echo
echo Generating site:
source $HYDE_VIRTUALENV_ACTIVATE
cd $TMP_GIT_CLONE
hyde gen
echo
echo Synchronizing generated site to $DOCROOT:
rsync -av --chmod=go=rX --delete deploy/ $DOCROOT
echo
echo Cleanup
cd ~
rm -rf $TMP_GIT_CLONE
echo
Sources: