久々にPlayプロジェクトをHerokuにデプロイしようとしたらハマったので、
2018年時点でのデプロイ方法をまとめておきます。
# Playプロジェクト作成
sbt new playframework/play-scala-seed.g8
# play-miscという名前で作成した
cd play-misc
sbt run
下記URLにアクセスして動作確認。
Git管理しておきましょう。
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
git init
git add .
git commit -m "init"
Herokuで動かすためにAPPLICATION_SECRETを設定する
sbt playGenerateSecret
[info] Generated new secret: 7k9[E6(略)
heroku config:add APPLICATION_SECRET="7k9[E6(略)"
application.confにHostのフィルタ設定を追記
application.conf
play.filters.hosts {
allowed = ["."]
}
heroku用に下記内容のProcfileを作成してPush
web: target/universal/stage/bin/play-misc -Dhttp.port=${PORT} -Dplay.crypto.secret=${APPLICATION_SECRET}
HerokuにPush
git remote add origin git@github.com:your_name/your_repository.git
git push -u origin master
HerokuのURLにアクセスして動作確認。