One Click Django Project Publishing

I was reading The Joel Test and I got to number #2 which says "Can you make a build in one step?" My initial thought was that there aren’t really builds per se in web applications (unless you use ASP.NET). But then I thought, I wonder if I could make publishing my Django application a one step process. So that’s what I set out to do.

Here are the manual steps I go through to publish my Django App:

  1. Commit my code changes to Subversion (I use TortoiseSVN – Yes, I’m running Windows)
  2. Log in to my Webfaction account via SSH using PuTTy.
  3. Run a subversion update on media folder
  4. Back up my settings.py file for good measure
  5. Run a subversion update on my Django application folder
  6. If there were model additions, run manage.py syncdb
  7. Restart apache for good measure

Ok, so maybe the title of this post is a bit misleading because I did not automate step one. Let me explain why though. When I commit code, I sometimes leave debug code in where I don’t want to. I live to verify that I’m not committing changes that shouldn’t be there so I often look at diff files in TortoiseSVN before I commit. That’s just one step that I prefer to keep my eyes on. I suppose you could say that it’s not really part of the publishing process and we assume that publishing comes after committing code changes then yeah, it’s still one step.

My solution is actually a combination of two scripts. I found this app called Plink that is basically PuTTy for your command line. Inside my Django project folder I’ve created a batch script called publish.bat which contains the following:

@echo off
plink -ssh MYDOMAIN.com -l MYLOGIN -pw MYPASSWORD ./update.sh
pause

This essentially logs in to my server via SSH and runs a shell script. Here are the contents of that shell script:

cd webapps/media
svn update
cd ../myapp/myapp
cp settings.py settings.backup.py
svn update
python2.5 manage.py syncdb
../apache2/bin/restart

That’s basically it. Now I just commit my code and when I want to publish I just double-click on publish.bat and I’m done.

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

