Deep-dive on the Next Gen Platform. Join the Webinar!

Skip Navigation
Show nav
Dev Center
  • Get Started
  • Documentation
  • Changelog
  • Search
  • Get Started
    • Node.js
    • Ruby on Rails
    • Ruby
    • Python
    • Java
    • PHP
    • Go
    • Scala
    • Clojure
    • .NET
  • Documentation
  • Changelog
  • More
    Additional Resources
    • Home
    • Elements
    • Products
    • Pricing
    • Careers
    • Help
    • Status
    • Events
    • Podcasts
    • Compliance Center
    Heroku Blog

    Heroku Blog

    Find out what's new with Heroku on our blog.

    Visit Blog
  • Log inorSign up
Hide categories

Categories

  • Heroku Architecture
    • Compute (Dynos)
      • Dyno Management
      • Dyno Concepts
      • Dyno Behavior
      • Dyno Reference
      • Dyno Troubleshooting
    • Stacks (operating system images)
    • Networking & DNS
    • Platform Policies
    • Platform Principles
  • Developer Tools
    • Command Line
    • Heroku VS Code Extension
  • Deployment
    • Deploying with Git
    • Deploying with Docker
    • Deployment Integrations
  • Continuous Delivery & Integration (Heroku Flow)
    • Continuous Integration
  • Language Support
    • Node.js
      • Working with Node.js
      • Troubleshooting Node.js Apps
      • Node.js Behavior in Heroku
    • Ruby
      • Rails Support
      • Working with Bundler
      • Working with Ruby
      • Ruby Behavior in Heroku
      • Troubleshooting Ruby Apps
    • Python
      • Working with Python
      • Background Jobs in Python
      • Python Behavior in Heroku
      • Working with Django
    • Java
      • Java Behavior in Heroku
      • Working with Java
      • Working with Maven
      • Working with Spring Boot
      • Troubleshooting Java Apps
    • PHP
      • PHP Behavior in Heroku
      • Working with PHP
    • Go
      • Go Dependency Management
    • Scala
    • Clojure
    • .NET
      • Working with .NET
  • Databases & Data Management
    • Heroku Postgres
      • Postgres Basics
      • Postgres Getting Started
      • Postgres Performance
      • Postgres Data Transfer & Preservation
      • Postgres Availability
      • Postgres Special Topics
      • Migrating to Heroku Postgres
    • Heroku Key-Value Store
    • Apache Kafka on Heroku
    • Other Data Stores
  • AI
    • Working with AI
  • Monitoring & Metrics
    • Logging
  • App Performance
  • Add-ons
    • All Add-ons
  • Collaboration
  • Security
    • App Security
    • Identities & Authentication
      • Single Sign-on (SSO)
    • Private Spaces
      • Infrastructure Networking
    • Compliance
  • Heroku Enterprise
    • Enterprise Accounts
    • Enterprise Teams
    • Heroku Connect (Salesforce sync)
      • Heroku Connect Administration
      • Heroku Connect Reference
      • Heroku Connect Troubleshooting
  • Patterns & Best Practices
  • Extending Heroku
    • Platform API
    • App Webhooks
    • Heroku Labs
    • Building Add-ons
      • Add-on Development Tasks
      • Add-on APIs
      • Add-on Guidelines & Requirements
    • Building CLI Plugins
    • Developing Buildpacks
    • Dev Center
  • Accounts & Billing
  • Troubleshooting & Support
  • Integrating with Salesforce
  • Language Support
  • Scala
  • Deploying Scala Apps on Heroku

Deploying Scala Apps on Heroku

English — 日本語に切り替える

Last updated October 16, 2024

Table of Contents

  • Prerequisites
  • Overview
  • Verify that the sbt-native-packager plugin is set up correctly
  • Specify a JDK
  • The Procfile
  • How to keep build artifacts out of git
  • Build your app and run it locally
  • Deploy your application to Heroku
  • Console
  • Troubleshooting

This article describes how to take an existing Scala app and deploy it to Heroku.

If you are new to Heroku, you might want to start with the Getting Started with Scala on Heroku tutorial.

Prerequisites

