I do a lot of coding for my blog and occasionally friends blogs/side-projects, and have been looking at possible ways to manage deployment simply, as while I version control all my code, copying it up to the server using SFTP can be troublesome, time-consuming and error prone.
I currently have no automated easy way to do this and wondered what else people might use, so thought I would shout out on twitter to see what others do.
The variety of responses was amazing, so thought I'd do a little round up and list them all, do a little searching and provide some useful URLs.
Suggestions from Twitter
Capistrano (4 mentions)
What is it: Ruby tool intended originally for ruby/rails, but can be used for anything.
Get it: Capistrano on Github (requires Ruby >= 1.9)
Introduction and Tutorial:theCapistrano homepage has lots of resource links. I found a nice tutorial from the Beanstalk folks, thegetting started guide and the officialCapistrano 'From the Beginning' article onthe capistrano wiki is pretty thorough.
Deploying non-rails sites: The 12 Devs article has some insight into a few simple capistrano commands, andZodiacMedia have some in-depth tutorials for Capistrano 2 and 3.
Fabric (2 mentions)
What is it:
%blockquote Fabric is a Python (2.5 or higher) library and command-line tool for streamlining the use of SSH for application deployment or systems administration tasks.
It provides a basic suite of operations for executing local or remote shell commands (normally or via sudo) and uploading/downloading files, as well as auxiliary functionality such as prompting the running user for input, or aborting execution.
Typical use involves creating a Python module containing one or more functions, then executing them via the fab command-line tool.
Introduction and Tutorial:http://docs.fabfile.org/en/1.4.0/tutorial.html
circleCI (2 mentions)
What is it: Commercial tool that sits on top of github, deploying your tool when your tests pass.
Introduction and Tutorial: https://circleci.com/docs/getting-started
puppet (1 mention)
What is it: Open source framework for building and managing servers (available in free open source/commercial enterprise variants)
Video overview: http://vimeo.com/50780573
Chef (1 mention)
What is it: Chef 'models IT infrastructure and application delivery as code' (available in free open source/commercial enterprise variants)
Introduction and Tutorial: http://www.getchef.com/chef/
Git (1 mention)
What is it: just add a git repository to your server. No automation per-se, but you no longer have to ftp files across, and git keeps everything in sync with a single command.
Tutorial: Chris James:
Cloning a github repo onto your webfaction server
git hooks (3 mentions)
What is it: Add git to your server .Create hooks that call pull scripts after git commits.
- Introduction and Tutorial:a great deployment post on the awesome 12 Devs.
- asitepoint article on deployment with Git Hooks.
- automating deployment with bitbucket.
Codebase/Deployhq (1 mention)
What is it: Codebase looks to be a pretty kickass code management platform. Deploy is a deployment platform for Git Mercurial and SVN that deploys to the cloud/FTP/SSH/SFTP. A deploy membership seems to come with Codebase, but it can be used as a standalone product. There arepricing plans, but looks like you can do a single project with up to 10 deployments a day for free.
Introduction and Tutorial: http://deployhq.com
Beanstalk App (1 mention)
What is it: 'Hassle-free, hosted version control service' - a version control service that has some really nice looking integration and deployment features baked in. Commercial, but has a free 30 day trial (http://beanstalkapp.com/pricing)
Grunt (1 mention)
Getting Started: http://gruntjs.com/getting-started
What I went with...
Based on my specific needs:
- Ideally free - have no money to fund an ongoing service as it's for a personal project with infrequent deployments rather than a project with regular use.
- Version control not needed - I already have version control covered
- Simple - I LOVE simple.
Chef/Puppet look a bit too heavyweight for my needs, as I don't need to deploy VMs, just small amounts of code.
Git Hooks look great, but I don't want to put a publicly accessible deploy script on my web server. Codebase/deployhq and beanstalk app look amazing, but I have my VCS already sorted, and as I use bitbucket, CircleCI is out. Fabric looks good, but I don't really use Python, which for me is yet another language to learn.
While I haven't settled on a fully automated solution quite yet, in the end after playing around with Capistrano and failing (more likely my understanding than Capistrano's fault) I got a solution working using SSH + Git, taken from the plain Git approach from Chris James, which involved creating a SSH user on my web server, and authenticating this with my VCS.
Basically I have to:
- SSH onto my web server
- Do a 'git pull' command to get the latest version via SSH.
Not particularly automated, but at lease I know my live site is version controlled and easily updated.
For the future, I'm looking into both Grunt+Plugins and Capistrano, as they seem to fit the bill closest, and I like the idea of keeping my server completely clean. Of interest was a very detailed overview from David Tucker on how he
uses Grunt for automation. I'm also looking into deployHQ as a possible product to use, as a third possible solution, as that seems pretty pain free, and is pretty much a third party extension of what I went with.
Thanks for reading this far - if there are an inaccuracies/suggestions for this listdo let me know.
This stuff is hard - while saving you time on the long run, some of the setup can be quite confusing, and I did hit a fair few brick walls while trying stuff. I don't think there is one true right way - all the methods listed above look great, and could be valid for your given situation, depending on what language you are familiar with, what you are deploying to where, and what your needs are.
While I think everyone should look into version controlling code for their blogs/websites (github is free for open repos, bitbucket free for open/private repos), if you are a developer or just like to tinker with code, there is no reason you shouldn't try automating site deployments - why repeat boring tasks when a computer can do them for you?
Thanks to all those who responded to my tweet - Happy new year and happy coding in 2014!