There are two pre-configured environments, local and docker. Logs go to the console in both. Traces, metrics and logs also leave over OTLP whenever OTEL_EXPORTER_OTLP_ENDPOINT is set, which Docker Compose does for you.
The app stores its data in a SQLite file, movie-reviews.db, next to the app. In Docker the file is /app/data/movie-reviews.db, on the movie-reviews-data volume, so it survives a restart. On startup the app applies any pending Entity Framework Core migrations. When Database:SeedSampleData is true, it also seeds the same sample data into an empty database. It's on in appsettings.local.json and appsettings.docker.json and off everywhere else, so a deployed copy never starts with fake data. Delete the file, or run docker compose down -v, to start again. Change ConnectionStrings:MovieReviews to point somewhere else, or to Data Source=MovieReviews;Mode=Memory;Cache=Shared to keep everything in memory.
To add a migration after changing the data model:
dotnet tool install --global dotnet-ef
dotnet ef migrations add <Name> --project ./src/Infrastructure --output-dir Databases/MovieReviews/MigrationslaunchSettings.json sets the ports, environment and logging, so one command is enough.
dotnet run --project ./src/PresentationIt listens on https://localhost:7311, and on http://localhost:7310, which redirects there. If your browser or curl doesn't trust the .NET development certificate yet, run dotnet dev-certs https --trust once. Open src/Presentation/Presentation.http in Visual Studio, Rider or VS Code to call every endpoint with one click.
docker-compose.yml starts the app and the Aspire dashboard, which shows its logs, traces and metrics. The app sends everything to an OpenTelemetry Collector, and the collector forwards it to the dashboard, the same shape as a production setup. The dashboard is only a container that receives OTLP; nothing in the solution depends on Aspire. The dashboard has no login and the collector accepts OTLP from anyone on ports 7313 and 7314. That's on purpose for a developer's machine, so don't run this compose file anywhere other people can reach.
docker compose up -d --build- App: http://localhost:7310/scalar (Scalar API reference)
- OpenAPI document: http://localhost:7310/openapi/v1.json
- Aspire dashboard: http://localhost:7312
- Health checks: http://localhost:7310/health/live (the process is up) and http://localhost:7310/health/ready (the database can be reached). Both answer without a token. The image's
HEALTHCHECKuses the live one.
The container runs as the image's non-root app user.
To shut the containers down:
docker compose downEvery Lean Mean Clean template has its own block of ten ports on your machine, so this solution runs beside one made from another template without a clash. This one uses 7310 to 7319:
| Port | What listens |
|---|---|
| 7310 | The app over HTTP, from Docker Compose or dotnet run |
| 7311 | The app over HTTPS, dotnet run only |
| 7312 | The Aspire dashboard |
| 7313 | The OpenTelemetry Collector, OTLP over gRPC |
| 7314 | The OpenTelemetry Collector, OTLP over HTTP |
The app listens on 7310 everywhere: under dotnet run, inside its container and on your machine, so docker run -p 7310:7310 works the same way. The dashboard and collector keep their usual ports inside their containers. To move the app, change applicationUrl in launchSettings.json, ASPNETCORE_HTTP_PORTS, EXPOSE and the HEALTHCHECK in the Dockerfile, and its mapping in docker-compose.yml. When you deploy the image, point the platform's target port at 7310. 7315 to 7319 are spare for anything you add.
The app always collects OpenTelemetry traces and metrics, and exports them, along with its logs, only when OTEL_EXPORTER_OTLP_ENDPOINT is set. Every other standard OTEL_* variable works too, such as OTEL_SERVICE_NAME, OTEL_EXPORTER_OTLP_PROTOCOL and OTEL_EXPORTER_OTLP_HEADERS, so sending it to Grafana, Honeycomb, Seq or a collector is a settings change.
In production, send the app's telemetry to a collector rather than straight to a backend. Run one beside the app (a sidecar or agent) or as a shared gateway, and give it your backend's exporter. The collector then owns batching, retries, sampling and scrubbing, and changing backend never touches the app. otel-collector.yaml is a starting point: an OTLP receiver, the memory limiter and batch processors, and one exporter to swap.
To see a dotnet run in the dashboard, start the collector and the dashboard, and point the app at the collector:
docker compose up -d otel-collector
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:7313 dotnet run --project ./src/PresentationEvery span, metric and log carries service.version, so you can always tell which build sent it.
The app redirects HTTP to HTTPS whenever it has an HTTPS port, which is why dotnet run sends http://localhost:7310 on to https://localhost:7311. Outside the local and Development environments it also sends an HSTS header. The container only listens on HTTP, so in production put it behind a proxy or load balancer that ends TLS, and set ASPNETCORE_FORWARDEDHEADERS_ENABLED=true so the app knows the original request was HTTPS.
dotnet testThe tests never touch movie-reviews.db. Each test builds its own in-memory SQLite database from the migrations and the same fixed seed, so no test can change what another one sees and the results are the same every time.