diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/appsettings.Tye.json b/apps/public-web/src/EShopOnAbp.PublicWeb/appsettings.Tye.json new file mode 100644 index 00000000..ea194f5a --- /dev/null +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/appsettings.Tye.json @@ -0,0 +1,26 @@ +{ + "RemoteServices": { + "Default": { + "BaseUrl": "https://localhost:44373" + } + }, + "ReverseProxy": { + "Routes": { + "route1": { + "ClusterId": "cluster1", + "Match": { + "Path": "/api/{**anypath}" + } + } + }, + "Clusters": { + "cluster1": { + "Destinations": { + "destination1": { + "Address": "https://localhost:44373" + } + } + } + } + } +} diff --git a/gateways/web-public/src/EShopOnAbp.WebPublicGateway/yarp.Tye.json b/gateways/web-public/src/EShopOnAbp.WebPublicGateway/yarp.Tye.json new file mode 100644 index 00000000..d4971bee --- /dev/null +++ b/gateways/web-public/src/EShopOnAbp.WebPublicGateway/yarp.Tye.json @@ -0,0 +1,186 @@ +{ + "ReverseProxy": { + "Routes": { + "AbpApi": { + "ClusterId": "Administration", + "Match": { + "Path": "/api/abp/{**catch-all}" + } + }, + "Identity Service": { + "ClusterId": "Identity", + "Match": { + "Path": "/api/identity/{**everything}" + } + }, + "Identity Service Swagger": { + "ClusterId": "Identity", + "Match": { + "Path": "/swagger-json/Identity/swagger/v1/swagger.json" + }, + "Transforms": [ + { "PathRemovePrefix": "/swagger-json/Identity" } + ] + }, + "FeatureManagement": { + "ClusterId": "Administration", + "Match": { + "Path": "/api/feature-management/{**everything}" + } + }, + "PermissionManagement": { + "ClusterId": "Administration", + "Match": { + "Path": "/api/permission-management/{**everything}" + } + }, + "SettingManagement": { + "ClusterId": "Administration", + "Match": { + "Path": "/api/setting-management/{**everything}" + } + }, + "Administration Service Swagger": { + "ClusterId": "Administration", + "Match": { + "Path": "/swagger-json/Administration/swagger/v1/swagger.json" + }, + "Transforms": [ + { "PathRemovePrefix": "/swagger-json/Administration" } + ] + }, + "Catalog Service": { + "ClusterId": "catalogCluster", + "Match": { + "Path": "/api/catalog/{**everything}" + } + }, + "Catalog Service Swagger": { + "ClusterId": "catalogCluster", + "Match": { + "Path": "/swagger-json/Catalog/swagger/v1/swagger.json" + }, + "Transforms": [ + { "PathRemovePrefix": "/swagger-json/Catalog" } + ] + }, + "Basket Service": { + "ClusterId": "Basket", + "Match": { + "Path": "/api/basket/{**everything}" + } + }, + "Basket Service Swagger": { + "ClusterId": "Basket", + "Match": { + "Path": "/swagger-json/Basket/swagger/v1/swagger.json" + }, + "Transforms": [ + { "PathRemovePrefix": "/swagger-json/Basket" } + ] + }, + "Ordering Service": { + "ClusterId": "Ordering", + "Match": { + "Path": "/api/ordering/{**everything}" + } + }, + "Ordering Service Swagger": { + "ClusterId": "Ordering", + "Match": { + "Path": "/swagger-json/Ordering/swagger/v1/swagger.json" + }, + "Transforms": [ + { "PathRemovePrefix": "/swagger-json/Ordering" } + ] + }, + "Cmskit Public Service": { + "ClusterId": "CmsKit", + "Match": { + "Path": "/api/cms-kit-public/{**everything}" + } + }, + "Cmskit Admin Service": { + "ClusterId": "CmsKit", + "Match": { + "Path": "/api/cms-kit-admin/{**everything}" + } + }, + "Cmskit Service Swagger": { + "ClusterId": "CmsKit", + "Match": { + "Path": "/swagger-json/Cmskit/swagger/v1/swagger.json" + }, + "Transforms": [ + { "PathRemovePrefix": "/swagger-json/Cmskit" } + ] + }, + "Payment Service": { + "ClusterId": "Payment", + "Match": { + "Path": "/api/payment/{**everything}" + } + }, + "Payment Service Swagger": { + "ClusterId": "Payment", + "Match": { + "Path": "/swagger-json/Payment/swagger/v1/swagger.json" + }, + "Transforms": [ + { "PathRemovePrefix": "/swagger-json/Payment" } + ] + } + }, + "Clusters": { + "Identity": { + "Destinations": { + "destination1": { + "Address": "https://localhost:44351" + } + } + }, + "Administration": { + "Destinations": { + "destination1": { + "Address": "https://localhost:44353" + } + } + }, + "catalogCluster": { + "Destinations": { + "destination1": { + "Address": "https://localhost:44354" + } + } + }, + "Basket": { + "Destinations": { + "destination1": { + "Address": "https://localhost:44355" + } + } + }, + "Ordering": { + "Destinations": { + "destination1": { + "Address": "https://localhost:44356" + } + } + }, + "CmsKit": { + "Destinations": { + "destination1": { + "Address": "https://localhost:44358" + } + } + }, + "Payment": { + "Destinations": { + "destination1": { + "Address": "https://localhost:44357" + } + } + } + } + } +} \ No newline at end of file diff --git a/gateways/web/src/EShopOnAbp.WebGateway/Program.cs b/gateways/web/src/EShopOnAbp.WebGateway/Program.cs index 9383d74f..741f6f17 100644 --- a/gateways/web/src/EShopOnAbp.WebGateway/Program.cs +++ b/gateways/web/src/EShopOnAbp.WebGateway/Program.cs @@ -20,6 +20,7 @@ public static async Task Main(string[] args) { Log.Information($"Starting {assemblyName}."); var builder = WebApplication.CreateBuilder(args); + builder.Host .AddAppSettingsSecretsJson() .AddYarpJson() diff --git a/services/basket/src/EShopOnAbp.BasketService/BasketServiceModule.cs b/services/basket/src/EShopOnAbp.BasketService/BasketServiceModule.cs index 0f8775cc..699b9558 100644 --- a/services/basket/src/EShopOnAbp.BasketService/BasketServiceModule.cs +++ b/services/basket/src/EShopOnAbp.BasketService/BasketServiceModule.cs @@ -2,8 +2,10 @@ using EShopOnAbp.CatalogService.Grpc; using EShopOnAbp.Shared.Hosting.AspNetCore; using EShopOnAbp.Shared.Hosting.Microservices; +using Grpc.Net.ClientFactory; using Microsoft.AspNetCore.Cors; using Microsoft.Extensions.Caching.Distributed; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Polly; using Volo.Abp; @@ -56,7 +58,7 @@ public override void ConfigureServices(ServiceConfigurationContext context) ConfigureAutoMapper(); ConfigureAspNetCoreRouting(); - ConfigureGrpc(context); + ConfigureGrpc(context,configuration); ConfigureDistributedCache(); ConfigureVirtualFileSystem(); ConfigureAuthentication(context, configuration); @@ -152,12 +154,12 @@ private void ConfigureAutoApiControllers() }); } - private void ConfigureGrpc(ServiceConfigurationContext context) + private void ConfigureGrpc(ServiceConfigurationContext context, IConfiguration configuration) { - // context.Services.AddHttpForwarderWithServiceDiscovery(); + context.Services.AddGrpcClient((services, options) => { - options.Address = new Uri("http://_grpc.catalogService"); + options.Address = new Uri(configuration.GetRequiredSection("GrpcService:Address").Value); }); } diff --git a/services/basket/src/EShopOnAbp.BasketService/appsettings.Tye.json b/services/basket/src/EShopOnAbp.BasketService/appsettings.Tye.json new file mode 100644 index 00000000..c1c41d6f --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/appsettings.Tye.json @@ -0,0 +1,12 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*", + "GrpcService": { + "Address": "https://localhost:44354" + } +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/appsettings.json b/services/basket/src/EShopOnAbp.BasketService/appsettings.json index 56ac0140..f4e33796 100644 --- a/services/basket/src/EShopOnAbp.BasketService/appsettings.json +++ b/services/basket/src/EShopOnAbp.BasketService/appsettings.json @@ -39,5 +39,8 @@ }, "ElasticSearch": { "Url": "http://localhost:9200" + }, + "GrpcService": { + "Address": "http://grpc.catalogService" } } \ No newline at end of file diff --git a/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/Program.cs b/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/Program.cs index f010c2dc..df334c62 100644 --- a/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/Program.cs +++ b/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/Program.cs @@ -21,26 +21,8 @@ public static async Task Main(string[] args) try { Log.Information($"Starting {assemblyName}."); - var builder = WebApplication.CreateBuilder(args); - builder.Host - .UseAutofac() - .UseSerilog(); - - builder.AddServiceDefaults(); - builder.WebHost.ConfigureKestrel(options => - { - options.ListenAnyIP(5054, listenOptions => - { - listenOptions.Protocols = HttpProtocols.Http1AndHttp2; - }); - options.ListenAnyIP(8181, listenOptions => - { - listenOptions.Protocols = HttpProtocols.Http2; - }); - }); - - await builder.AddApplicationAsync(); - var app = builder.Build(); + var app = await ApplicationBuilderHelper + .BuildApplicationAsync(args); await app.InitializeApplicationAsync(); await app.RunAsync(); diff --git a/shared/EShopOnAbp.Shared.Hosting.Gateways/GatewayHostBuilderExtensions.cs b/shared/EShopOnAbp.Shared.Hosting.Gateways/GatewayHostBuilderExtensions.cs index c22d86b7..4e598b06 100644 --- a/shared/EShopOnAbp.Shared.Hosting.Gateways/GatewayHostBuilderExtensions.cs +++ b/shared/EShopOnAbp.Shared.Hosting.Gateways/GatewayHostBuilderExtensions.cs @@ -12,10 +12,12 @@ public static IHostBuilder AddYarpJson( bool reloadOnChange = true, string path = AppYarpJsonPath) { - return hostBuilder.ConfigureAppConfiguration((_, builder) => + return hostBuilder.ConfigureAppConfiguration((context, builder) => { + string environmentName = context.HostingEnvironment.EnvironmentName; + string yarpJsonPath = environmentName == "Tye" ? "yarp.Tye.json" : AppYarpJsonPath; builder.AddJsonFile( - path: AppYarpJsonPath, + path: yarpJsonPath, optional: optional, reloadOnChange: reloadOnChange ) diff --git a/tye.yaml b/tye.yaml index ff389ce8..36b9846e 100644 --- a/tye.yaml +++ b/tye.yaml @@ -35,6 +35,8 @@ services: env: - Kestrel__Certificates__Default__Path=../../../../etc/dev-cert/localhost.pfx - Kestrel__Certificates__Default__Password=8b6039b6-c67a-448b-977b-0ce6d3fcfd49 + - ASPNETCORE_ENVIRONMENT=Tye + - DOTNET_ENVIRONMENT=Tye - name: ordering-service project: services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/EShopOnAbp.OrderingService.HttpApi.Host.csproj @@ -84,6 +86,8 @@ services: env: - Kestrel__Certificates__Default__Path=../../../../etc/dev-cert/localhost.pfx - Kestrel__Certificates__Default__Password=8b6039b6-c67a-448b-977b-0ce6d3fcfd49 + - ASPNETCORE_ENVIRONMENT=Tye + - DOTNET_ENVIRONMENT=Tye - name: public-web project: apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbp.PublicWeb.csproj @@ -93,6 +97,8 @@ services: env: - Kestrel__Certificates__Default__Path=../../../../etc/dev-cert/localhost.pfx - Kestrel__Certificates__Default__Password=8b6039b6-c67a-448b-977b-0ce6d3fcfd49 + - ASPNETCORE_ENVIRONMENT=Tye + - DOTNET_ENVIRONMENT=Tye - name: keycloak-seeder project: shared/EShopOnAbp.Keycloak.DbMigrator/EShopOnAbp.Keycloak.DbMigrator.csproj \ No newline at end of file