Added DB_HOST env variable

This commit is contained in:
Kamigen
2024-04-15 19:09:03 -04:00
parent b6e65b416d
commit e04f8f1968
2 changed files with 6 additions and 3 deletions

View File

@@ -20,11 +20,14 @@ public static class DependencyInjection
{
// Replace password in the connection string with env var.
var connectionString = configuration.GetConnectionString("DefaultConnection") ?? "";
Guard.Against.Null(connectionString, message: "Connection string 'DefaultConnection' not found.");
var dbPassword = Environment.GetEnvironmentVariable("DB_PASSWORD");
var dbHost = Environment.GetEnvironmentVariable("DB_HOST") ?? "localhost";
connectionString = connectionString.Replace("{DB_PASSWORD}", dbPassword);
Guard.Against.Null(connectionString, message: "Connection string 'DefaultConnection' not found.");
connectionString = connectionString.Replace("{DB_HOST}", dbHost);
services.AddScoped<ISaveChangesInterceptor, AuditableEntityInterceptor>();
services.AddScoped<ISaveChangesInterceptor, DispatchDomainEventsInterceptor>();