From 5009f6e6885eea9dc86dbe02a6441002ce31674b Mon Sep 17 00:00:00 2001 From: amadzarak Date: Sat, 25 Apr 2026 22:36:53 -0400 Subject: [PATCH] OPC # 0002: Fix issue from docker root directory change Co-authored-by: Copilot --- ControlPlane.Api/Endpoints/InfraEndpoints.cs | 7 ++++++- ControlPlane.Api/Program.cs | 5 +++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ControlPlane.Api/Endpoints/InfraEndpoints.cs b/ControlPlane.Api/Endpoints/InfraEndpoints.cs index 7642141..e5c4c03 100644 --- a/ControlPlane.Api/Endpoints/InfraEndpoints.cs +++ b/ControlPlane.Api/Endpoints/InfraEndpoints.cs @@ -226,9 +226,14 @@ public static class InfraEndpoints private static string ResolveInfraPath(IConfiguration config) { + var configured = config["Infra:Path"]; + if (!string.IsNullOrWhiteSpace(configured)) + return Path.GetFullPath(configured); + + // Docker:RepoRoot is ClarityStack/ root — infra lives under OPC/ var repoRoot = config["Docker:RepoRoot"] ?? Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "..", "..", "..", "..")); - return Path.GetFullPath(Path.Combine(repoRoot, "infra")); + return Path.GetFullPath(Path.Combine(repoRoot, "OPC", "infra")); } private static Task<(int Code, string? Output)> DockerAsync(string args) => diff --git a/ControlPlane.Api/Program.cs b/ControlPlane.Api/Program.cs index 12dc195..47f51bc 100644 --- a/ControlPlane.Api/Program.cs +++ b/ControlPlane.Api/Program.cs @@ -32,9 +32,10 @@ builder.Services.AddSingleton(); // OPC persistence (raw Npgsql) var opcConnStr = builder.Configuration.GetConnectionString("opcdb"); if (!string.IsNullOrWhiteSpace(opcConnStr)) - builder.Services.AddSingleton(NpgsqlDataSource.Create(opcConnStr)); + // Replace 'localhost' with '127.0.0.1' to avoid Npgsql trying [::1] first on Windows + builder.Services.AddSingleton(NpgsqlDataSource.Create(opcConnStr.Replace("localhost", "127.0.0.1"))); else - builder.Services.AddSingleton(NpgsqlDataSource.Create("Host=localhost;Database=opcdb;Username=postgres;Password=controlplane-dev")); + builder.Services.AddSingleton(NpgsqlDataSource.Create("Host=127.0.0.1;Port=5433;Database=opcdb;Username=postgres;Password=controlplane-dev")); builder.Services.AddScoped(); // Named HttpClient for OpenRouter AI assist proxy