Skip to content

Play Framework 1.x (Scala)

Overview

Clever Cloud supports Play 1.x applications natively. The present guide explains how to set up your application to run on Clever Cloud.

Configure your Scala + Play! 1 application

Select Play! 1.x version

Clever Cloud supports Play! 1.2 to 1.11, and uses Play! 1.7 by default. You can select the Play! version for your application by setting the CC_PLAY1_VERSION environment variable. The former PLAY1_VERSION name remains supported as an alias. A clevercloud/play1_version file containing the version also works, but it’s deprecated and ignored when CC_PLAY1_VERSION is set.

The CC_PLAY1_VERSION environment variable can contain one of the following values:

  • 1.2 or 12 for Play! 1.2
  • 1.3 or 13 for Play! 1.3
  • 1.4 or 14 for Play! 1.4
  • 1.5 or 15 for Play! 1.5
  • 1.6 or 16 for Play! 1.6
  • 1.7 or 17 for Play! 1.7
  • 1.8 or 18 for Play! 1.8
  • 1.9 or 19 for Play! 1.9
  • 1.10 or 110 for Play! 1.10
  • 1.11 or 111 for Play! 1.11

Play! configuration with application.conf

By default, your application will run on Clever Cloud with the option --%clevercloud. It means that you can define special keys in your application.conf file that will be used only on Clever Cloud.

You can for example:

  • set production mode so the files are compiled at startup time and the errors are logged in a file:

    %clevercloud.application.mode=prod
  • set up a mysql database (using environment variables)

    %clevercloud.db.url="jdbc:mysql://"${MYSQL_ADDON_HOST}"/"${MYSQL_ADDON_DB}
    %clevercloud.db.driver=com.mysql.jdbc.Driver
    %clevercloud.db.user=${MYSQL_ADDON_USER}
    %clevercloud.db.pass=${MYSQL_ADDON_PASSWORD}

More information on playframework.com.

HTTPS support

HTTPS is handled by Clever Cloud ahead of your application, your application retrieves the traffic in plain http. To be able to use request.secure, you have to add XForwardedSupport=all in application.conf.

Monitor your application with New Relic

You can use New Relic to monitor your application on Clever Cloud.

Please refer to our New Relic documentation to configure it for your application.

Environment injection

Clever Cloud injects the environment variables of your application into its environment, along with those of its linked add-ons.

Custom build configurations

On Clever Cloud you can define some build configuration: like the app folder to deploy or the path to validate your application deployment is ready To do that follow the documentation here and add the environment variable you need.

To access the environment variables from your code, you need to add my.option=${MY_VARIABLE} in your application.conf file, and then use the configuration item my.option in your application. e.g %clevercloud.db.url="jdbc:mysql://"${MYSQL_ADDON_HOST}"/"${MYSQL_ADDON_DB}

Go Further

Last updated on