Scala on Miren
Scala isn't auto-detected, so you deploy it with a Dockerfile.miren that packages a
runnable jar. This guide uses scala-cli with the
Cask framework — the least-ceremony path. The
same jar-and-java -jar pattern works for sbt builds with http4s or Play.
Ask your AI coding agent to "set up this Scala app on Miren" after installing the
Miren agent skills. It adds the Dockerfile.miren, binds the server to
0.0.0.0:$PORT, and deploys — using this page as its reference.
Does this source build need a Dockerfile?
Yes. Miren doesn't auto-detect Scala, so add a Dockerfile.miren to your project root.
Miren builds from it instead of guessing the stack — see
Using Dockerfile.miren.
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. A Cask
app declares its port and host:
//> using dep com.lihaoyi::cask:0.9.4
object App extends cask.MainRoutes {
override def port = sys.env.getOrElse("PORT", "8080").toInt
override def host = "0.0.0.0"
@cask.get("/")
def hello() = "Hello from Scala on Miren!\n"
initialize()
}
The //> using dep line lets scala-cli resolve dependencies without a separate build
file.
The Dockerfile
Create Dockerfile.miren in your project root. scala-cli packages an assembly jar,
which runs on a plain JRE:
# ----- Build stage -----
FROM virtuslab/scala-cli:latest AS builder
WORKDIR /app
COPY . .
RUN scala-cli --power package app.scala -o app.jar --assembly
# ----- Runtime stage -----
FROM eclipse-temurin:21-jre
WORKDIR /app
COPY --from=builder /app/app.jar /app/app.jar
EXPOSE 8080
CMD ["java", "-jar", "app.jar"]
.dockerignore
.git
Deploy
The Dockerfile's CMD starts the app. Miren uses it as the web service's startup default,
so you don't need a Procfile or service command.
Create .miren/app.toml naming your app and deploy from your project root:
name = "scala-bench"
miren deploy
Environment variables
Set variables with miren env set — -e for plain values, -s for secrets (masked in
output and logs). Read them with sys.env.get("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 - Build:
scala-cli --power package app.scala -o app.jar --assembly; run on a JRE image - Startup: inherited from the Dockerfile
CMD; noProcfileor service command needed - Port:
sys.env.getOrElse("PORT", "8080").toInt; Caskoverride def host = "0.0.0.0" - Env vars:
miren env set -e/-s; read withsys.env.get
Next steps
- Java on Miren — the JVM sibling guide
- Using Dockerfile.miren — how custom builds work
- App Configuration — customize
.miren/app.toml - Deployment — how deploys build and activate