Run everything with Aspire
What this page covers
Every choice of --Persistence, --Auth, --IncludeTests and --Aspire: a label says which options a part is for. The copy in your app's docs/ folder has only the parts for yours. ApiHost stands for your app's name.
This app was created with --Aspire true, so it has an Aspire AppHost (src/ApiHost.AppHost, MIT licensed). One command starts everything for development:
cd src/Client && npm install && cd ../.. # once, for the Vite dev server
dotnet run --project src/ApiHost.AppHostIt starts, in order:
- With accounts PostgreSQL in a container, with its data in a volume, and Mailpit to catch emails.
- Without accounts PostgreSQL in a container, with its data in a volume.
- The API on http://localhost:5133 once the database is up, as
dotnet runwould. - The Vite dev server on http://localhost:5173 once the API is healthy. Open the app there.
It also opens the Aspire dashboard (the address is printed, with a login token). Every part's logs are there, and the API's traces and metrics: Aspire sets OTEL_EXPORTER_OTLP_ENDPOINT, which the app's OpenTelemetry set-up (src/ApiHost/Observability/) already sends to.
With accounts
Mailpit's address is listed with the resources.
docker compose up -d and dotnet run --project src/ApiHost still work as the README describes; use one or the other, since both want port 5432 or 5133. Production doesn't change either: the AppHost is for development only, and deploy/ runs the app with Docker Compose and Caddy.
Good to know
- PostgreSQL keeps running after you stop the AppHost (it's a persistent container), so the next start is quick. Remove it with
docker rm -fon thepostgres-...container, and its data withdocker volume rmon the...-postgres-datavolume. - Its password is fixed (
postgres, inAppHost.cs), because the data volume outlives it. It's for local development only. - HTTP by default. The AppHost's
httplaunch profile serves the dashboard over plain HTTP on localhost, so it needs no developer certificate. For HTTPS, trust the certificate withdotnet dev-certs https --trustand run with--launch-profile https. - No ServiceDefaults project: the app already has its own health checks and OpenTelemetry set up, and it's a single service, so it needs no service discovery.