Deployment Made Easy

Hey everyone,

My post today is going to be about deployment, a subject I dreaded as a beginner web developer. When I first made scholtek.com, my deployment strategy consisted of accessing the web server with Filezilla, and copying everything into the public root on my server. It was slow, and not at all scalable. It didn't allow any room for extra build processes such as minification or image compression. My builds were handled manually, one painful step at a time.

With my recent move to Django, and my new experience of deployment done by professionals at work, I decided to make things easier. The first thing I needed was a server that actually gave me some control. Up to this point, I'd been using the cheapest plan from HostGator - for shared hosting it worked very well. On my peak day, the site had more than 12,000 hits and HostGator never complained. For someone just starting out, they're a great option. But now I wanted to flexibility available with a Virtual Private Server, which provides a nice little sandbox where I can do whatever I want. Most of my experience was been with Amazon's elastic compute cloud offerings, which I enjoyed using and think is a clear choice if you're going to scale to hundreds of thousands of hits per day, but I decided to go with Digital Ocean, which boasted one click Django deployment, and a cheapest plan at $5 per month.

As can be expected, the VPS for this server is not a powerhouse. It provides 512MB memory and a single core, but even that is likely to outperform a shared hosting plan, and I have the advantage of a very low consumption website. All of the content currently on scholtek.com is static content, meaning it's the same for each and every user of the site. That provides a lot of room for caching and other optimization, which I have yet to test out (don't worry - that blog post will come as well!), and so the plan I have should be just fine.

The other benefit of Digital Ocean is their wealth of documentation. In particular, I found an article on automatically deploying with git. I'll leave the details to the article, but the summary is:

  1. Create an empty git repository on the server
  2. Create a post-receive hook on git that copies the files to your django projects location, and restarts the server
  3. Set that repo as a remote on your local git branch
  4. Type 'git push branch-to-deploy
  5. Profit!

If that sounds extremely easy, it's because it was. So this complicated manual deployment method I've been using for the past year was replaced in under 20 minutes using git and a VPS. To any web developers out there, I can't recommend this approach strongly enough.

-Keilan