Friday, December 2, 2011

Re: How to deploy new code to the Production Server?

I considered it very important to be able to keep all configurations
under revision control and have the ability to review the changes
between what is live, what is tested and what is in development. As
soon as you start leaving things out of revision control (for example
as someone recommended earlier, skipping settings.py), you are IMO
asking for trouble and it is probably a sign that your processes are
broken. :-)

I use git branches to manage my differences between development,
production and testing. Everything that matters at all is in git, I
can rebuild my entire site using a script which also lives in git.

Now, obviously each of these environments will be slightly different -
at the very least domain names and port numbers will differ and in my
case I also use mock back-end databases during development and real
ones in testing and production. Also, the deployment scripts
themselves (I am a dinosaur who uses ssh, rsync and makefiles) are
different on each branch.

So all three branches are different, and I don't want to risk losing
the differences when I merge. But aside from these deliberate
deviations, I want to keep the three branches as closely synchronized
as possible.

They key to making this work, is all development happens on the main
branch, and production and testing branch off dev and are updated
using the `git rebase` command. If you don't know `git rebase`, I
highly recommend learning it, it's like magic. :-) When I update my
production branch it automates these steps:

1. reverts all differences between production and the dev branch point
2. applies the development progress (moving the branch point to the head)
3. reapplies the patches that got reverted in 1.

Basically, this moves the branch point forward, bringing both branches
back in sync without losing the deliberate deviations.

Sometimes there is some manual work involved in resolving conflicts,
but that is a good thing as those are generally things which have
changed and deserve extra attention during deployment.

At any time if I want to compare what is in production with the
testing or development trees, I can just run `git diff production` or
`git diff testing` to see all the differences.

I've been working this way for a bit over a year, developing and
running the pagekite.net site and service, and I really like it.

--
Bjarni R. Einarsson
Founder, lead developer of PageKite.

Make localhost servers visible to the world: http://pagekite.net/

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment