Play frameworkをherokuで動かすための最速手順

Instant Play Framework Starterを少しづつ読み進めてるが、先にherokuに上げる方法を調べておきたくなった。公開できるとやる気出るし。基本的には公式チュートリアルで言われるがままにやっていれば動く。

環境構築(Heroku toolbelt)

heroku関連のコマンドを利用する為に必要。以前インストールしてそのまま使っているので覚えていないが、ここからダウンロードして説明読めば何とかなると思う(適当)。

herokuにログイン

mikami-no-MacBook-Air:play-starter-scala mkouhei0910$ heroku login
Enter your Heroku credentials.
Email: hogehoge@fugafuga
Password (typing will be hidden): ...

Authentication successful.

各種ファイルの作成

conf/dependencies.yml

使っているPlayのバージョンに合わせて記述する。

# Application dependencies
require:
	- play 2.1.1

Procfile

公式のチュートリアルの通りにやっても動作しない(参考)。以下のように記述する。

web:    target/start -Dhttp.port=$PORT $PLAY_OPTS

公開

gitに登録

 $ git init
 $ git add .
 $ git commit -m "init"

デプロイ

 $ heroku create
 ...
 $ git push heroku master
 ...
 $ heroku ps:scale web=1

確認

あとは実際にアクセスして確認する。以下のコマンドでブラウザから開く事ができる。

 $ heroku open

f:id:mi_kami:20130625233648p:plain
http://mighty-hollows-9694.herokuapp.com/entries