Website Releases via Subversion (SVN)
One of the best uses that we have put subversion to is a way to handle code releases to live web servers. It has a number of major benefits over other methods of releasing web sites.
For example, when using FTP you have the option to copy over the site each time which leaves lots of old files hanging around if you remove files from you website.
Alternatively you can upload a complete new copy of you code, which can take a considerable amount of time for a large code base, and you then have to switch the running to the new code.
Using subversion gives the following benefits:
- Simple and fast to do a site release
- Can always check that the versions of files on the server are what you think they are
- Automatically removes files from live servers that are no longer used and have been removed in the subversion repository
- Can show you if any files have been changes or added to live site
- Easily move back and forward between releases
- Simple to keep multiple servers (cluster) in sync.
- Security considerations
- Conflicts in code-base if people edit on live (which is a big No, No)
The main security consideration is that a working copy of a subversion repository contains a duplicate copy of the current version in .svn directories which allows for quicker compares as it is a local file compare not a network operation.
However, this would allow a crafty hacker to browse to www.example.com/.svn/ and potentially get access to view the code of the pages that run your website which is always a bad thing.
We can manage this issue however thanks to the very customisable security in apache (assuming you are using it) to disallow access to all directories with .svn in it.
<Directory ~ "\.svn">
Order allow,deny
Deny from all
</Directory>
Note: It may be possible to do the same with IIS, so please let me know if it is.
To check out a project/website into the current directory use:
Then when it comes around to doing a release to the next version you use
Easy as that!

Have you looked at anthill and cruise control automated build and release tools?
I haven't come across anthill or cruise control, I'll add them to my list of software to evaluate. Do you have any experience with these? Any recommendations?
Cheers,
Mark
Definitely both worth evaluating, think they would fit nicely into to how you are working already. i.e building sites directly from subversion.
Dave - I'm looked into rsync briefly and it does do pretty much everything I'm doing, except that it does not do a direct checkout from subversion - so going the Rsync route would actually add another step to the process. It may be that it will be a useful step down the track so I'll keep it in mind.
Cheers,
Mark
However, I have a 1.2 GB site, and using rsync for it is very slow. I'm probably going to have to keep working copies on the live server, and update those (as is outlined in the blog).
Unfortunately, I haven't figured out yet how to deny access to .svn directories in IIS.
Also, any way to restrict files. Like for example, if you have multiple servers in a cluster, and a config file that has server specific paths, how do you control releasing these files between servers in the cluster?
Some examples of using SVNKit in CF:
http://code.google.com/p/cfdiff
http://www.skweegee.com/
I have no access to ssh in my webserver, so I tryed mounting my ftp account in my local filesystem using fusefs-curlftpfs but it didnt work :(
I'm searching about it for a while and i can't find a good solution for it.
There is also a piece of code named ftpsync that aims to sync local folders with ftp folders. But I couldn't figure out how to set exclude folders and files to it.
Any ideas will be welcome.
:)
Protecting files
You can use standard ASP.NET 2.0 content protection techniques. For example, you can deny access to all .xsl files by adding this snippet to <httpHandlers /> section in Web.config:
<add path="*.xsl" verb="*" type="System.Web.HttpForbiddenHandler" />
Alternatively, you can protect any folder by placing this Web.config file in it:
<?xml version="1.0"?>
<configuration>
<system.web>
<authorization>
<deny users="*" />
</authorization>
</system.web>
</configuration>
So i guess the first method would work. I have not been able to test this effectively however as I can't work out how to access the .svn files anyway. Perhaps down to the mime types not being recognised? Or user permissions? So it may not be an issue but if anyone else has further input I would be interested to hear.