From 25c937e41c31b7cc326005856ba7337e18d108ae Mon Sep 17 00:00:00 2001 From: amadzarak Date: Sun, 26 Apr 2026 12:48:02 -0400 Subject: [PATCH] OPC # 0007: Patch FDEV provisioning for local aspire development Co-authored-by: Copilot --- Clarity.AppHost/AppHost.cs | 43 ++++---------------- Clarity.AppHost/appsettings.Development.json | 4 ++ Clarity.Server/appsettings.Development.json | 13 ++++-- 3 files changed, 22 insertions(+), 38 deletions(-) diff --git a/Clarity.AppHost/AppHost.cs b/Clarity.AppHost/AppHost.cs index ed0a96a..6aa820c 100644 --- a/Clarity.AppHost/AppHost.cs +++ b/Clarity.AppHost/AppHost.cs @@ -3,53 +3,27 @@ using Scalar.Aspire; var builder = DistributedApplication.CreateBuilder(args); -#region MINIO -var minio = builder.AddMinioContainer("minio"); +#region EXTERNAL CONNECTIONS — OPC infra (postgres, minio) +// Connection strings are declared in appsettings.Development.json and point at the +// fdev tenant on the shared OPC platform infra running via OPC/infra/docker-compose.yml. +var postgresdb = builder.AddConnectionString("postgresdb"); +var minio = builder.AddConnectionString("minio"); #endregion #region REDIS var cache = builder.AddRedis("cache"); #endregion -#region POSTGRESQL AND PGADMIN -var postgres = builder.AddPostgres("postgres") - .WithLifetime(ContainerLifetime.Persistent) - .WithHostPort(5432) - .WithPgAdmin(); - -var postgresdb = postgres.AddDatabase("postgresdb"); -#endregion - -#region KEYCLOAK -var keycloakDb = postgres.AddDatabase("authdb"); - -var keycloak = builder.AddKeycloak("keycloak", 8080) - .WithEnvironment(async ctx => - { - var connString = await keycloakDb.Resource.ConnectionStringExpression.GetValueAsync(CancellationToken.None); - var conn = new Npgsql.NpgsqlConnectionStringBuilder(connString); - ctx.EnvironmentVariables["KC_DB"] = "postgres"; - ctx.EnvironmentVariables["KC_DB_URL"] = $"jdbc:postgresql://postgres:5432/{keycloakDb.Resource.DatabaseName}"; - ctx.EnvironmentVariables["KC_DB_USERNAME"] = conn.Username!; - ctx.EnvironmentVariables["KC_DB_PASSWORD"] = conn.Password!; - }) - .WaitFor(keycloakDb) - .WithRealmImport("KeycloakConfig/"); -#endregion - #region EFCORE MIGRATION WORKER var migrations = builder.AddProject("clarity-migrationservice") - .WithReference(postgresdb) - .WaitFor(postgresdb); + .WithReference(postgresdb); #endregion #region REST API var server = builder.AddProject("server") - .WaitFor(keycloak) .WithReference(cache) .WithReference(postgresdb) .WaitFor(cache) - .WaitFor(postgresdb) .WithReference(migrations) .WithReference(minio) .WaitForCompletion(migrations) @@ -60,11 +34,10 @@ var server = builder.AddProject("server") #region REACT var webfrontend = builder.AddViteApp("webfrontend", "../frontend") - .WaitFor(keycloak) .WithReference(server) .WaitFor(server) - .WithEnvironment("VITE_KEYCLOAK_URL", keycloak.GetEndpoint("http")) - .WithEnvironment("VITE_KEYCLOAK_REALM", "clarity") + .WithEnvironment("VITE_KEYCLOAK_URL", "https://keycloak.clarity.test") + .WithEnvironment("VITE_KEYCLOAK_REALM", "clarity-fdev-app-clarity-01000000") .WithEnvironment("VITE_KEYCLOAK_CLIENT_ID", "clarity-web-app"); server.PublishWithContainerFiles(webfrontend, "wwwroot"); diff --git a/Clarity.AppHost/appsettings.Development.json b/Clarity.AppHost/appsettings.Development.json index 0c208ae..dfb7c00 100644 --- a/Clarity.AppHost/appsettings.Development.json +++ b/Clarity.AppHost/appsettings.Development.json @@ -4,5 +4,9 @@ "Default": "Information", "Microsoft.AspNetCore": "Warning" } + }, + "ConnectionStrings": { + "postgresdb": "Host=localhost;Port=5432;Database=clarity_fdev_app_clarity_01000000;Username=postgres;Password=postgres", + "minio": "Endpoint=http://localhost:9000/;AccessKey=minioadmin;SecretKey=minioadmin" } } diff --git a/Clarity.Server/appsettings.Development.json b/Clarity.Server/appsettings.Development.json index 5342ec4..64af9bd 100644 --- a/Clarity.Server/appsettings.Development.json +++ b/Clarity.Server/appsettings.Development.json @@ -5,7 +5,14 @@ "Microsoft.AspNetCore": "Warning" } }, - "ConnectionStrings": { - "postgresdb": "Host=localhost;Port=56235;Database=postgresdb;Username=postgres;Password=WdW+Q3wzq.Ssuzq6rT4A}_" - } + "Keycloak": { + "Realm": "clarity-fdev-app-clarity-01000000", + "BaseUrl": "https://keycloak.clarity.test", + "InternalUrl": "http://localhost:8080" + }, + "Vault": { + "Address": "http://localhost:8200", + "Token": "hvs.YLYBCUXgeJM3Gq4C10tWBWjw" + }, + "Tenant__Id": "fdev-app-clarity-01000000" }