Docker compose works

This commit is contained in:
David Fowler 2023-05-06 16:14:56 -07:00 committed by Reuben Bond
parent e1ec790ddf
commit d0c710ebdc
10 changed files with 30 additions and 51 deletions

View File

@ -22,21 +22,16 @@ builder.Services.Configure<UrlsConfig>(builder.Configuration.GetSection("urls"))
var app = builder.Build(); var app = builder.Build();
if (!await app.CheckHealthAsync())
{
return;
}
app.UseServiceDefaults(); app.UseServiceDefaults();
app.UseHttpsRedirection(); app.UseHttpsRedirection();
app.UseCors("CorsPolicy"); app.UseCors();
app.UseAuthentication(); app.UseAuthentication();
app.UseAuthorization(); app.UseAuthorization();
app.MapGet("/", () => Results.Redirect("/swagger")); app.MapGet("/", () => Results.Redirect("/swagger"));
app.MapControllers(); app.MapControllers().RequireCors("CorsPolicy");
await app.RunAsync(); await app.RunAsync();

View File

@ -2,7 +2,8 @@
"Logging": { "Logging": {
"LogLevel": { "LogLevel": {
"Default": "Information", "Default": "Information",
"Microsoft.AspNetCore": "Warning" "Microsoft.AspNetCore": "Warning",
"System.Net.Http": "Warning"
} }
}, },
"OpenApi": { "OpenApi": {

View File

@ -16,11 +16,6 @@ builder.Services.AddTransient<OrderStatusChangedToPaidIntegrationEventHandler>()
var app = builder.Build(); var app = builder.Build();
if (!await app.CheckHealthAsync())
{
return;
}
app.UseServiceDefaults(); app.UseServiceDefaults();
app.MapGet("/", () => Results.Redirect("/swagger")); app.MapGet("/", () => Results.Redirect("/swagger"));

View File

@ -40,11 +40,6 @@ builder.Services.AddTransient<IRedirectService, RedirectService>();
var app = builder.Build(); var app = builder.Build();
if (!await app.CheckHealthAsync())
{
return;
}
app.UseServiceDefaults(); app.UseServiceDefaults();
app.UseStaticFiles(); app.UseStaticFiles();

View File

@ -33,20 +33,15 @@ services.AddScoped<IOrderRepository, OrderRepository>();
services.AddScoped<IRequestManager, RequestManager>(); services.AddScoped<IRequestManager, RequestManager>();
// Add integration event handlers. // Add integration event handlers.
services.AddSingleton<IIntegrationEventHandler<GracePeriodConfirmedIntegrationEvent>, GracePeriodConfirmedIntegrationEventHandler>(); services.AddTransient<IIntegrationEventHandler<GracePeriodConfirmedIntegrationEvent>, GracePeriodConfirmedIntegrationEventHandler>();
services.AddSingleton<IIntegrationEventHandler<OrderPaymentFailedIntegrationEvent>, OrderPaymentFailedIntegrationEventHandler>(); services.AddTransient<IIntegrationEventHandler<OrderPaymentFailedIntegrationEvent>, OrderPaymentFailedIntegrationEventHandler>();
services.AddSingleton<IIntegrationEventHandler<OrderPaymentSucceededIntegrationEvent>, OrderPaymentSucceededIntegrationEventHandler>(); services.AddTransient<IIntegrationEventHandler<OrderPaymentSucceededIntegrationEvent>, OrderPaymentSucceededIntegrationEventHandler>();
services.AddSingleton<IIntegrationEventHandler<OrderStockConfirmedIntegrationEvent>, OrderStockConfirmedIntegrationEventHandler>(); services.AddTransient<IIntegrationEventHandler<OrderStockConfirmedIntegrationEvent>, OrderStockConfirmedIntegrationEventHandler>();
services.AddSingleton<IIntegrationEventHandler<OrderStockRejectedIntegrationEvent>, OrderStockRejectedIntegrationEventHandler>(); services.AddTransient<IIntegrationEventHandler<OrderStockRejectedIntegrationEvent>, OrderStockRejectedIntegrationEventHandler>();
services.AddSingleton<IIntegrationEventHandler<UserCheckoutAcceptedIntegrationEvent>, UserCheckoutAcceptedIntegrationEventHandler>(); services.AddTransient<IIntegrationEventHandler<UserCheckoutAcceptedIntegrationEvent>, UserCheckoutAcceptedIntegrationEventHandler>();
var app = builder.Build(); var app = builder.Build();
if (!await app.CheckHealthAsync())
{
return;
}
app.UseServiceDefaults(); app.UseServiceDefaults();
app.MapGet("/", () => Results.Redirect("/swagger")); app.MapGet("/", () => Results.Redirect("/swagger"));

View File

@ -23,11 +23,6 @@ builder.Services.AddSingleton<IIntegrationEventHandler<OrderStatusChangedToSubmi
var app = builder.Build(); var app = builder.Build();
if (!await app.CheckHealthAsync())
{
return;
}
app.UseServiceDefaults(); app.UseServiceDefaults();
app.UseCors("CorsPolicy"); app.UseCors("CorsPolicy");

View File

@ -8,11 +8,6 @@ builder.Services.AddTransient<OrderStatusChangedToStockConfirmedIntegrationEvent
var app = builder.Build(); var app = builder.Build();
if (!await app.CheckHealthAsync())
{
return;
}
app.UseServiceDefaults(); app.UseServiceDefaults();
var eventBus = app.Services.GetRequiredService<IEventBus>(); var eventBus = app.Services.GetRequiredService<IEventBus>();

View File

@ -57,6 +57,16 @@ public static class CommonExtensions
if (!string.IsNullOrEmpty(pathBase)) if (!string.IsNullOrEmpty(pathBase))
{ {
app.UsePathBase(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); app.UseDefaultOpenApi(app.Configuration);

View File

@ -19,11 +19,6 @@ builder.Services.AddTransient<OrderStatusChangedToPaidIntegrationEventHandler>()
var app = builder.Build(); var app = builder.Build();
if (!await app.CheckHealthAsync())
{
return;
}
app.UseServiceDefaults(); app.UseServiceDefaults();
app.MapGet("/", () => Results.Redirect("/swagger")); app.MapGet("/", () => Results.Redirect("/swagger"));

View File

@ -61,7 +61,9 @@ services:
basket-api: basket-api:
environment: environment:
- ASPNETCORE_ENVIRONMENT=Development - 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__Redis=${ESHOP_AZURE_REDIS_BASKET_DB:-basketdata}
- ConnectionStrings__EventBus=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq} - ConnectionStrings__EventBus=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq}
- Identity__Url=http://identity-api - Identity__Url=http://identity-api
@ -72,8 +74,6 @@ services:
- OrchestratorType=${ORCHESTRATOR_TYPE} - OrchestratorType=${ORCHESTRATOR_TYPE}
- UseLoadTest=${USE_LOADTEST:-False} - UseLoadTest=${USE_LOADTEST:-False}
- PATH_BASE=/basket-api - PATH_BASE=/basket-api
- GRPC_PORT=81
- PORT=80
ports: ports:
- "5103:80" - "5103:80"
- "9103:81" - "9103:81"
@ -81,6 +81,9 @@ services:
catalog-api: catalog-api:
environment: environment:
- ASPNETCORE_ENVIRONMENT=Development - 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__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} - ConnectionStrings__EventBus=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq}
- PicBaseUrl=${ESHOP_STORAGE_CATALOG_URL} - PicBaseUrl=${ESHOP_STORAGE_CATALOG_URL}
@ -92,8 +95,6 @@ services:
- AzureStorageEnabled=False - AzureStorageEnabled=False
- ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY} - ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY}
- OrchestratorType=${ORCHESTRATOR_TYPE} - OrchestratorType=${ORCHESTRATOR_TYPE}
- GRPC_PORT=81
- PORT=80
- PATH_BASE=/catalog-api - PATH_BASE=/catalog-api
ports: ports:
- "5101:80" - "5101:80"
@ -102,7 +103,9 @@ services:
ordering-api: ordering-api:
environment: environment:
- ASPNETCORE_ENVIRONMENT=Development - 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__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} - ConnectionStrings__EventBus=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq}
- Identity__Url=http://identity-api - Identity__Url=http://identity-api
@ -284,7 +287,7 @@ services:
- ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://0.0.0.0:80 - ASPNETCORE_URLS=http://0.0.0.0:80
- PurchaseUrl=http://webshoppingapigw - 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 - SignalrHubUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5202
- IdentityUrlHC=http://identity-api/hc - IdentityUrlHC=http://identity-api/hc
- UseCustomizationData=True - UseCustomizationData=True