May 15, 2009 Ā· Dustin Ā· 20 Comments
Tags: , , , , , ,  Ā· Posted in: Programming & Internet

  • http://arthurkoziel.com Arthur

    You may want to take a look at Fabric: http://docs.fabfile.org/
    For me, it’s just a “fab deploy” to deploy.

  • http://squarefactor.com bill

    +1 on Fabric

    fab deploy FTW!

  • http://www.jonasundderwolf.de Jonas

    No kidding… put South into the mix and ./manage migrate into your fabfile and you can even deploy database changes in one step.

  • http://www.nerdydork.com Dustin

    Thanks guys. I haven’t heard of Fabric before. I just saw South yesterday and I was going to look into it. I wanted to get something for migrations so I could be as cool as those smug Rails developers ;)

  • http://jetfar.com Rich

    Fabric offers the bonus that you can have multiple tasks inside the one wrapper.

    This means that you can have one script to do for example:

    fab deploy2test
    fab deploy2prod
    fab rollback-prod (assuming your fab task kept track of the previous SVN revision).

    Cheers!

  • http://jetfar.com Rich

    PS: If you try South (http://south.aeracode.org/) let us know how you go!

  • http://melbourne.at9t.com/ å¢Øå°”ęœ¬

    This is a very useful project!
    Thanks for sharingl

  • vishal

    Hi Dustin
    where did yu place yur file ./update.sh on server?

  • http://www.drivenz.co.nz/home/ Melvin@Car Hire New Zealand

    Automation has always been greek and latin to me. Dustin, I think I have to read your posts several times to get what is on my mind. I was thinking about a automated script to enhance the ip address look up of hosted pages. I know there are several apps available already, but I wish to do some custom made app with some niche features.

  • http://nicheblueprint2bonus.org Alex @ Niche Blueprint 2 Bonus

    I also use Fabric – it works very well. On another note – can you tell me where you got the theme for this blog? Cheers!

  • http://tzangms.com tzangms

    Try fabric, you can do more things easily with fabric.

  • Craig @ Instant Money Code Bonus

    I’ve read that Django was designed to be used in a newsroom situation…supposedly it is good for building applications although the very idea of doing so scares the heck out of me!

  • ismail

    Personally, i use git,

    git push prod,

    and then i have a bunch of hooks that run commands. I.e restarting the server etc.

    • Anonymous

      WideĀ  selection of women’s swimwear. Many forms, so that you feel your body [url=http://www..sexybikinissunglass.com/bikinisswimwear-dior-bikinis-c-153_204.html]Dior Bikinis[/url] comfortable, but very nice. Bikini swimsuit is the most popular works. Wearing a bikini can make you feel sexy and beautiful asĀ  you relax andĀ  enjoy the warm sunshine and water. It continues to beĀ  the most one piece of clothing for women.Ā  Push the envelope further, to provide some small micro bikini is a Armani Bikinis pure material, when the sun shines through at the right angle and the [url=http://www..sexybikinissunglass.com/bikinisswimwear-billabong-bikinis-c-153_196.html]Buberry Bikinis[/url] proceedings [url=http://www..sexybikinissunglass.com/women-aff-bikinis-on-sale-p-1244.html]AFF Bikini[/url] areĀ  wetĀ  look. While this may be an exciting bikiniĀ  to Buberry Bikinis wear attention and show AFF Bikini off your assets, there is a public place isĀ  allowed on this swimsuit controversy. Making Chanel Bikinis this change is not easy. However, please remember to wear your [url=http://www..sexybikinissunglass.com/bikinisswimwear-billabong-bikinis-c-153_196.html]Buberry Bikinis[/url] bikini-style a few days this summer, Dior Bikinis when youĀ  lose allĀ  momentum. These changes will make you feel better, [url=http://www..sexybikinissunglass.com/chanel-bikinis-p-1113.html]Chanel Bikinis[/url] have more energy, living a healthier lifestyle, and all look forward to Sinful BikinisĀ  the greatestĀ  new Buberry Bikinis bikini! [url=http://www..sexybikinissunglass.com/discount-women-sinful-bikinis-online-p-1063.html]Sinful Bikinis[/url] Women’s [url=http://www..sexybikinissunglass.com/sexy-armani-bikini-swimwear-outlet-p-1256.html]Armani Bikinis[/url] swimwear in times controversial
      but always in great demand. Today,Ā  there are more styles,Ā  shapes and colors of the swimsuit can select more than ever before.Ā  And the price more competitive swimwear, and because so much competition. It is consumers, especially those who cannot just buy a good news! If you planĀ  ahead, purchase the summer is over. You will haveĀ  aĀ  great summer of next [url=http://www..sexybikinissunglass.com/bikinisswimwear-dior-bikinis-c-153_204.html]Dolce & Gabbana Bikinis[/url] year the price of large stocks of new bikini. If you buy online, you can even takeĀ  advantage of greater discounts andĀ  free shipping. Simply log [url=http://www..sexybikinissunglass.com/bikinisswimwear-juicy-bikinis-c-153_219.html]juicy Bikinis[/url] into the site,Ā  choose a hat, shirt and hoodies, you like toĀ  buy a single [url=http://www..sexybikinissunglass.com/bikinisswimwear-hollister-bikinis-c-153_211.html]Hollister Bikinis[/url] mouse click on them. It is that simple! At anyĀ  time, you will walk in the street [url=http://www..sexybikinissunglass.com/cheap-sexy-polo-bikinis-for-sale-p-1201.html]Polo Bikinis[/url] looking very smart, fashionable. All of these great tips should be very easy for you to find a great swimsuit the next time you went out shopping. Spend [url=http://www..sexybikinissunglass.com/bikinisswimwear-gucci-bikinis-c-153_210.html]Gucci Bikini[/url] the season in style and polka dot prints and vibrant color. [url=http://www..sexybikinissunglass.com/larget-discount-ed-hardy-bikini-on-sale-p-1571.html]ED Hardy Bikinis[/url] So remember to keep movingĀ  (to your health), but remember, we can not look like [url=http://www..sexybikinissunglass.com/womens-sexy-louis-vuitton-bikinis-p-1174.html]Louis Vuitton Bikinis[/url] a 15-year-old girl’s life, so relax and have funĀ  this summer.http://www..sexybikinissunglass.com/
      Ā 

      • Anonymous

        Ā Also it considered as athelete shoes, which can protect foot become [url=http://www.vibramfivefingersshoes-sale.com/]vibram five fingers shoes sale[/url] into athelete’s foot. Vibram five fingers is a shoe that separates the toes,Ā  so that all the muscles, tendons and ligaments in the [url=http://www.vibramfivefingersshoes-sale.com/vibram-fivefingers-women_c1135]Vibram FiveFingers Women[/url] foot and legĀ  are used and exercised as they should be. The benefit of wearing the unique shoe is that it does provide protection [url=http://www.vibramfivefingersshoes-sale.com/vibram-fivefingers-bikila_c1130]Vibram FiveFingers Bikila[/url] to the foot, [url=http://www.vibramfivefingersshoes-sale.com/vibram-fivefingers-sprint_c1131]Vibram FiveFingers Sprint[/url] andĀ  includes grips ideal for sport that the shoe is lacking.

        Intensify your workout [url=http://www.vibramfivefingersshoes-sale.com/vibram-fivefingers-kso_c1129]vibram five fingers kso[/url] with the increased toning and circulation created by the Komodo Sport’s barefoot imitation technology. The 2mm footbed is stitch-free and seamless to reduce friction andĀ  provideĀ  greaterĀ  comfort with every step. Hook and loop enclosuresĀ  at the heelĀ  and instep pull the stretch nylon upper into place, shaping it to the contours of your foot for the perfect fit every [url=http://www.vibramfivefingersshoes-sale.com/]Vibram FiveFingers shoes[/url] time. You’ll be prepared for your cross-training activities, thanks toĀ  the 4mm Vibram TC1Ā  rubber outsole, which providesĀ  a secure grip on all types of surfaces and is sturdy enough to keep your feet well protected.Ā  From the breathable materials to the impeccable construction and fitness-oriented design, the Komodo SportĀ  will giveĀ  you the burn you’re looking for without compromising on comfort or style.http://www.vibramfivefingersshoes-sale.com/

        • Anonymous

          When it comes to sports apparel, Nike may be the most well-known all over the world. The reason why sports clothing and shoes from this brand is very popular mainly because Nike isĀ  considered as one of the top brands of fact. Second, these [url=http://www.nikeairmaxs2010.com/nike-air-max-2011-c-9.html]New Air Max 2011[/url] productsĀ  are [url=http://www.nikeairmaxs2010.com/nike-air-max-90-c-3.html]New Air Max 90[/url] fashionable and trendy. Third, from Nike shoes and clothing to provide so much comfort in the lack of some brand product line. How can [url=http://www.nikeairmaxs2010.com/nike-air-max-ltd-nike-air-max-ltd-mens-c-12_36.html]Mens Nike Air Max LTD[/url] that be? Dr. Michael Yessis explosion in his book called the run, explained that today? s pad, additional support running shoes actually encourage athletes toĀ  achieve their heel firstĀ  landing, and not in the arch, had a positive impact on increasing leg strength. There is also a tendency to heel forward, pronation, or exposure to launch their feet inward. Dr. Yessis [url=http://www.nikeairmaxs2010.com/nike-air-max-247-nike-air-max-247-womens-c-1_15.html]Women’s Nike Air Max 4-27[/url] speculated that foot? s support structure (bones, ligaments, [url=http://www.nikeairmaxs2010.com/nike-air-max-90-c-3.html]Nike Air Max 90 Sale[/url] tendons, muscles) ultimately weaken the protective shoes, do their job veryĀ  well. There [url=http://www.nikeairmaxs2010.com/nike-air-max-kids-c-13.html]Nike Air Max 2011[/url] are manyĀ  ways [url=http://www.nikeairmaxs2010.com/]Nike Air Max 2011[/url] you want to buy shoes,Ā  especially shoes. You can go online or from your local shoe store. A disadvantage to buy shoes online is that you can not be a good choice definitely. However, thereĀ  is a largerĀ  selection of [url=http://www.nikeairmaxs2010.com/nike-air-max-bw-c-10.html]Nike Air Max BW[/url] shoes onlineĀ  than at a local shoe store. Before you buy, must gather some information about shoe brands. [url=http://www.nikeairmaxs2010.com/]Nike Air Max 2010[/url] Research online and compare prices of brand shoes and functionality, and make theĀ  right decision.welcome to http://www.nikeairmaxs2010.com

  • http://www.farmvillenews.net FarmVille News

    This is a very useful post!
    Thanks for sharingl

  • shadrach lamuel

    Fabric offers the bonus that you can have multiple tasks inside the one wrapper.

    This means that you can have one script to do for example:

    fab deploy2test
    fab deploy2prod
    best ipod case

  • Anonymous

    Of course. They falsify the street address in their registration, but they will be honest with you about the genuineness of the shoes that they will sell to you for less than the stores, even though their shipping expense (if they send them at all) would be higher.
    …..http://www.suprasocietyuk.com怀Cheap Supra Skytop Shoes, Supra Skytops UK
    …
    It doesn’t matter that much whether you get genuine shoes for this purchase (you won’t). What matters more is how many more charges are going to come in if you let them have your credit card number.

  • UGG Bailey Button Triplet