5 ms·
Setup a complete Django server, deploy, rollback – all in one powerful script.
- Pewpewarrows 15y agoI have a morbid fascination with improving my workflow and programming environment, so I absolutely adore combing through other developer's fabfiles. This one is definitely nicely put together, and there's some nice gems I look forward to adapting into my own. I'll say this though: while fabric is _ok_ at configuration management and provisioning new servers/instances, it's absolutely dwarfed by real tools for that kind of job. If you value your sanity and want another excellent tool in your arsenal, look into using Chef or Puppet for building servers (with a dose of Blueprint for reverse-engineering your existing requirements). Fabric is great at everything else it does, but for building new servers it's very flimsy and prone to break, which can cause many a needless headache. I prefer Chef, but Puppet is equally excellent. Do yourself a favor and take the afternoon to learn one or both.
- barnaby 15y agoAgreed. It's well worth ones time to learn various different deployment tools. Everybody on a team should either contribute to making the build process better, or at least be familiar with how it works because their code has to go through that process to get published.
- ch0wn 15y agoI agree. Fabric is fine for simple, one-time deployments, but as requirements grow and need to be updated later on, idempotence starts to shine. For chef, there is a great tutorial by Opscode about deploying Django applications: http://help.opscode.com/kb/otherhelp/build-a-django-stack http://help.opscode.com/kb/otherhelp/build-a-django-stack
- ymir 15y agoI've heard many good things about Chef -- seems to be the tool get job done. Could you guys share your Chef script/config so we can all benefit from learning by example?
- ra 15y agoYes, I've often heard people say this is the way to go, but please blog about your own django server setup process using chef / puppet so we can see the details.
- cabacon 15y agoAgreed. There was a nice post on HN recently (http://news.ycombinator.com/item?id=2714149 http://news.ycombinator.com/item?id=2714149) about combining fabric + vagrant to manage django deploys. The vagrant part handles the "use puppet or chef" part of provisioning, while the fabric includes the "run quick commands on the VM" part after the VM is already provisioned. I learned a lot from that!
- mikeocool 15y agoThis looks super nice. One thing I've found that really speeds up deploys using git (inspired by github's deploy process[1]), is having your production copies of your app just be a clone of the git repo. To deploy new code the commands that get run are just: $ git fetch origin $ git reset --hard origin/<production branch> A rollback is just: $ git reset --hard HEAD^ Fetching pulls down the new code, without replacing your production code just yet. Then git reset --hard is a super fast way to point the production server's working copy at the current head of the origin/<production branch>. Saves you the time of having to upload an archive of your entire app the server everytime. However, it also gets complicated if you want to rollback more than one deploy. I've been looking into maybe auto-tagging each deploy and using the tags for rollbacks. Also, for uploading assets to S3 checkout s3cmd. It has a really nice sync command, that's basically like rsync for s3 --only uploads files that have changed. [1] https://github.com/blog/470-deployment-script-spring-cleaning https://github.com/blog/470-deployment-script-spring-cleanin...
- Tomek_Kopczuk 15y agoThanks for the s3cmd suggestion, we'll be sure to check it out before next weeks post.
- dce 15y agoIf you're deploying multiple commits at once, rollback is a bit more complicated than that. Check out http://www.viget.com/extend/deploying-the-git-way/ http://www.viget.com/extend/deploying-the-git-way/.
- deleted 15y ago[deleted]
- flexterra 15y agoVery nice! I made a similar script a couple of weeks ago. https://github.com/gcollazo/fabulous https://github.com/gcollazo/fabulous
- odiroot 15y agoIt'd be best to talk about the rationale behind this script. Since I'm currently diving into Fabric I have to say the very script isn't really pretty (rather hacky). Still, it's useful. On the other hand one can invest a lot of work initially by using Chef (or Puppet) and never again be bothered with setting up deployment scripts.
- jpadilla 15y agoNice! You should take a look at https://github.com/gcollazo/Fabulous https://github.com/gcollazo/Fabulous