feat ocelot
This commit is contained in:
21
Src/Gateway/Dockerfile
Normal file
21
Src/Gateway/Dockerfile
Normal file
@@ -0,0 +1,21 @@
|
||||
#See https://aka.ms/customizecontainer to learn how to customize your debug container and 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
|
||||
COPY ["Src/Gateway/Gateway.csproj", "Src/Gateway/"]
|
||||
RUN dotnet restore "Src/Gateway/Gateway.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/src/Src/Gateway"
|
||||
RUN dotnet build "Gateway.csproj" -c Release -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
RUN dotnet publish "Gateway.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
||||
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
ENTRYPOINT ["dotnet", "Gateway.dll"]
|
||||
15
Src/Gateway/Gateway.csproj
Normal file
15
Src/Gateway/Gateway.csproj
Normal file
@@ -0,0 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
<DockerfileContext>..\..</DockerfileContext>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Ocelot" Version="23.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
16
Src/Gateway/Program.cs
Normal file
16
Src/Gateway/Program.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using Ocelot.DependencyInjection;
|
||||
using Ocelot.Middleware;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Configuration.AddJsonFile("ocelot.json", true, true);
|
||||
// Add services to the container.
|
||||
|
||||
builder.Services.AddOcelot();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
|
||||
app.UseOcelot().Wait();
|
||||
|
||||
app.Run();
|
||||
14
Src/Gateway/Properties/launchSettings.json
Normal file
14
Src/Gateway/Properties/launchSettings.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"profiles": {
|
||||
"Gateway": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": false,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "http://localhost:5001"
|
||||
}
|
||||
},
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json"
|
||||
}
|
||||
8
Src/Gateway/appsettings.Development.json
Normal file
8
Src/Gateway/appsettings.Development.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
9
Src/Gateway/appsettings.json
Normal file
9
Src/Gateway/appsettings.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
20
Src/Gateway/ocelot.json
Normal file
20
Src/Gateway/ocelot.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"Routes": [
|
||||
{
|
||||
"ServiceName": "basic",
|
||||
"UpstreamPathTemplate": "/api/basic/{url}",
|
||||
"UpstreamHttpMethod": [ "Get", "Post" ],
|
||||
"DownstreamPathTemplate": "/api/{url}",
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "localhost",
|
||||
"Port": 5002
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"GlobalConfiguration": {
|
||||
//"BaseUrl": "http://localhost:5000"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user