Refactor database connection handling and update Docker Compose environment variables #5
This commit is contained in:
@@ -39,8 +39,13 @@ namespace Api
|
||||
});
|
||||
builder.Services.AddControllers();
|
||||
// Add DbContext with SQL Server
|
||||
// Allow connection string to be set via environment variable (e.g., in Docker)
|
||||
var envConnectionString = Environment.GetEnvironmentVariable("DB_CONNECTION_STRING");
|
||||
var connectionString = !string.IsNullOrWhiteSpace(envConnectionString)
|
||||
? envConnectionString
|
||||
: builder.Configuration.GetConnectionString("DefaultConnection");
|
||||
builder.Services.AddDbContext<AppDbContext>(options =>
|
||||
options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")));
|
||||
options.UseSqlServer(connectionString));
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
{
|
||||
/*
|
||||
The following identity settings need to be configured
|
||||
before the project can be successfully executed.
|
||||
For more info see https://aka.ms/dotnet-template-ms-identity-platform
|
||||
*/
|
||||
"AzureAd": {
|
||||
"Instance": "https://login.microsoftonline.com/",
|
||||
"Domain": "qualified.domain.name",
|
||||
"TenantId": "22222222-2222-2222-2222-222222222222",
|
||||
"ClientId": "11111111-1111-1111-11111111111111111",
|
||||
|
||||
"Scopes": "access_as_user",
|
||||
"CallbackPath": "/signin-oidc"
|
||||
"Authentication": {
|
||||
"PocketId": {
|
||||
"Authority": "https://identity.lesko.me",
|
||||
"ClientId": "21131567-fea1-42a2-8907-21abd874eff8",
|
||||
"ClientSecret": "a633GE6G3JoY8WopnsxhSXQpmsTuXa63",
|
||||
"CallbackPath": "/signin-pocketid",
|
||||
"Scopes": "openid profile email"
|
||||
}
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
@@ -20,4 +15,4 @@ For more info see https://aka.ms/dotnet-template-ms-identity-platform
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user