From d0c710ebdca0ff168dcaaa2bcd6c8ff2567e5546 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Sat, 6 May 2023 16:14:56 -0700 Subject: [PATCH] Docker compose works --- .../Web.Bff.Shopping/aggregator/Program.cs | 9 ++------- .../aggregator/appsettings.json | 3 ++- src/Services/Catalog/Catalog.API/Program.cs | 5 ----- src/Services/Identity/Identity.API/Program.cs | 5 ----- src/Services/Ordering/Ordering.API/Program.cs | 17 ++++++----------- .../Ordering/Ordering.SignalrHub/Program.cs | 5 ----- src/Services/Payment/Payment.API/Program.cs | 5 ----- .../Services.Common/CommonExtensions.cs | 10 ++++++++++ src/Services/Webhooks/Webhooks.API/Program.cs | 5 ----- src/docker-compose.override.yml | 17 ++++++++++------- 10 files changed, 30 insertions(+), 51 deletions(-) diff --git a/src/ApiGateways/Web.Bff.Shopping/aggregator/Program.cs b/src/ApiGateways/Web.Bff.Shopping/aggregator/Program.cs index 2adccb59f..880d9b921 100644 --- a/src/ApiGateways/Web.Bff.Shopping/aggregator/Program.cs +++ b/src/ApiGateways/Web.Bff.Shopping/aggregator/Program.cs @@ -22,21 +22,16 @@ builder.Services.Configure(builder.Configuration.GetSection("urls")) var app = builder.Build(); -if (!await app.CheckHealthAsync()) -{ - return; -} - app.UseServiceDefaults(); app.UseHttpsRedirection(); -app.UseCors("CorsPolicy"); +app.UseCors(); app.UseAuthentication(); app.UseAuthorization(); app.MapGet("/", () => Results.Redirect("/swagger")); -app.MapControllers(); +app.MapControllers().RequireCors("CorsPolicy"); await app.RunAsync(); diff --git a/src/ApiGateways/Web.Bff.Shopping/aggregator/appsettings.json b/src/ApiGateways/Web.Bff.Shopping/aggregator/appsettings.json index dfa9ce18f..26e436a4e 100644 --- a/src/ApiGateways/Web.Bff.Shopping/aggregator/appsettings.json +++ b/src/ApiGateways/Web.Bff.Shopping/aggregator/appsettings.json @@ -2,7 +2,8 @@ "Logging": { "LogLevel": { "Default": "Information", - "Microsoft.AspNetCore": "Warning" + "Microsoft.AspNetCore": "Warning", + "System.Net.Http": "Warning" } }, "OpenApi": { diff --git a/src/Services/Catalog/Catalog.API/Program.cs b/src/Services/Catalog/Catalog.API/Program.cs index 006a8b29b..d450b022a 100644 --- a/src/Services/Catalog/Catalog.API/Program.cs +++ b/src/Services/Catalog/Catalog.API/Program.cs @@ -16,11 +16,6 @@ builder.Services.AddTransient() var app = builder.Build(); -if (!await app.CheckHealthAsync()) -{ - return; -} - app.UseServiceDefaults(); app.MapGet("/", () => Results.Redirect("/swagger")); diff --git a/src/Services/Identity/Identity.API/Program.cs b/src/Services/Identity/Identity.API/Program.cs index c8a04cd73..38bbbca42 100644 --- a/src/Services/Identity/Identity.API/Program.cs +++ b/src/Services/Identity/Identity.API/Program.cs @@ -40,11 +40,6 @@ builder.Services.AddTransient(); var app = builder.Build(); -if (!await app.CheckHealthAsync()) -{ - return; -} - app.UseServiceDefaults(); app.UseStaticFiles(); diff --git a/src/Services/Ordering/Ordering.API/Program.cs b/src/Services/Ordering/Ordering.API/Program.cs index 70faa5022..6b8dce4c2 100644 --- a/src/Services/Ordering/Ordering.API/Program.cs +++ b/src/Services/Ordering/Ordering.API/Program.cs @@ -33,20 +33,15 @@ services.AddScoped(); services.AddScoped(); // Add integration event handlers. -services.AddSingleton, GracePeriodConfirmedIntegrationEventHandler>(); -services.AddSingleton, OrderPaymentFailedIntegrationEventHandler>(); -services.AddSingleton, OrderPaymentSucceededIntegrationEventHandler>(); -services.AddSingleton, OrderStockConfirmedIntegrationEventHandler>(); -services.AddSingleton, OrderStockRejectedIntegrationEventHandler>(); -services.AddSingleton, UserCheckoutAcceptedIntegrationEventHandler>(); +services.AddTransient, GracePeriodConfirmedIntegrationEventHandler>(); +services.AddTransient, OrderPaymentFailedIntegrationEventHandler>(); +services.AddTransient, OrderPaymentSucceededIntegrationEventHandler>(); +services.AddTransient, OrderStockConfirmedIntegrationEventHandler>(); +services.AddTransient, OrderStockRejectedIntegrationEventHandler>(); +services.AddTransient, UserCheckoutAcceptedIntegrationEventHandler>(); var app = builder.Build(); -if (!await app.CheckHealthAsync()) -{ - return; -} - app.UseServiceDefaults(); app.MapGet("/", () => Results.Redirect("/swagger")); diff --git a/src/Services/Ordering/Ordering.SignalrHub/Program.cs b/src/Services/Ordering/Ordering.SignalrHub/Program.cs index 4583e9025..a030d5eb0 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/Program.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/Program.cs @@ -23,11 +23,6 @@ builder.Services.AddSingleton(); diff --git a/src/Services/Services.Common/CommonExtensions.cs b/src/Services/Services.Common/CommonExtensions.cs index 96c9828cb..104a66e3b 100644 --- a/src/Services/Services.Common/CommonExtensions.cs +++ b/src/Services/Services.Common/CommonExtensions.cs @@ -57,6 +57,16 @@ public static class CommonExtensions if (!string.IsNullOrEmpty(pathBase)) { app.UsePathBase(pathBase); + app.UseRouting(); + + var identitySection = app.Configuration.GetSection("Identity"); + + if (identitySection.Exists()) + { + // We have to add the auth middleware to the pipeline here + app.UseAuthentication(); + app.UseAuthorization(); + } } app.UseDefaultOpenApi(app.Configuration); diff --git a/src/Services/Webhooks/Webhooks.API/Program.cs b/src/Services/Webhooks/Webhooks.API/Program.cs index 8aedaa8a8..ad227b906 100644 --- a/src/Services/Webhooks/Webhooks.API/Program.cs +++ b/src/Services/Webhooks/Webhooks.API/Program.cs @@ -19,11 +19,6 @@ builder.Services.AddTransient() var app = builder.Build(); -if (!await app.CheckHealthAsync()) -{ - return; -} - app.UseServiceDefaults(); app.MapGet("/", () => Results.Redirect("/swagger")); diff --git a/src/docker-compose.override.yml b/src/docker-compose.override.yml index 428228c9c..46c762515 100644 --- a/src/docker-compose.override.yml +++ b/src/docker-compose.override.yml @@ -61,7 +61,9 @@ services: basket-api: environment: - ASPNETCORE_ENVIRONMENT=Development - - ASPNETCORE_URLS=http://0.0.0.0:80 + - Kestrel__Endpoints__HTTP__Url=http://0.0.0.0:80 + - Kestrel__Endpoints__GRPC__Url=http://0.0.0.0:81 + - Kestrel__Endpoints__GRPC__Protocols=Http2 - ConnectionStrings__Redis=${ESHOP_AZURE_REDIS_BASKET_DB:-basketdata} - ConnectionStrings__EventBus=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq} - Identity__Url=http://identity-api @@ -72,8 +74,6 @@ services: - OrchestratorType=${ORCHESTRATOR_TYPE} - UseLoadTest=${USE_LOADTEST:-False} - PATH_BASE=/basket-api - - GRPC_PORT=81 - - PORT=80 ports: - "5103:80" - "9103:81" @@ -81,6 +81,9 @@ services: catalog-api: environment: - ASPNETCORE_ENVIRONMENT=Development + - Kestrel__Endpoints__HTTP__Url=http://0.0.0.0:80 + - Kestrel__Endpoints__GRPC__Url=http://0.0.0.0:81 + - Kestrel__Endpoints__GRPC__Protocols=Http2 - ConnectionStrings__CatalogDb=${ESHOP_AZURE_CATALOG_DB:-Server=sqldata;Database=Microsoft.eShopOnContainers.Services.CatalogDb;User Id=sa;Password=Pass@word;Encrypt=False;TrustServerCertificate=true} - ConnectionStrings__EventBus=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq} - PicBaseUrl=${ESHOP_STORAGE_CATALOG_URL} @@ -92,8 +95,6 @@ services: - AzureStorageEnabled=False - ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY} - OrchestratorType=${ORCHESTRATOR_TYPE} - - GRPC_PORT=81 - - PORT=80 - PATH_BASE=/catalog-api ports: - "5101:80" @@ -102,7 +103,9 @@ services: ordering-api: environment: - ASPNETCORE_ENVIRONMENT=Development - - ASPNETCORE_URLS=http://0.0.0.0:80 + - Kestrel__Endpoints__HTTP__Url=http://0.0.0.0:80 + - Kestrel__Endpoints__GRPC__Url=http://0.0.0.0:81 + - Kestrel__Endpoints__GRPC__Protocols=Http2 - ConnectionStrings__OrderingDb=${ESHOP_AZURE_ORDERING_DB:-Server=sqldata;Database=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word;Encrypt=False;TrustServerCertificate=true} - ConnectionStrings__EventBus=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq} - Identity__Url=http://identity-api @@ -284,7 +287,7 @@ services: - ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_URLS=http://0.0.0.0:80 - PurchaseUrl=http://webshoppingapigw - - Identity__Url=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105 + - IdentityUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105 - SignalrHubUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5202 - IdentityUrlHC=http://identity-api/hc - UseCustomizationData=True