Before you begin, make sure you have installed Scala, sbt, and the Heroku CLI. This article assumes that you are starting with an existing Scala app that is set up to build with sbt.

This article does not apply to apps that use the Play framework. Play framework support is described in the Play framework support reference.

Overview

The way Heroku recognizes a Scala application is described in Heroku Scala Support.

Your application should already include a project/build.properties file that defines the sbt.version it is designed to use. It will look something like this:

sbt.version=0.13.9

For more information, see Build behavior.

Verify that the sbt-native-packager plugin is set up correctly

To package your app for deployment, you can use the sbt-native-packager sbt community plugin. If you are using the Play framework version 2.3 or higher, then this plugin will be automatically configured for you.

If you are not using Play framework, you must configure the plugin manually. The project/plugins.sbt file will specify which version of the sbt-native-packager to use. Add the following to your project/plugins.sbt file:

addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.0.3")

In your build.sbt enable the plugin you want. For example the JavaAppPackaging.

enablePlugins(JavaAppPackaging)

For more detailed information, see the sbt documentation, and the sbt-native-packager documentation.

Specify a JDK

Optionally, you can specify a JDK. For more information, see Specifying a Java version.

The Procfile

A Procfile is a text file in the root directory of your application, that defines process types and explicitly declares what command should be executed to start your app. If you are using the sbt-native-packager and the java_application package archetype, you will have a start script in target/universal/stage/bin. Your Procfile will look something like this, except instead of hello, you’d use the name of your app:

web: target/universal/stage/bin/hello

This declares a single process type, web, and the command needed to run it. The name, web, is important here. It declares that this process type will be attached to the HTTP routing stack of Heroku, and receive web traffic when deployed.

The command in a web process type must bind to the port number specified in the PORT environment variable. If it does not, the dyno will not start.

How to keep build artifacts out of git

Prevent build artifacts from going into revision control by creating a .gitignore file. Here’s a typical .gitignore file:

target/
project/boot

Build your app and run it locally

To build your app locally do this:

$ sbt compile stage
$ heroku local --port 5001

Your app should now be running on http://localhost:5001/.

Deploy your application to Heroku

After you commit your changes to git, you can deploy your app to Heroku.

$ git add .
$ git commit -m "Added a Procfile and packaging."
$ heroku login
...
$ heroku create
Creating warm-frost-1289... done, stack is heroku-18
http://warm-frost-1289.herokuapp.com/ | git@heroku.com:warm-frost-1289.git
Git remote heroku added
$ git push heroku master
...
-----> Scala app detected

To open the app in your browser, type heroku open.

Console

Heroku allows you to run one-off dynos - scripts and applications that only need to be executed when needed - using the heroku run command. The console has your application code available. Use this to launch a REPL process attached to your local terminal for experimenting in your app’s environment:

$ heroku run sbt console
Running sbt console attached to terminal... up, run.1
...
scala>

For more information, see Running a Remote sbt Console for a Scala or Play Application.

Troubleshooting

Major releases of sbt may not be compatible with each other. Most issues will be related to mismatched versions of sbt.

Keep reading

  • Scala

Feedback

Log in to submit feedback.

Using Node.js to Perform JavaScript Optimization for Play and Scala Applications Getting Started on Heroku with Scala and Play

Information & Support

  • Getting Started
  • Documentation
  • Changelog
  • Compliance Center
  • Training & Education
  • Blog
  • Support Channels
  • Status

Language Reference

  • Node.js
  • Ruby
  • Java
  • PHP
  • Python
  • Go
  • Scala
  • Clojure
  • .NET

Other Resources

  • Careers
  • Elements
  • Products
  • Pricing
  • RSS
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku Blog
    • Heroku News Blog
    • Heroku Engineering Blog
  • Twitter
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku
    • Heroku Status
  • Github
  • LinkedIn
  • © 2025 Salesforce, Inc. All rights reserved. Various trademarks held by their respective owners. Salesforce Tower, 415 Mission Street, 3rd Floor, San Francisco, CA 94105, United States
  • heroku.com
  • Legal
  • Terms of Service
  • Privacy Information
  • Responsible Disclosure
  • Trust
  • Contact
  • Cookie Preferences
  • Your Privacy Choices