Reminders about deploying Play apps in Heroku

Put your application in production, also known as deploy, is one of the most important aspects of our lives as developers. This is one more thing that is too much easy with Play. Let’s walk through for some important details about deploying apps in Heroku.

There is step by step guide here. The main problem that I usually see with people that are trying to use heroku is about the details in the procfile and the database configuration. The procfile is used to configure heroku in order to start your application. This file is needed by Foreman, a ruby gem used to manage all processes necessary to run your application. Here an example:

  web: target/universal/stage/bin/acasaesuadecor-landing 
   -Dhttp.port=${PORT} 
  -Dconfig.resource=production.conf 
  -DapplyEvolutions.default=true 
  -Ddb.default.url=${DATABASE_URL}

Heroku uses the stage command to generate the deploy structure for the Play app, that is why you used this path. You need to have this file in order to run your app. It also needs to be placed in the root of your project. All information between curly braces will be provided by Heroku, in their environment.

If you take a closer look, you will see the parameter named Ddb.default.url and this is a point of confusion between a lot of people. All the information needed to connect to the database is provided in the url. You only need to configure, in your production.conf, the driver information.

 db.default.driver=org.postgresql.Driver
 #db.default.url="..."
 #db.default.user=...
 #db.default.password="..."

If you configure, for example, the password. This information will be used and you will get an exception in Heroku, explaining that the password is wrong.

That is it :). I am gonna try to write about the webjars in the next post!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s