Skip to content

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:

bash
cd src/Client && npm install && cd ../..        # once, for the Vite dev server
dotnet run --project src/ApiHost.AppHost

It starts, in order:

  1. With accounts PostgreSQL in a container, with its data in a volume, and Mailpit to catch emails.
  2. Without accounts PostgreSQL in a container, with its data in a volume.
  3. The API on http://localhost:5133 once the database is up, as dotnet run would.
  4. 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 -f on the postgres-... container, and its data with docker volume rm on the ...-postgres-data volume.
  • Its password is fixed (postgres, in AppHost.cs), because the data volume outlives it. It's for local development only.
  • HTTP by default. The AppHost's http launch profile serves the dashboard over plain HTTP on localhost, so it needs no developer certificate. For HTTPS, trust the certificate with dotnet dev-certs https --trust and 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.

Documentation for v0.10.0. Released under the MIT licence.