Skip to content

feat: add AddStandardMailHog/AddStandardPostgres Aspire AppHost helpers - #163

Merged
andregoepel merged 1 commit into
mainfrom
feature/aspire-apphost-helpers
Jul 26, 2026
Merged

feat: add AddStandardMailHog/AddStandardPostgres Aspire AppHost helpers#163
andregoepel merged 1 commit into
mainfrom
feature/aspire-apphost-helpers

Conversation

@andregoepel

Copy link
Copy Markdown
Owner

Summary

5 AppHost.cs files across the ecosystem (andregoepel-dev, finance-app, customer-portal, this repo's own sample, marten-identity's sample) hand-roll ~65%-identical MailHog + Postgres + EmailSender__* blocks. New packable project AndreGoepel.AppFoundation.Aspire extracts the container-wiring core.

Two things this fixes along the way

MailHog endpoint name standardized on "http" (not "web") — matches AndreGoepel.Testing.E2E's E2EAppFixtureOptions.MailHogEndpointName default, shipped in Wave 1. andregoepel-dev/finance-app currently use "web"; customer-portal/this repo already used "http". Adopting this helper fixes the inconsistency as a side effect.

isE2E gate exists everywhere now. AddStandardPostgres(isE2E, ...) skips WithDataVolume, persistent lifetime, and the fixed host port when isE2E is true. Confirmed by reading all 5 AppHosts: finance-app already gates all three; marten-identity gates the volume; andregoepel-dev and customer-portal currently have no isE2E gate at all — their Postgres always persists regardless of E2E mode. That gap is exactly what customer-portal#91 and andregoepel-dev#58 (both already filed) should pick up when they adopt this package.

Design

  • AddStandardMailHog(builder, name, tag, smtpPort, httpPort) returns the container resource so callers can still wire up their own app-specific EmailSender__* env vars (sender name/credentials stay app-specific, not standardized).
  • AddStandardPostgres(builder, isE2E, ...) returns a StandardPostgres(Server, Database) record, deconstructible so the common case stays a one-liner: var (_, db) = builder.AddStandardPostgres(isE2E);.
  • Lives in this repo as a new package (not app-foundation's runtime packages) since AppHost projects are dev-only orchestration outside the core → marten-* → app-foundation → host apps dependency order the root CLAUDE.md governs — same reasoning that already puts ServiceDefaults here.
  • This repo's own sample AppHost.cs migrated to dogfood both helpers.

Verification

  • dotnet csharpier format . clean
  • dotnet build — 0 warnings, 0 errors
  • dotnet test — 119 tests passing total (5 new, resource-model only — no Docker needed): MailHog endpoint names/ports, Postgres isE2E gating of volume/lifetime, database-name-vs-resource-name distinction
  • dotnet list package --vulnerable --include-transitive — clean

Closes #154. Follow-ups tracked separately: finance-app#69, customer-portal#91, andregoepel-dev#58 (isE2E gate adoption + endpoint rename in the 3 repos still on the old pattern).

@andregoepel
andregoepel merged commit 3da7fc2 into main Jul 26, 2026
4 checks passed
@andregoepel
andregoepel deleted the feature/aspire-apphost-helpers branch July 26, 2026 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Aspire AppHost helper extensions: AddStandardMailHog / AddStandardPostgres (plan F4)

1 participant