Skip to main content

Clojure on Miren

Clojure isn't auto-detected, so you deploy it with a Dockerfile.miren. This guide uses Ring with the Jetty adapter, run via the clojure CLI and deps.edn.

Let your agent do this

Ask your AI coding agent to "set up this Clojure app on Miren" after installing the Miren agent skills. It adds the Dockerfile.miren, binds Jetty to 0.0.0.0:$PORT, and deploys — using this page as its reference.

Do you need a Dockerfile?

Yes. Miren doesn't auto-detect Clojure, so add a Dockerfile.miren to your project root. Miren builds from it instead of guessing the stack — see Using Dockerfile.miren.

Want native support?

Miren auto-detects and builds common stacks (Python, Node, Bun, Go, Ruby, Rust) without a Dockerfile. This language isn't one of them yet — if you'd like first-class support, request it.

Bind to the injected port

Miren injects PORT and routes traffic to it, so read PORT and bind 0.0.0.0:

;; src/app.clj — deps.edn searches "src" and the Procfile runs the `app` namespace
(ns app
(:require [ring.adapter.jetty :as jetty]))

(defn handler [_]
{:status 200
:headers {"Content-Type" "text/plain"}
:body "Hello from Clojure on Miren!\n"})

(defn -main []
(let [port (Integer/parseInt (or (System/getenv "PORT") "8080"))]
(jetty/run-jetty handler {:port port :host "0.0.0.0" :join? true})))

A deps.edn with the source path and dependencies:

{:paths ["src"]
:deps {ring/ring-core {:mvn/version "1.12.2"}
ring/ring-jetty-adapter {:mvn/version "1.12.2"}}}

The Dockerfile

Create Dockerfile.miren in your project root. clojure -P downloads dependencies at build time so they're cached in the image:

FROM clojure:temurin-21-tools-deps

WORKDIR /app
COPY deps.edn .
RUN clojure -P
COPY . /app

EXPOSE 8080

.dockerignore

.git
.cpcache

Set up the app

Even with a Dockerfile.miren, Miren needs at least one service defined — it doesn't use the image's CMD as the start command. Add a Procfile that runs the main namespace:

web: clojure -M -m app

Then create .miren/app.toml naming your app and deploy from your project root:

name = "clojure-bench"
miren deploy
Deploying without a service fails

If no service is defined, the build succeeds but the deploy stops with no services defined: please define at least one service in a Procfile or .miren/app.toml.

For faster startup you can instead build an uberjar (via tools.build or depstar) and run java -jar, but running the clojure CLI directly with cached deps works fine.

Environment variables

Set variables with miren env set-e for plain values, -s for secrets (masked in output and logs). Read them with (System/getenv "KEY"):

miren env set -e LOG_LEVEL=info
miren env set -s DATABASE_URL

You can also declare variables in .miren/app.toml:

[[env]]
key = "DATABASE_URL"
value = ""
required = true
sensitive = true

See App Configuration — Environment Variables.

Agent quick reference

  • Detection: none — requires Dockerfile.miren
  • Base image: clojure:temurin-21-tools-deps; clojure -P caches deps in the build
  • Service is required: define a Procfile (web: clojure -M -m app) — the image CMD is not used
  • Port: (System/getenv "PORT"); run-jetty handler {:host "0.0.0.0"}
  • Env vars: miren env set -e/-s; read with (System/getenv "KEY")

Next steps