diff --git a/Api/Program.cs b/Api/Program.cs index 33ff6a9..9bfe4f6 100644 --- a/Api/Program.cs +++ b/Api/Program.cs @@ -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(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(); diff --git a/Api/appsettings.json b/Api/appsettings.json index 760e771..9925c2d 100644 --- a/Api/appsettings.json +++ b/Api/appsettings.json @@ -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": "*" -} +} \ No newline at end of file diff --git a/deployment/docker-compose.yaml b/deployment/docker-compose.yaml index 0e72ccb..3882f26 100644 --- a/deployment/docker-compose.yaml +++ b/deployment/docker-compose.yaml @@ -6,14 +6,15 @@ services: depends_on: - db restart: unless-stopped + environment: + - ASPNETCORE_ENVIRONMENT=Production + - ConnectionStrings__DefaultConnection=Server=localhost;Database=centrum;User Id=sa;Password=$DB_PASSWORD; network_mode: host - ports: - - "5000:5000" db: image: mcr.microsoft.com/mssql/server:2019-latest restart: unless-stopped network_mode: host environment: - SA_PASSWORD: P@ssw0rd + SA_PASSWORD: $DB_PASSWORD ACCEPT_EULA: Y