On Free Orchard Hosting with Bitbucket and AppHarbor

If you’re not familiar with the Orchard Project, you should be. Orchard is an open source, mostly-CMS framework built on top of ASP.NET MVC. I say mostly-CMS because the project has goals of becoming more of a generalized component framework.

I first saw Orchard in action at the NYC GiveCamp. One of the teams built out a site for a charity using Orchard, which at that point had been released for about a week (I think). As a CMS, it’s reasonably feature rich. It’s not quite WordPress yet, but it’s more than adequate for use in a typical content heavy site.

I’m working on starting an ALT.NET group up here in Boston – Beantown ALT.NET. My first efforts with getting the group off the ground were of course to buy a domain and put up a site. I grabbed the domain beantownalt.net (bostonalt.net was taken) from Namecheap, since Bob Parsons is sick individual.

For the site, I considered the usual suspects. I know Fairfield/Westchester .NET uses WordPress. But running an ALT.NET site on a PHP app didn’t feel right. I think that group used to run on Dot Net Nuke, but running an ALT.NET site on VB.NET is worse than running it on PHP! I also considered Meringue, since I know the developer. But it doesn’t have the module support I wanted.

Ultimately, Orchard was an easy choice. It’s built on MVC and lots of ALT.NET technologies, such as Autofac and NHibernate.

At first, I setup BeantownALT.NET on a hosted VPS (damn impulse purchases) that I have. But I can’t really justify the cost of that server for the demoware that I host there. So I’m going to move the sites on that box to a cheaper solution, namely AppHarbor.

AppHarbor is Heroku for .NET. You commit your code to either a Mercurial or Git repository then push it to AppHarbor. AppHarbor then builds your solution, runs your tests and viola, your app is live in the cloud. It’s really that simple. In fact it’s so simple, I’m going to move Beantown ALT.NET’s website to AppHarbor as I write this post.

First things first. You’ll need to grab the Orchard bits. You can grab them from CodePlex here. I’m just grabbing the web zip as I’m going to push the prebuilt web package to a Mercurial repository setup on Bitbucket.

OK, so Bitbucket… If you’re a Windows developer and you’re using Git and GitHub, I have to ask why. The Windows experience with Mercurial is simply cleaner. More importantly, Bitbucket offers Free private repositories. That’s right, free and private. GitHub doesn’t offer that. I know, I know… Rails is hosted at GitHub, so everyone uses it. Get over it and get some free repositories devs!

Anyway, so once you’ve done the sensible thing and signed up for Bitbucket, create a new repository and clone it locally.

hg clone https://username@bitbucket.org/username/project project

Back to Orchard… You could try to get the source code and set it up to build at AppHarbor, but really there’s no need to do that. If you do that, start by renaming Orchard.sln to AppHarbor.sln so that AppHarbor can disambiguate which solution to build (Orchard has a few in the source tree). Getting the Orchard source to build is a topic for a different post.

Since you’ll likely just be using your Orchard site for content management, just download the web files zip instead. This package has the compiled bits ready to be deployed. Extract those files to your Mercurial repository. Once you do that, move the files out of the Orchard directory into the root of your repository (sibling with the .hg directory). You need to move these files since we’re pushing only content and this is the website root.

Your repository should look something like:

/yourproject
     /.hg
     /App_Data
     /bin
     /Config
     /Core
     /Media
     /Modules
     /Themes
     /.hgignore
     /Global.asax
     /install.sql
     /Refresh.html
     /Web.config

Now go ahead and hg add and hg commit the source files. If you have an .hgignore file setup to ignore your bin directories, you’ll need to reverse that here. Remember, this is the prebuilt Orchard and you’re going to want to have the binaries deployed as well.

Next login to AppHarbor (assuming you’ve already signed up). Create a new application and click into its properties pages (just click on the name of the app on the left hand side of the top navigation bar). Under the repository URL, you should see a link “Create build URL: (show/hide).” Click show/hide and copy the link that appears. Also, while in AppHarbor, click on “Settings” and check the option to allow write access, as Orchard will need this setting to manage modules and the like.

Next, you’ll need to navigate to the “Admin” tab for your repository on Bitbucket. Look for the “Additional options/settings” widget and click “Services.” Select “POST” from the list and paste the build URL from AppHarbor. Save the changes. You’ve now wired Bitbucket to AppHarbor. Also, in the admin section, find the “User access” widget and give read access to the “apphb” user. Don’t miss this step or it won’t work! Every push to Bitbucket will now trigger a build at AppHarbor. Yes, it’s that easy…

Go ahead and push your changes to Bitbucket. Once the commit is complete, you should see a “Builds” section appear in your application’s properties pages at AppHarbor. You’ll also see a list of Application URLs. Navigate to one and you should see the setup page for your new Orchard site.

At AppHarbor, on the property pages for your application, you can add a SQL database. When you create that database, copy the connection string and paste it into the form for creating your site. Once you hit submit, you’re in Orchard.

So that’s it. Free hosting for your Orchard site (assuming you can stay within the pretty generous free limits), deployed via Mercurial. Kind of awesome, right?

Oh yeah, the one thing I should definitely mention is that all builds are clean! What this means is that each time you hg push, you get a clean deploy of Orchard, meaning your settings will be lost. So you have one of two options. The first option is not to push again. Manage your site and updates through Orchard. This option is how I plan to work. Option two is to run your site locally, make updates locally, add content locally, etc. You should be able to connect to your AppHarbor DB locally. Then just push your code when its ready to go live.

This entry was posted in Uncategorized and tagged , , , . Bookmark the permalink.

4 Responses to On Free Orchard Hosting with Bitbucket and AppHarbor

  1. htlar says:

    Hi,

    I tried to follow this, but it didn’t seem to build. The web zip of Orchard has no .sln file, so how did you get AppHarbor to build it?

  2. htlar says:

    UPDATE: Seems to have been deployed now! I’m guess it just gets deployed, not built?

  3. jzablocki says:

    Sorry for the late response. My dllHell emails have been getting filtered and I totally missed this. With the web zip, you can just push the project as is with nothing to build. If I remember correctly, pushing w/o a solution just pushes the content?

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">