LoginSignup
5

More than 5 years have passed since last update.

【2018年7月版】Scala on PlayFrameworkをHerokuで動かすまで

Last updated at Posted at 2018-07-28

久々に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にアクセスして動作確認。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5