Skip to content

Deployment ​

One page for every option

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 yours. ApiHost stands for your app's name.

deploy/ has everything to run the app on a small server: a production docker-compose.yml (PostgreSQL, the app's container, and Caddy for automatic HTTPS) and a step-by-step guide in deploy/README.md. The container image is built with dotnet publish src/ApiHost -c Release /t:PublishContainer.

The rest of this page applies wherever you run it.

Publishing ​

dotnet publish builds the React app into wwwroot and pre-generates Wolverine's handler code, so production starts quickly and compiles nothing at runtime.

bash
dotnet publish src/ApiHost -c Release -o publish
cd publish                                         # run from here, so it finds wwwroot
ASPNETCORE_ENVIRONMENT=Production dotnet ApiHost.dll

Marten

Marten creates and updates its tables when the app starts. For health checks, see Observability.

EF Core

EF Core migrations are applied when the app starts. For health checks, see Observability.

What the published app serves ​

  • The pages in src/Client/src/pages.ts: the public ones (index: true, such as /) as HTML the build pre-rendered, and the others as a page that starts the app. Any other path gets that page with status 404 (the app shows its not-found page), so search engines don't index made-up URLs. The HTML is sent with Cache-Control: no-cache, so browsers and CDNs pick up a new deployment at once.
  • Built files under /assets/, with content hashes in their names, cached for a year.
  • /robots.txt (everything may be crawled except /api/) and /sitemap.xml (the pages marked index in pages.ts), using the address the visitor used.
  • Unknown /api/ paths answer 404 as ProblemDetails; errors are ProblemDetails with a trace ID that matches the logs.

Configuration ​

Set these with environment variables (or any ASP.NET Core configuration source):

SettingExample
Marten ConnectionStrings__MartenHost=db;Database=apihost;Username=app;Password=…
EF Core ConnectionStrings__PostgresHost=db;Database=apihost;Username=app;Password=…
ASPNETCORE_URLShttp://+:8080
ASPNETCORE_FORWARDEDHEADERS_ENABLEDtrue behind a reverse proxy, so the app sees clients' real addresses and HTTPS
OTEL_EXPORTER_OTLP_ENDPOINTOptional: where to send traces, metrics and logs
Storage__ProviderWhere uploaded files go: Local (default), S3 or AzureBlob, with that provider's settings (file storage)
Storage__Local__RootPathLocal disk: the folder for files; put it on a volume in a container
Analytics__GoogleTagManagerIdOptional: a Google Tag Manager container, loaded once visitors accept cookies; also Analytics__ConnectOrigins__0, Analytics__ScriptOrigins__0 for its tags (analytics)
Legal__TermsUrl, Legal__PrivacyUrlOptional: your terms of service and privacy policy (a path such as /terms or a full address), linked in the footer
With accounts Legal__VersionThe version of those documents (default 1): people accept it at sign-up, and are asked again when it goes up (accounts)
Attachments__MaxBytes, Attachments__MaxPerTodoThe largest file that can be attached to a Todo (default 25 MB; with local disk, raise Storage__Local__MaxUploadBytes too) and how many one Todo can have (default 10)

With accounts

| Jwt__SigningKey | A random secret of at least 32 bytes (how to change it) | | App__ClientUrl | The app's public address, such as https://app.example.com: links in emails use it | | Email__Smtp__Host, Email__Smtp__Port, Email__Smtp__Security, Email__Smtp__UserName, Email__Smtp__Password, Email__Smtp__From | Your email provider's SMTP settings (how-to) | | Accounts__AdminEmails__0 | Your email: that account becomes an admin once its email is confirmed (more: __1, __2, ...) | | Accounts__AllowRegistration | false to allow only invited people to create accounts (default true) | | Accounts__AuthAttemptsPerMinute | Sign-in and account attempts allowed per client address per minute | | Accounts__RequireTwoFactorForAdmins | true to let admins use the back office only with two-factor authentication (or passkeys only) on their account (default false, more) | | Accounts__TwoFactorIssuer | The name authenticator apps show next to the account (default: the app's name) | | Accounts__RejectBreachedPasswords | true to refuse new passwords known from data breaches, checked with Have I Been Pwned without sending the password (default false, more). The server must be able to reach api.pwnedpasswords.com | | Accounts__AskForProductNews | false if the app doesn't send product news: hides the "Send me product news" box at sign-up and in Settings (default true, more) | | Pictures__UploadsPerMinute | Picture, logo and attachment uploads allowed per user per minute (default 10) | | Pictures__Gravatar | true to show people's Gravatar when they haven't uploaded a picture (default false, why) | | Authentication__Google__ClientId, Authentication__Google__ClientSecret | Optional: turns on "Continue with Google" (how-to) | | Authentication__GitHub__ClientId, Authentication__GitHub__ClientSecret | Optional: turns on "Continue with GitHub" | | With organisations Billing__Stripe__SecretKey, Billing__Stripe__WebhookSecret | Optional: paid plans through Stripe (billing) | | With organisations Billing__Stripe__AutomaticTax | true to have Stripe Tax add sales tax and VAT | | With organisations Billing__TrialDays, Billing__TrialPlan | The trial new organisations get (default 14 days of pro; 0 days turns it off) |

The app refuses to start outside Development if Jwt:SigningKey is missing, too short, or still the development key, or if App:ClientUrl isn't set. Email links (confirmation, password reset, invitations) are built from App:ClientUrl, never from the request's Host header: that header is chosen by whoever sends the request, so a password reset requested with a forged host would email a real link to someone else's site. Also refuse requests for other host names: the Caddy setup in deploy/ only serves DOMAIN, and without such a proxy set AllowedHosts (for example AllowedHosts=app.example.com; keep your load balancer's health check host in it too).

The demo user is never created outside Development. Without Email:Smtp:Host, no emails are sent and the app logs a warning instead (never the link), and since new accounts must confirm their email, nobody can finish signing up: configure SMTP before people register.

ASP.NET Core Data Protection keys, which protect the tokens in account emails, are stored in PostgreSQL, so email links keep working across restarts and on every instance of the app.

Running more than one instance ​

The app is built to run as one instance, which a small server handles comfortably. Some parts already work across several instances, because they coordinate through PostgreSQL: Wolverine's outbox and scheduled messages, and the Data Protection keys.

Two parts don't yet:

  • Live updates (SignalR): a message only reaches browsers connected to the instance that sent it. Several instances need a SignalR backplane (for example Redis).
  • With accounts Sign-in rate limits: each instance counts attempts separately, so the limits are multiplied by the number of instances. Shared limits need a shared store (for example Redis).
  • Without accounts In-memory state you add yourself (caches, counters) is per instance.

Behind a CDN such as Cloudflare, one instance goes a long way, since the built client is served from the CDN's cache; see Put Cloudflare in front.

Before going live, read the deployment checklist in Security.

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