Scala on Heroku (using Ubuntu): Addendums to the Tutorial

So, I thought to myself: Heroku sounds pretty cool, let’s try it out… – there is a detailed “Getting Started” out there, so what can possibly go wrong?

Right, that’s what I thought. And yet again, I have learned that I’m being a tad too optimistic.

Without further ado, here’s what went wrong for me and how I fixed what I managed to fix (as a total Ruby newbie):

Prerequisites

No problem here, registration was instant and went smoothly. – sbt 0.11, OpenJDK 6, basic Scala knowledge, all there ready to go.

Local Workstation Setup

Unfortunately, the Ubuntu readme failed me:

  • Minor nitpick, but you should have told me to run those commands as root (yes, I’m such a newb).
  • Running the commands from the readme went smoothly.
  • However, “heroku login” failed with “ruby: command not found“. Hmm… – I’m sorry, but I don’t know anything about Ruby.
  • Let’s try the usual Ubuntu magic: “sudo apt-get install ruby“. Works, yay! Now I can login to heroku from the command line just fine.

Write Your App

Finally, some Scala code, I feel right at home here.

Declare Dependencies with sbt, Add the Start Script Plugin, Build Your App

I’m cool with sbt magic, too. Everything went fine. This looks promising.

Declare Process Types With Foreman/Procfile

Foreman and Procfile? Never heard of these. No problem, I guess, looks easy and helpful. However, my Ubuntu system doesn’t know anything about Foreman either: “foreman: command not found“.

I’m stumped here. I’ve found out that it’s a Ruby gem, and that it should have been installed together with the Heroku Toolbelt. I even tried installing it via “gem install foreman” (which required installing the rubygems package first).

Why do I have to use Foreman here at all?

… turns out: I don’t. I can start my new web application via “target/start Web” just as well. Good enough for me and my experiments.

(The web application started on port 8080 for me though, not on port 5000 as mentioned in the tutorial.)

Store Your App to Git

But I don’t want to. I want to store it to Mercurial instead. Never mind me, though, everyone else loves Git, so you probably love Git, too.

Anyway, this worked like a charm.

Deploy to Heroku/Cedar

This mostly worked, too. “heroku logs” failed at first (“Logging is not enabled for this app.”). A few minutes later, however, it worked. I didn’t change anything, I swear. This is minor anyway, as activating the logging plugin would have been very easy.

And here I am, with a working Scala web app deployed to Heroku. In spite of all my nitpicking: This is cool!

Now I just have to decide what the heck to do with that web app? :)

By the way, the “slug size” of this teeny weeny little app is > 40 MB. This sounds like quite a lot, especially when Heroku tells me that 100 MB is the maximum. How come? – I don’t know. My local git repo is very small, I think. Is it the dependencies, maybe (finagle-core)?

Posted in Scala by jmhofer at October 10th, 2011.
Tags: , ,

2 Responses to “Scala on Heroku (using Ubuntu): Addendums to the Tutorial”

  1. […] small, I think. Is it the dependencies, maybe (finagle-core)?Tweet This Post  Eclipse Read the full post on Planet Eclipse… Share […]

  2. Zdenek Farana says:

    Hi, as pointed out by Scott Classes, heroku bundles the ivy2 cache into the slug (https://twitter.com/#!/scottclasen/status/124257488206966784). I was wondering about the size as well, ours slug is 60MB. Zdenek

Leave a Reply