.NET on Miren
.NET isn't auto-detected, so you deploy ASP.NET Core apps with a Dockerfile.miren
that publishes your app with the SDK image and runs it on the smaller ASP.NET runtime
image.
Ask your AI coding agent to "set up this .NET app on Miren" after installing the
Miren agent skills. It adds the Dockerfile.miren, points Kestrel at
0.0.0.0:$PORT, wires up environment variables, and deploys — using this page as its
reference.
Do you need a Dockerfile?
Yes. Miren doesn't auto-detect .NET, 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 Kestrel must listen on 0.0.0.0 at
that port. The simplest way is to pass the URL to app.Run:
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.MapGet("/", () => "Hello from .NET on Miren!\n");
var port = Environment.GetEnvironmentVariable("PORT") ?? "8080";
app.Run($"http://0.0.0.0:{port}");
Reading PORT in code (as above) is the simplest approach. ASPNETCORE_URLS also works,
but Miren stores env vars literally and does not shell-expand $PORT, so you can't set
it to http://0.0.0.0:$PORT in app.toml — the app would receive that literal string. Use
it only from a shell entrypoint that expands PORT at runtime.
The Dockerfile
Create Dockerfile.miren in your project root. Replace dotnet-bench.dll with your
project's assembly name:
# ----- Build stage -----
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS builder
WORKDIR /app
COPY . .
RUN dotnet publish -c Release -o /out
# ----- Runtime stage -----
FROM mcr.microsoft.com/dotnet/aspnet:9.0
WORKDIR /app
COPY --from=builder /out .
EXPOSE 8080
CMD ["dotnet", "dotnet-bench.dll"]
.dockerignore
.git
bin
obj
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: dotnet /app/dotnet-bench.dll
Then create .miren/app.toml naming your app and deploy from your project root:
name = "dotnet-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 Environment.GetEnvironmentVariable or the
configuration system:
miren env set -e ASPNETCORE_ENVIRONMENT=Production
miren env set -s ConnectionStrings__Default
.NET maps __ in an env var name to nested configuration keys, so
ConnectionStrings__Default becomes ConnectionStrings:Default. You can also declare
variables in .miren/app.toml:
[[env]]
key = "ASPNETCORE_ENVIRONMENT"
value = "Production"
See App Configuration — Environment Variables.
Agent quick reference
- Detection: none — requires
Dockerfile.miren - Build:
dotnet publish -c Release -o /outon the SDK image; run ondotnet/aspnet - Service is required: define a
Procfile(web: dotnet /app/<assembly>.dll) — the imageCMDis not used - Port:
app.Run($"http://0.0.0.0:{port}")(readingPORTin code;ASPNETCORE_URLSis not shell-expanded) - Env vars:
miren env set -e/-s;__maps to nested config keys - Database: optional
[addons.miren-postgresql]injectsDATABASE_URL
Next steps
- Using Dockerfile.miren — how custom builds work
- Addons — managed Postgres and other backing services
- App Configuration — customize
.miren/app.toml - Deployment — how deploys build and activate