Nim on Miren
Nim isn't auto-detected, so you deploy it with a Dockerfile.miren that compiles a
native binary and runs it on a minimal image. This guide uses the
Jester web framework.
Ask your AI coding agent to "set up this Nim app on Miren" after installing the
Miren agent skills. It adds the Dockerfile.miren, confirms the server
binds 0.0.0.0:$PORT, and deploys — using this page as its reference.
Do you need a Dockerfile?
Yes. Miren doesn't auto-detect Nim, 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. With
Jester:
import jester
import std/[os, strutils]
let appPort = parseInt(getEnv("PORT", "8080"))
settings:
port = Port(appPort)
bindAddr = "0.0.0.0"
routes:
get "/":
resp "Hello from Nim on Miren!\n"
A minimal .nimble file declares the dependency and binary:
version = "0.1.0"
author = "you"
description = "nim on miren"
license = "MIT"
srcDir = "."
bin = @["app"]
requires "nim >= 2.0.0"
requires "jester >= 0.6.0"
The Dockerfile
Create Dockerfile.miren in your project root:
# ----- Build stage -----
FROM nimlang/nim:2.0.8 AS builder
WORKDIR /app
COPY . .
RUN nimble install -dy && nim c -d:release --opt:speed --mm:refc -o:app app.nim
# ----- Runtime stage -----
FROM debian:12-slim
RUN apt-get update -y && apt-get install -y libpcre3 openssl ca-certificates \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/app /usr/local/bin/app
EXPOSE 8080
CMD ["app"]
--mm:refcJester runs on httpbeast, which spawns worker threads. Built with Nim 2.0's default ORC
memory manager, the app segfaults on startup (SIGSEGV: Illegal storage access,
right after "Starting N threads"). Compiling with --mm:refc (the older reference-counting
GC) fixes it. This guide also uses a glibc base (debian, via the non-Alpine nimlang/nim
image) and installs libpcre3 for Jester's routing.
.dockerignore
.git
app
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:
web: /usr/local/bin/app
Then create .miren/app.toml naming your app and deploy from your project root:
name = "nim-bench"
miren deploy
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.
Environment variables
Set variables with miren env set — -e for plain values, -s for secrets (masked in
output and logs). Read them with 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(native binary) - Build:
nimble install -dy && nim c -d:release --mm:refc -o:app app.nim --mm:refcrequired: Jester/httpbeast segfaults on startup with Nim 2.0's default ORC GC- Runtime libs:
libpcre3 opensslondebian-slim(glibc base) - Service is required: define a
Procfile(web: /usr/local/bin/app) — the imageCMDis not used - Port:
getEnv("PORT", "8080"); Jestersettings: bindAddr = "0.0.0.0" - Env vars:
miren env set -e/-s; read withgetEnv
Next steps
- Using Dockerfile.miren — how custom builds work
- App Configuration — customize
.miren/app.toml - Deployment — how deploys build and activate