Introduction

This tutorial will show you how to deploy your Scala app in several minutes. These instructions will also give you enough information to make the most out of Dokkur.

Be sure that you already have:

  1. Dokkur account.
  2. SSH keys added to your account.
  3. sbt or activator installed.

Set up

In this step you will install the Dokkur Toolbelt that gives you you access to the Dokkur Command Line Interface (CLI).

After installation you can use dokkur login command to log in with your email and password you set when creating Dokkur account.

Prepare the app

To deploy an app you need to have the app prepared for deployment.

If you don’t have your own Scala project, you can use a template that we have already prepared for you:

$ git clone https://github.com/dokkur/scala-getting-started.git
$ cd scala-getting-started

The app in this example is built using the Play framework.

You now have a functioning git repository that contains a simple application as well as a build.sb file, which is used by Scala's dependency manager, sbt.

If you have a Scala app that you want to deploy, you need to do some preparations.

Declare app dependencies

How does Dokkur recognize an app as a Scala app? The answer is by the existence of a build.sbt file in the root directory.

It may look something like this:

name := """play-getting-started"""
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayScala)
scalaVersion := "2.11.1"
libraryDependencies ++= Seq(
jdbc,
cache,
ws
)

The build.sbt file specifies dependencies that should be installed with your application. When an app is deployed, Dokkur reads this file and installs the appropriate Java dependencies using the sbt compile stagecommand.

Another file, system.properties, determines the version of Java to use. The contents of this file, which is optional, is quite straightforward:

java.runtime.version=1.8

Run sbt compile stage in your local directory to install the dependencies, preparing your system for running the app locally.

$ sbt compile stage
[info] Loading project definition from /private/tmp/play-getting-started/project
[info] Updating
{file:/private/tmp/play-getting-started/project/}play-getting-started-build...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Set current project to play-getting-started (in build
file:/private/tmp/play-getting-started/)
[info] Updating {file:/private/tmp/play-getting-started/}root...
[info] Resolving jline#jline;2.11 ...
...
[info] Done packaging.
[info] Packaging
/private/tmp/play-getting-started/target/play-getting-started-1.0-SNAPSHOT-assets.jar ...
[info] Done packaging.
model contains 19 documentable templates
[info] Main Scala API documentation successful.
[info] Packaging
/private/tmp/play-getting-started/target/scala-2.11/play-getting-started_2.11-1.0-SNAPSH
OT-javadoc.jar ...
[info] Done packaging.
[success] Total time: 7 s, completed Apr 15, 2015 2:53:03 PM

Once dependencies are installed, you will be ready to run your app locally.

Create a new app

Follow these steps:

  1. Open website, go to Personal apps (left menu bar)
  2. Click ⨁ button to open New App interface
  3. Enter the app’s name (Caution! Use latin lowercase and numbers, e.g. myapp007), choose available and convenient instances for hosting, pick Custom App template and press Create App button.

Congrats! Your app has easily been created. Now you need to deploy it. Just do it!

Add BUILDPACK_URL config var

  1. Go to Settings page, in Environmental variables section click on Edit button.
  2. Choose ADD NEW VARIABLE
  3. In the Name field write BUILDPACK_URL
  4. In the VALUE field put
    https://github.com/dokkur/buildpack-scala
  5. Save settings

Deploy your app

  1. Go to Settings page, copy the app git url from the Git URL section.
  2. Switch to Dokkur Toolbelt and execute this command:

    git remote add dokkur git_url
    Instead of git_url paste your app's git url.

  3. Push your app:
    git push dokkur master
    If you want to deploy another branch, run:
    git push dokkur yourbranch:master

Hell yeah! Your app is deployed! Open yourappname.dokkurapp.com in your browser.