Monday, 28 February 2011

AppHarbor - free .net hosting with continuous integration, Getting started tutorial

Ive been test driving appharbor recently and im very impressed.

Its basically a host for your .net web apps, but with a difference.
First you deploy to appharbor via a git push, as soon as you do this your app is built, your tests are run, and if all goes well (build succeeded and tests passed) your code is deployed to the hosting environment there and then.

Thats all sounds pretty simple, and is very impressive, especially since its free for a single web instance and a 20MB database.

So how do you go about doing it, how do you get a ASP.MVC 3 web app on the interweb in 15 minutes (if that) for free.

  1. Create a solution with a single MVC 3 web app in it, im using VS2010 (1 minute)
  2. Add a controller and a view, just static content will do (1 minute)
  3. Create a git repository in the folder that contains your solution. Just run "git init" (1 minute)
  4. Add your web app to the local repository "git add ." but be careful not to include the bin, obj or _resharper folders then Commit changes locally "git commit" (1-2 minutes)
  5. Log into appharbor and create a new application (1-2 minutes)
  6. Get your remote repository URL from the appharbor administration interface (1 minute)
  7. Add remote repository to your git repo: "git remote add appharbor" (1 minute)
  8. Push your app to git: "git push appharbor master" (1 minute)
  9. Log on to appharbor and navigate to your new app, see the successful build (1-2 minutes)
  10. Navigate to the live url and see the site live on the interweb (1-2 minutes)

I said 15 minutes, you can actually do it in a lot less, but you get my drift.

So what can you do :-)
  • Add test projects, your code will only be deployed if all the tests pass, brilliant.
  • Roll back to last deployment, very easy to do, if your not happy with the release, just click deploy on a older build and that older build gets redeployed, perfect. 
  • You can add your own host name
  • Add worker processors (at a cost)
  • Have multiple collaborators to the same project and use appharbor as the master repo (a bit like github) its really easy to get get the source on to a different machine, use "git clone"
What cant it do :-(
  • Acceptance tests, i use BDD style tests a lot, webdriver, selinium etc. it cant run these, and think about it, it makes sense. If a failing test stops deployment how can you run tests after you have deployed? I guess they need to develop a staging environment similar to Azure which gets deployed to first. I think that is on the pipeline of improvements but not at a high priority.
  • No file storage, only what is checked into your repo, you can save things to the file system, but they will get blown away with each deployment. i guess you could use amazon EC2, google or Azure to store your files using their REST APIs but that could be slow for the users, options exist though.
  • If/when tests fail you dont get a very good message, only a stack trace, you dont get the expected and actual values, not sure why this is, but its not a show stopper by any means.
  • Only one web app per solution is allowed, i guess this is because appharbor uses convention over configuration, and will automatically deploy the one web app there to the hosting environment.