This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit to implementing YARP API gateway #1888
Draft
erjain
wants to merge
2
commits into
dotnet-architecture:dev
Choose a base branch
from
erjain:feature/yarp
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. | ||
|
||
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base | ||
WORKDIR /app | ||
EXPOSE 80 | ||
|
||
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build | ||
WORKDIR /src | ||
|
||
# It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles | ||
# to take advantage of Docker's build cache, to speed up local container builds | ||
COPY "eShopOnContainers-ServicesAndWebApps.sln" "eShopOnContainers-ServicesAndWebApps.sln" | ||
|
||
COPY "ApiGateways/Yarp/WebShoppingAPIGateway/WebShoppingAPIGateway.csproj" "ApiGateways/Yarp/WebShoppingAPIGateway/WebShoppingAPIGateway.csproj" | ||
COPY "ApiGateways/Mobile.Bff.Shopping/aggregator/Mobile.Shopping.HttpAggregator.csproj" "ApiGateways/Mobile.Bff.Shopping/aggregator/Mobile.Shopping.HttpAggregator.csproj" | ||
COPY "ApiGateways/Web.Bff.Shopping/aggregator/Web.Shopping.HttpAggregator.csproj" "ApiGateways/Web.Bff.Shopping/aggregator/Web.Shopping.HttpAggregator.csproj" | ||
COPY "BuildingBlocks/Devspaces.Support/Devspaces.Support.csproj" "BuildingBlocks/Devspaces.Support/Devspaces.Support.csproj" | ||
COPY "BuildingBlocks/EventBus/EventBus/EventBus.csproj" "BuildingBlocks/EventBus/EventBus/EventBus.csproj" | ||
COPY "BuildingBlocks/EventBus/EventBus.Tests/EventBus.Tests.csproj" "BuildingBlocks/EventBus/EventBus.Tests/EventBus.Tests.csproj" | ||
COPY "BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.csproj" "BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.csproj" | ||
COPY "BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.csproj" "BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.csproj" | ||
COPY "BuildingBlocks/EventBus/IntegrationEventLogEF/IntegrationEventLogEF.csproj" "BuildingBlocks/EventBus/IntegrationEventLogEF/IntegrationEventLogEF.csproj" | ||
COPY "BuildingBlocks/WebHostCustomization/WebHost.Customization/WebHost.Customization.csproj" "BuildingBlocks/WebHostCustomization/WebHost.Customization/WebHost.Customization.csproj" | ||
COPY "Services/Basket/Basket.API/Basket.API.csproj" "Services/Basket/Basket.API/Basket.API.csproj" | ||
COPY "Services/Basket/Basket.FunctionalTests/Basket.FunctionalTests.csproj" "Services/Basket/Basket.FunctionalTests/Basket.FunctionalTests.csproj" | ||
COPY "Services/Basket/Basket.UnitTests/Basket.UnitTests.csproj" "Services/Basket/Basket.UnitTests/Basket.UnitTests.csproj" | ||
COPY "Services/Catalog/Catalog.API/Catalog.API.csproj" "Services/Catalog/Catalog.API/Catalog.API.csproj" | ||
COPY "Services/Catalog/Catalog.FunctionalTests/Catalog.FunctionalTests.csproj" "Services/Catalog/Catalog.FunctionalTests/Catalog.FunctionalTests.csproj" | ||
COPY "Services/Catalog/Catalog.UnitTests/Catalog.UnitTests.csproj" "Services/Catalog/Catalog.UnitTests/Catalog.UnitTests.csproj" | ||
COPY "Services/Identity/Identity.API/Identity.API.csproj" "Services/Identity/Identity.API/Identity.API.csproj" | ||
COPY "Services/Ordering/Ordering.API/Ordering.API.csproj" "Services/Ordering/Ordering.API/Ordering.API.csproj" | ||
COPY "Services/Ordering/Ordering.BackgroundTasks/Ordering.BackgroundTasks.csproj" "Services/Ordering/Ordering.BackgroundTasks/Ordering.BackgroundTasks.csproj" | ||
COPY "Services/Ordering/Ordering.Domain/Ordering.Domain.csproj" "Services/Ordering/Ordering.Domain/Ordering.Domain.csproj" | ||
COPY "Services/Ordering/Ordering.FunctionalTests/Ordering.FunctionalTests.csproj" "Services/Ordering/Ordering.FunctionalTests/Ordering.FunctionalTests.csproj" | ||
COPY "Services/Ordering/Ordering.Infrastructure/Ordering.Infrastructure.csproj" "Services/Ordering/Ordering.Infrastructure/Ordering.Infrastructure.csproj" | ||
COPY "Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj" "Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj" | ||
COPY "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" | ||
COPY "Services/Payment/Payment.API/Payment.API.csproj" "Services/Payment/Payment.API/Payment.API.csproj" | ||
COPY "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" | ||
COPY "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" | ||
COPY "Web/WebhookClient/WebhookClient.csproj" "Web/WebhookClient/WebhookClient.csproj" | ||
COPY "Web/WebMVC/WebMVC.csproj" "Web/WebMVC/WebMVC.csproj" | ||
COPY "Web/WebSPA/WebSPA.csproj" "Web/WebSPA/WebSPA.csproj" | ||
COPY "Web/WebStatus/WebStatus.csproj" "Web/WebStatus/WebStatus.csproj" | ||
|
||
COPY "docker-compose.dcproj" "docker-compose.dcproj" | ||
|
||
COPY "NuGet.config" "NuGet.config" | ||
|
||
RUN dotnet restore "eShopOnContainers-ServicesAndWebApps.sln" | ||
|
||
COPY . . | ||
WORKDIR /src/ApiGateways/Yarp/WebShoppingAPIGateway | ||
RUN dotnet publish --no-restore -c Release -o /app | ||
|
||
FROM build AS publish | ||
|
||
FROM base AS final | ||
WORKDIR /app | ||
COPY --from=publish /app . | ||
ENTRYPOINT ["dotnet", "WebShoppingAPIGateway.dll"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
var builder = WebApplication.CreateBuilder(args); | ||
builder.Services.AddReverseProxy().LoadFromConfig(builder.Configuration.GetSection("ReverseProxy")); | ||
builder.Services.AddCors(options => | ||
{ | ||
options.AddPolicy("customPolicy", builder => | ||
{ | ||
builder.AllowAnyOrigin() | ||
.AllowAnyMethod() | ||
.AllowAnyHeader(); | ||
}); | ||
}); | ||
var app = builder.Build(); | ||
app.UseCors(); | ||
app.MapGet("/", () => "Hello World!"); | ||
|
||
app.MapReverseProxy(); | ||
|
||
app.Run(); |
35 changes: 35 additions & 0 deletions
35
src/ApiGateways/Yarp/WebShoppingAPIGateway/Properties/launchSettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"iisSettings": { | ||
"windowsAuthentication": false, | ||
"anonymousAuthentication": true, | ||
"iisExpress": { | ||
"applicationUrl": "http://localhost:26551", | ||
"sslPort": 0 | ||
} | ||
}, | ||
"profiles": { | ||
"WebShoppingAPIGateway": { | ||
"commandName": "Project", | ||
"launchBrowser": true, | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
}, | ||
"applicationUrl": "https://localhost:7118;http://localhost:5118", | ||
"dotnetRunMessages": true | ||
}, | ||
"IIS Express": { | ||
"commandName": "IISExpress", | ||
"launchBrowser": true, | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"Docker": { | ||
"commandName": "Docker", | ||
"launchBrowser": true, | ||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", | ||
"publishAllPorts": true, | ||
"useSSL": false | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/ApiGateways/Yarp/WebShoppingAPIGateway/WebShoppingAPIGateway.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<UserSecretsId>7c1733f8-e653-474b-9422-32c68ba1d44e</UserSecretsId> | ||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> | ||
<DockerfileContext>..\..\..</DockerfileContext> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.14.0" /> | ||
<PackageReference Include="Yarp.ReverseProxy" Version="1.0.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |
8 changes: 8 additions & 0 deletions
8
src/ApiGateways/Yarp/WebShoppingAPIGateway/appsettings.Development.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
} | ||
} |
134 changes: 134 additions & 0 deletions
134
src/ApiGateways/Yarp/WebShoppingAPIGateway/appsettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
{ | ||
"Urls": "http://{ServiceHost}:{ServicePort}", | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
}, | ||
"AllowedHosts": "*", | ||
"ReverseProxy": { | ||
"Routes": { | ||
"minimumroute": { | ||
"ClusterId": "minimumcluster", | ||
"Match": { | ||
"Path": "{**catch-all}" | ||
} | ||
}, | ||
"catalog": { | ||
"ClusterId": "catalog", | ||
"CorsPolicy": "customPolicy", | ||
"Match": { | ||
"Methods": [ "GET", "POST" ], | ||
"Hosts": "host.docker.internal", | ||
"Path": "/c/{**catch-all}" | ||
}, | ||
"Transforms": [ | ||
{ | ||
"PathRemovePrefix": "/c" | ||
} | ||
] | ||
}, | ||
"ordering": { | ||
"ClusterId": "ordering", | ||
"CorsPolicy": "customPolicy", | ||
"Match": { | ||
"Methods": [ "GET", "POST" ], | ||
"Hosts": "host.docker.internal", | ||
"Path": "/o/{**catch-all}" | ||
}, | ||
"Transforms": [ | ||
{ | ||
"PathRemovePrefix": "/o" | ||
} | ||
] | ||
}, | ||
"signalr-hub": { | ||
"ClusterId": "signalr-hub", | ||
"CorsPolicy": "customPolicy", | ||
"Match": { | ||
"Methods": [ "GET", "POST" ], | ||
"Hosts": "host.docker.internal", | ||
"Path": "/hub/{**catch-all}" | ||
}, | ||
"Transforms": [ | ||
{ | ||
"PathRemovePrefix": "/hub" | ||
} | ||
] | ||
}, | ||
"basket": { | ||
"ClusterId": "basket", | ||
"CorsPolicy": "customPolicy", | ||
"Match": { | ||
"Methods": [ "GET", "POST" ], | ||
"Hosts": "host.docker.internal", | ||
"Path": "/b/{**catch-all}" | ||
}, | ||
"Transforms": [ | ||
{ | ||
"PathRemovePrefix": "/b" | ||
} | ||
] | ||
}, | ||
"shoppingagg": { | ||
"ClusterId": "shoppingagg", | ||
"CorsPolicy": "customPolicy", | ||
"Match": { | ||
"Methods": [ "GET", "POST" ], | ||
"Hosts": "host.docker.internal", | ||
"Path": "/{**catch-all}" | ||
}, | ||
"Transforms": [ | ||
{ | ||
"PathPattern": "/{**catch-all}" | ||
} | ||
] | ||
} | ||
}, | ||
"Clusters": { | ||
"minimumcluster": { | ||
"Destinations": { | ||
"httpbin.org": { | ||
"Address": "https://www.microsoft.com/" | ||
} | ||
} | ||
}, | ||
"catalog": { | ||
"Destinations": { | ||
"catalog_destination": { | ||
"Address": "http://catalog-api/" | ||
} | ||
} | ||
}, | ||
"ordering": { | ||
"Destinations": { | ||
"catalog_destination": { | ||
"Address": "http://ordering-api/" | ||
} | ||
} | ||
}, | ||
"signalr-hub": { | ||
"Destinations": { | ||
"catalog_destination": { | ||
"Address": "http://ordering-signalrhub/" | ||
} | ||
} | ||
}, | ||
"basket": { | ||
"Destinations": { | ||
"catalog_destination": { | ||
"Address": "http://basket-api/" | ||
} | ||
} | ||
}, | ||
"shoppingagg": { | ||
"Destinations": { | ||
"catalog_destination": { | ||
"Address": "http://webshoppingagg/" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"/api": { | ||
"target": "http://host.docker.internal:5202", | ||
"secure": false, | ||
"changeOrigin": true, | ||
"logLevel": "debug" | ||
} | ||
} |
Empty file.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe test project is not needed for the Dockerfile