Project Website Part 5: Morph in 11 steps or so

BD3787F1-7967-4CE0-AF3F-AA9E36AD6AA3.jpg

Eventually in the course of developing the Project Website application, it was time to put the project on a staging server for client viewing.

Often we'll host that ourselves, but in this case I decided to try out Morph, which provides a relatively inexpensive virtual hosting environment for Rails applications, using the Amazon Web Services cloud. Even better, Morph allows you to set up a development environment for free. (The free version is limited in size and bandwidth, and they also apparently will shut down the server if you don't deploy for 30 days -- a limitation obviously not shared by the paid environments).

I was able to go from total Morph ignoramus to running deployed app in under two hours. After reading this you should be able to do it even faster. (Full disclosure: Morph and Pathfinder are co-sponsers of the WindyCityRails conference September 20, 2008. That doesn't really have anything to do with anything, I just wanted to mention the convference)

Here are the steps:

  1. Go to http://www.mor.ph. Click on login, then create a new account. You'll need to activate via email.
  2. After activating, you can create a new subscription:
    morph_01.png

    We'll create a Ruby on Rails project (the other option is Java), set the database to MySQL and create the subscription.

  3. You wind up in the control panel, which starts off like this:
    morph_02.png
  4. Click "Create Data Base", which does nothing visible, but, well.. creates your database.
  5. Click "Dowload Cap File. This will download a Capistrano file called
    morph_deploy.rb. You should put this in the root directory of your application.
  6. Open the morph deploy file file, and change the line set :repository to point to your repository. In my case, I'm using a local git repository, so I need to set it to set :repository, '.'. Note that I'm not changing the source control scm setting here, per the directions from Morph, I'll be doing that in my command line. Not sure why they want you to do it like that.
  7. You do need to do some prep work on your application. You should have as many gems as possible in your vendor/gems directory, if you are using Rails 2.1 gem tasks, this is easy. Morph has gems on the server, but you don't want to be dependent on their versioning. You must have Capistrano 2.0 or higher on your local machine. And any thing you want to be able to do on the remote system should be available as a Rake task. Also, if you are uploading files in your app, you need to store them elsewhere, like Amazon S3.
  8. Okay, at this point, we're ready to go. The recommended invocation for deploying my app via morph is

    cap -f morph_deploy.rb -s scm=git -s deploy_via=checkout morph:deploy

    $ cap -f morph_deploy.rb -s scm=git -s deploy_via=checkout morph:deploy
      * executing `morph:deploy'
     ** transaction: start
      * executing `morph:update_code'
      * executing `morph:upload_code_to_s3'
      * executing `morph:get_code'
    Downloading the code from the repository...
    Getting upload information
    *** Getting info for Morph authentication ***
    Morph user: xxxxxx
    Password:
    Uploading code to S3...
    Creating new appspace version...
    Code Upload Done.
    Deploy Done.
     ** transaction: commit

    Note that I got challenged for my username and password, so you do need to watch this one go.

  9. At this point, your control panel will look like this. (You might have to click a "start process" button to get this screen exactly).
    morph_03.png
  10. The "Manage" link is where all the interesting stuff is.
    morph_04.png

    The Dashboard lets you redownload the Capistrano file, revert to old versions, and see details of old versions. Charts has CPU and Memory usage histories. DB Admin takes you to phpMyAdmin, which lets you do all kinds of database manipulation. Web Stats has, well, web stats, hits, pages, and bandwidth -- the Google Analytics style features, although not quite as pretty. The Logs tab gives you access to the production log and all deployment logs.

  11. The Tasks tab is interesting, this is your main method of interaction with the running system.
    morph_05.png

    The pulldown has a list of all your Rake tasks (not alphabetized, for some reason). If you run one, you'll see the output on that screen in a few moments. You do not have general SSH access to the system, but the phpMyAdmin interface lets you do almost anything you'd need that is database related. Anything else, you need to roll up as a Rake task and run here. You can also set scheduled and event tasks.

And that's how I got my site uploaded to Morph, quick and easy.

Comments: 6 so far

  1. Thanks for the writeup.

    Cool service but I ran into some problems.

    1) File uploading is a bit foobared. They dont support filesystem. AttachmentFu S3 was throwing permission denied errors

    2) Couldnt install gems. Rails 2.1 doesnt pick up Gem Plugins that are in the vendor directory so freezing wasnt an option. I wish it would pick the gems out of environment.rb and just install them. But I guess there’s limitations since its shared server

    3) Cap deployment failures are really tough to debug. Lots of trial and error. Nondeterministic so I kept having to do refreshes on their tool to see if it updated. They should just email any deployment failures along with the log files so its not such a pain

    Looks like a promising tool. Not quite ready to give up my slice quite yet. I wish I could though.

    Comment by tom, Friday, August 8, 2008 @ 8:17 pm

  2. Thanks for mentioning the conference!

    Comment by Matt Polito, Saturday, August 9, 2008 @ 2:13 pm

  3. Glad to hear that you had a quick and easy time with it, Noel. Do let us in with more of your thoughts as you continue to explore the Morph Appspace for your apps deployment.

    Appreciate the kind words.

    Best.
    alain
    http://www.mor.ph
    Thanks to Matt, too for giving the Mor.ph -sters a chance to participate in the event.

    Comment by friarminor, Saturday, August 9, 2008 @ 7:02 pm

  4. The unalphabetized rake task names are a pain. Also, I’ve experienced significant delays after deploying; it seems like Morph has their own processes that throw up various not-found or bad-gateway pages for a while. I’ve just trained my client to wait an hour before testing newly-delivered features.

    I hacked up the morph_deploy script to remove the need for command-line arguments and created a bash helper so I can just ‘morph_deploy ‘

    Comment by Veez, Saturday, August 9, 2008 @ 9:02 pm

  5. Noel, thanks for the post. Anytime you need our help with deployment, we’re here to help.

    @Veez thanks as well. not sure if you’ve visited our forums, but feel free to post your suggestions and hiccups you encounter at forums [dot] mor [dot] ph. you may also email me directly. deployment shouldn’t be that difficult

    Comment by M L, Wednesday, August 20, 2008 @ 1:57 am

  6. Thanks for the post!

    @tom: If there are gems you need that aren’t installed, we would gladly install on our systems. We do that all the time. The attachment-fu + S3 issues are now solved. We are adding more error handling to the deploy scripts, and working on automatic notification in case of errors.

    @veez: Good point on the un-alphabetized rake tasks, we will fix this ASAP.

    We are very happy to receive feedback of any kind, and do our best to address it ASAP.

    Guy - Morph Labs CTO

    Comment by Guy Naor, Saturday, August 23, 2008 @ 12:47 am

Leave a comment

Powered by WP Hashcash

About Pathfinder

Follow the Blog

    Get a monthly update on best practices for delivering successful software.

    Subscribe via email

      

    Subscribe via RSS      RSS icon

Topics

Search

WordPress

Comments about this site: info@pathf.com