From 404b1e990485edbfe32050a305e85928e07bc354 Mon Sep 17 00:00:00 2001 From: James Wampler Date: Sat, 4 Jul 2026 17:55:06 -0700 Subject: [PATCH] Pin Aspire AppHost ports/credentials to match docker-compose defaults Aspire assigned random ports and an auto-generated Postgres password on each run, so the fixed targets baked into local.runsettings and docker-compose (localhost:5000/5173/5432, miccheck/password) didn't work when developing via Aspire instead of docker compose. Pins Postgres user/password/port and the api/admin HTTP endpoints so either workflow hits the same local addresses. --- src/MicCheck.AppHost/AppHost.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/MicCheck.AppHost/AppHost.cs b/src/MicCheck.AppHost/AppHost.cs index e654c5d..a99a11c 100755 --- a/src/MicCheck.AppHost/AppHost.cs +++ b/src/MicCheck.AppHost/AppHost.cs @@ -1,14 +1,26 @@ var builder = DistributedApplication.CreateBuilder(args); -var postgres = builder.AddPostgres("postgres").WithDataVolume("miccheck-pgdata").WithPgAdmin(); +// Pinned to match tests/api/MicCheck.Api.Tests.Integration/local.runsettings and +// src/admin's docker-compose defaults, so those fixed targets work whether the +// stack is run via `docker compose` or via this AppHost. +var postgresUser = builder.AddParameter("postgres-username", "miccheck"); +var postgresPassword = builder.AddParameter("postgres-password", "password", secret: true); + +var postgres = builder.AddPostgres("postgres", postgresUser, postgresPassword, port: 5432) + .WithDataVolume("miccheck-pgdata") + .WithPgAdmin(); var miccheckDb = postgres.AddDatabase("miccheck"); -var api = builder.AddProject("api").WithReference(miccheckDb).WaitFor(miccheckDb); +var api = builder.AddProject("api") + .WithReference(miccheckDb) + .WaitFor(miccheckDb) + .WithHttpEndpoint(port: 5000, name: "http"); builder.AddViteApp("admin", "../admin", "serve") .WithReference(api) .WaitFor(api) + .WithHttpEndpoint(port: 5173, name: "http") .WithExternalHttpEndpoints(); builder.Build().Run();