Skip to main content

Deploy Apps on Heroku

Learning Objectives

After completing this unit, you’ll be able to:

  • Describe the different deployment options with Heroku.
  • Explain the pros and cons of each option.

Heroku offers multiple deployment options. The method you choose depends on your specific deployment process, requirements, and apps. 

Deploy with Git

This method is the simplest mode of deployment. Add your Heroku app as a remote to an existing Git repository, then use git push to send your code to Heroku. Heroku automatically builds your application and creates a release.

Deploy with the GitHub Integration

The GitHub integration allows you to deploy changes from a GitHub repo directly to Heroku. This integration has more features than any other deployment option. After linking your repository, changes pushed to your repo automatically deploy to the app. You can configure automatic deployments for a specific branch, or manually trigger deployments from GitHub. If you use continuous integration (CI), such as Heroku CI, you can prevent deployments to Heroku if tests fail.

GitHub integration is also useful for automating deployments to pipelines. For example, when you merge a change into the main branch, you can auto-deploy it to staging for testing. 

Deploy with Heroku Review Apps

Review Apps allow you to deploy any GitHub pull request (PR) as an isolated, disposable app. You can demo and test the PR without overwriting your production app–a great time saver for testing. Closing the PR destroys the review app.

Deploy with the 'Deploy to Heroku' Button

The Deploy to Heroku button allows you to deploy an app to Heroku from a web browser with clicks. You can parameterize each button with different settings, such as pass custom environment variables to Heroku, use a specific Git branch, or provide OAuth keys. Apps deployed with this button don't auto-update when you add new commits to the GitHub repo.

Deploy with Docker

Docker bundles your apps into self-contained environments. This isolation ensures that they behave the same in both development and production. Docker provides more control over the languages, frameworks, and libraries used to run your app. To deploy a container to Heroku, push an image to the Heroku container registry or declare it in your app's heroku.yml file to build it automatically.

Deploy with Hashicorp Terraform

Hashicorp Terraform is an infrastructure-as-code tool that helps manage complex infrastructure. You can define your apps with HCL, a declarative configuration language, to automate the process of deploying and managing Heroku apps. Terraform v0.12+ allows you to store remote state, so you can run Terraform on a Heroku dyno and store the Terraform state in a Heroku Postgres database.

Compare Deployment Options

Use this table to help choose the best deployment option for your use case and workflow.

Deployment Method

Requirements

Best Suited For

Pros

Cons

Git

- Full access to both the Git repository and Heroku app to manually push code to production. 

- Projects with small, trusted teams.

- Simple to add to any Git-based workflow

- Supports Git submodules 

- Requires manually deploying code with git push

GitHub Integration

- Admin access to a GitHub repo

- Automated deployments

- Automatically deploys apps and keeps them up to date

- Integrates with Heroku Pipelines, Review Apps, and Heroku CI for a continuous workflow

- No support for Git submodules

Heroku Review Apps

- The GitHub integration 

- Heroku Pipelines

- Projects in GitHub with apps deployed to multiple environments.

- Option to automatically create and update Review Apps for each PR

- Supports Docker images

- Supports Heroku Private Spaces for testing changes in an isolated environment

- Additional costs from resources used in Review Apps. See tips on optimizing costs on the Dev Center.

'Deploy to Heroku' Button

- A GitHub repo

- A valid app.json file in the project's root directory

- Apps provided to your users or customers, such as open-source projects

- Onboarding new hires

- Great for sharing template projects

- Easy to add to a project's README file or web page

- Provides a template with pre-configured default values, environment variables, and parameters

- No support for Git submodules

- No auto-updates when the repo changes. You must use another deployment method for subsequent deploys to the same app.

Docker

- A Docker image

- Apps with custom stacks.

- More control over your app's stack

- Automatically generate images, or push an existing image to the container registry

- Consistency between environments

- Compatible with Heroku Review Apps

- You must maintain your own stack

- No support for pipeline promotions

Hashicorp Terraform

- Terraform

- Apps with complex infrastructure components

- Automates Heroku app deployments

- Allows you to deploy Heroku apps as code

- Simplifies the management of large, complex deployments

- Can configure apps, Private Spaces, or resources from other providers into a repeatable multi-provider architecture

Heroku Support can't provide help with these more complex deployments

Summary

You now know about the different deployment options. Continue this module to learn about some of the infrastructure used to run apps on Heroku.

Resources 

Keep learning for
free!
Sign up for an account to continue.
What’s in it for you?
  • Get personalized recommendations for your career goals
  • Practice your skills with hands-on challenges and quizzes
  • Track and share your progress with employers
  • Connect to mentorship and career opportunities