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
View 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
      • Node.js Behavior in Heroku
      • Troubleshooting Node.js Apps
    • 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
    • Heroku Inference
      • Inference API
      • Quick Start Guides
      • AI Models
      • Inference Essentials
    • Vector Database
    • Model Context Protocol
  • 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
  • Clojure
  • Deploying Clojure Apps on Heroku

Deploying Clojure Apps on Heroku

English — 日本語に切り替える

Last updated December 09, 2024

Table of Contents

  • Overview
  • Your Clojure application’s Source Code
  • The project.clj File
  • The Procfile
  • How to Keep Build Artifacts Out of git
  • Console
  • One-off Scripts

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

If you’re new to Heroku, start with the Getting Started with Clojure on Heroku tutorial.

 

Clojure is not yet supported on the Fir of the Heroku platform. Subscribe to our changelog to stay informed of when we add features.

Overview

To generate a project skeleton that has some extra convenient features that are useful for Heroku development, type lein new heroku helloworld. The skeleton project’s README.md file describes what it contains and how to use it.

The most important parts of an app are: your application’s source code in the src directory, a project.clj file in the root directory, and a Procfile that defines the app’s process types. A database isn’t automatically provisioned for Clojure apps, but it’s easy to add one if you need it.

Your Clojure application’s Source Code

Put your application source code into a folder within the src directory.

The project.clj File

Clojure’s dependency manager uses the project.clj file. Heroku’s Clojure support is applied only if a project.clj file exists in the root directory.

Projects that depend on dependencies that aren’t available in public repositories can deploy them to private repositories. The easiest way to do this is using a private S3 bucket with the s3-wagon-private Leiningen plugin.

It’s highly recommended to use AOT (ahead-of-time compilation) during deployment because it speeds up app boot time and catches certain types of errors before the app is live. The following project.clj settings apply AOT during deployment but not during local development:

  :profiles {:uberjar {:aot :all}}

The Procfile

A Procfile is a text file in the root directory of your application that defines process types and that explicitly declares what command must be executed to start your app. It looks something like this:

web: java $JVM_OPTS -cp target/helloworld-standalone.jar clojure.main -m helloworld.web

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 attach 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 doesn’t, the dyno doesn’t start.

Procfiles can contain additional process types. For example, you can declare one for a background worker process that processes items off a queue.

Your app’s config is exported to the command in the Procfile as environment variables. For instance, running heroku config:add JVM_OPTS=... changes the value used here.

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:

/target
/pom.xml
/.lein-*
/.env

Console

Heroku allows you to run one-off dynos, scripts and applications that only execute when needed, by using the heroku run command. Use this command to launch a REPL process attached to your local terminal for experimenting in your app’s environment:

Running heroku run lein repl uses a simplified version of the repl task provided by Leiningen.

$ heroku run lein repl
Running lein repl attached to terminal... up, run.1
Downloading Leiningen to .lein/leiningen-2.2.0-standalone.jar now...
[...]
Clojure 1.5.1
user=>

Since Leiningen isn’t included in your slug for size reasons, it’s downloaded on-demand here. The repl has your app’s namespaces available. For example:

user=> (require 'hello.world)
nil
user=> (hello.world/app {})
{:status 200, :headers {"Content-Type" "text/plain"}, :body "Hello, world"}

One-off Scripts

You can run a one-off Clojure script attached to the terminal in the same way, as long as the script exists in your deployed app. Try making a small script that prints to the console and exits:

src/hello/hi.clj

(ns hello.hi)

(defn -main [& args]
  (println "Hello there"))

Run the script in a one-off dyno with heroku run:

$ heroku run lein run -m hello.hi
Running lein run -m hello.hi attached to terminal... up, run.2
Hello there

Keep reading

  • Clojure

Feedback

Log in to submit feedback.

Heroku Clojure Support Getting Started on Heroku with Clojure

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