Sep
07
2011

The final solution for Git-versioned web development, part 3 - deploying changes on the server

IT

This is last part of three part guide, which will show how to use Git for versioning your web framework, files, database and also using it for deployment. Here is explained the most powerful thing about using Git - deploying only changed files. » pernament link

Other parts of this guide:


Everyone who has been doing web development probably knows very well how painful is uploading thousands of small files on remote FTP server. It just takes forever. But if you try to manually upload only what has chaned, it's error-prone and not trivial. With Git these problems just fade away.

Recommended workflow

It's good to have some well known routine, because that way you don't forget anyting and won't do any mistakes. I recommend something like following:

  1. Check for updates on remote Git server (if you have any) and in framework. If there is any change, don't forget to commit the submodule update.
  2. Make changes in files.
  3. Make changes in database using script from previous part.
  4. Commit all changes and make sure nothing is left uncommited.
  5. Run dump.sh and upload the changes to remote FTP server and database (see below).

The Script

The script dump.sh is saved in website root. It takes two optional parameters: revision from which to make dump (defaults to previous revision) and path where to save dump files (defaults to parent dir). It creates two files, one with dump of database (without readonly tables) and one tarball with files changed since given revision. Contents of the tarball can be then easily uploaded to the FTP server.

#!/bin/bash
 
# Database tables to exclude from dump
readonly="statistics discussions"
 
# Access to the database
user=myusername
database=mydatabase
password=mypassword
 
# Base part of filename of database dump and tarball
filename=myweb
 
ignore=
for i in $readonly ; do
    ignore="$ignore --ignore-table=$database.$i"
done
 
outPath=../
revision=HEAD^
if [ $# -eq 2 ] ; then
    outPath=$2
    revision=$1
else if [ $# -eq 1 ] ; then
    revision=$1
else
    echo "Usage: $0 [revision] [outPath]"
    exit
fi
 
# If the framework submodule (in engine/ subdir) changed, dump changes from
# there, too
engine=""
if [ -n "$(git log --name-only --pretty=format: ${revision}.. -- engine)" ] ; then
    previousRevision=$(git diff --pretty=format: ${revision}.. -- engine | \
        cut -d" " -f 3 | tail -n2 | head -n1)
    currentRevision=$(git diff --pretty=format: ${revision}.. -- engine | \
        cut -d" " -f 3 | tail -n1)
    cd engine
    engine=$(git log --name-only --pretty=format: ${previousRevision}..${currentRevision} \
        -- . | grep ^web | uniq | awk '{OFS=""; print "engine/",$0}')
    cd ..
fi
 
# Archive changed files (from web/ and engine/ subdirs)
tar --exclude=*.git --exclude=*~ --dereference \
    -czvf ${outPath}${filename}.tar.gz \
    $(git log --name-only --pretty=format: ${revision}.. -- . | grep ^web | uniq) $engine
 
# Archive database
mysqldump -u ${user} -p ${database} \
    ${ignore} > ${outPath}${filename}.sql

This script has of course some bugs (such as tar printing errors about nonexistent files when they were deleted by git), but it does its job fairly well.


Jul
24
2011

The final solution for Git-versioned web development, part 2 - versioning database

IT

This is second part of three part guide, which will show how to use Git for versioning your web framework, files, database and also using it for deployment. This part explains how to use Git for versioning database structure and data. » pernament link

Mar
21
2011
» Česky «

Kompas 0.1.2 - packaged for your favourite distribution

IT

This version finally brings packages for openSUSE, Fedora, Mandriva, Ubuntu and Debian. Besides that, there is a new historical map plugin and also some crash fixes. » pernament link

Jan
20
2011

Porting Kompas to Symbian - is it actually possible?

IT

If Kompas is described as "multiplatform", it must deserve this label. So I'm trying to port it to mobile devices, where it would be far more useful than just on the desktop. I don't have any of those MeeGo, Maemo, iOS or Android-powered devices where application development is a breeze. My smartphone runs Symbian and developing something bigger than prefabricated Hello World is a huge pain. » pernament link

Jan
15
2011
» Česky «

Kompas 0.1.1 - a few fixes and many new map plugins

IT

Kompas is already quite usable, let's make it also useful. This update brings new plugins for Bing, Yahoo, Ovi Maps and more, fixes some issues in map view and improves layout in Map Options dock. » pernament link

Jan
02
2011
» Česky «

Map2X is dead, long live Kompas - multiplatform navigation software

IT

After half an year of heavy development I can finally introduce Kompas - application, which goal is to bring powerful and easily extensible navigation software to as many platforms as possible. » pernament link

Nov
09
2010

The final solution for Git-versioned web development, part 1 - versioning framework and files

IT

I am using Git exclusively for almost everything I'm working on and while it's a great tool I must admit that using Git for web development is the most tricky. There is a database which really has to be versioned, external frameworks which are regularly updated and everything needs to be uploaded as quickly as possible to remote FTP server. I will explain in this multi-part guide how everything can be managed with Git without any fork-in-the-eye feeling. » pernament link

Sep
26
2010

HeyTrack 1.0 alpha 2 released

IT

One week after first release there is second alpha version. New Amarok player, SomaFM server and Russian translation are the most significant changes. » pernament link

Sep
19
2010
» Česky «

HeyTrack - the thing you always wanted but didn't know about

IT

Generally, when you want to play some internet radio, you either have to install bloated browser plugins, or, do someting even worse - dig in crappy HTML sources and look for something what looks like stream URL so you can play it in your favorite player. Awesomely annoying. And this is why HeyTrack is here, it does the hard work entirely for you. » pernament link

Sep
18
2010

Side effects ...of deploying application to Windows

IT

Yesterday I wanted to test HeyTrack (which will be hopefully released this weekend) on Windows to make sure there are no serious bugs which will put me in shame. But, in the end, the fact that HeyTrack runs on Windows is only a side effect. The result is many fixed bugs, but none of them was in HeyTrack. » pernament link