Skip to content

Commit b8bef96

Browse files
Merge pull request #10 from https-richardy/feature/gateway-proxy
gateway proxy
2 parents 50f711a + 6082cb3 commit b8bef96

11 files changed

Lines changed: 758 additions & 0 deletions

Applications/.gitkeep

Whitespace-only changes.

Applications/Proxy/.dockerignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
**/.vs
2+
**/.git
3+
4+
**/bin
5+
**/obj
6+
**/.vscode
7+
**/TestResults
8+
9+
**/appsettings.Development.json
10+
11+
.env
12+
.env.*
13+
.env.example
14+
15+
*.user
16+
*.suo
17+
*.userosscache
18+
*.sln.docstates
19+
.gitattributes
20+
21+
Dockerfile
22+
README.md
23+
LICENSE

Applications/Proxy/.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Routes__0__DownstreamScheme=http
2+
Routes__0__DownstreamHostAndPorts__0__Host=localhost
3+
Routes__0__DownstreamHostAndPorts__0__Port=5286

Applications/Proxy/Dockerfile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# use ASP.NET Core 9.0 runtime image (alpine) as base
2+
FROM mcr.microsoft.com/dotnet/aspnet:9.0-alpine AS base
3+
WORKDIR /artifacts
4+
EXPOSE 8080
5+
6+
# use SDK image (Alpine) for build
7+
FROM mcr.microsoft.com/dotnet/sdk:9.0-alpine AS build
8+
WORKDIR /workdir
9+
10+
ARG BUILD_CONFIGURATION=Release
11+
ARG SOLUTION=HttpsRichardy.Federation.Proxy
12+
13+
# copy only csproj and sln to restore as early as possible
14+
COPY ["Source/${SOLUTION}.csproj", "Source/"]
15+
COPY ["${SOLUTION}.sln", "./"]
16+
17+
# restore dependencies
18+
RUN dotnet restore "Source/${SOLUTION}.csproj"
19+
20+
# copy the rest of the source code
21+
COPY Source/ ./Source/
22+
23+
WORKDIR "/workdir/Source"
24+
25+
# build in Release mode
26+
RUN dotnet build "${SOLUTION}.csproj" -c $BUILD_CONFIGURATION -o /artifacts/build
27+
28+
# publish the project for production
29+
RUN dotnet publish "${SOLUTION}.csproj" -c $BUILD_CONFIGURATION -o /artifacts/publish /p:UseAppHost=false
30+
31+
# final image to run the app
32+
FROM base AS final
33+
WORKDIR /artifacts
34+
35+
ENV ASPNETCORE_URLS=http://+:8080
36+
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=true
37+
ENV DOTNET_RUNNING_IN_CONTAINER=true
38+
39+
# copy published files from the build stage
40+
COPY --from=build /artifacts/publish .
41+
42+
ENTRYPOINT ["dotnet", "HttpsRichardy.Federation.Proxy.dll"]
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31903.59
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Source", "Source", "{B8EFCA5F-814F-285C-A8CB-F00F14650265}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HttpsRichardy.Federation.Proxy", "Source\HttpsRichardy.Federation.Proxy.csproj", "{5D5AAD1B-A3F6-46D9-B7A3-A4627DED1E64}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Debug|x64 = Debug|x64
14+
Debug|x86 = Debug|x86
15+
Release|Any CPU = Release|Any CPU
16+
Release|x64 = Release|x64
17+
Release|x86 = Release|x86
18+
EndGlobalSection
19+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
20+
{5D5AAD1B-A3F6-46D9-B7A3-A4627DED1E64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{5D5AAD1B-A3F6-46D9-B7A3-A4627DED1E64}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{5D5AAD1B-A3F6-46D9-B7A3-A4627DED1E64}.Debug|x64.ActiveCfg = Debug|Any CPU
23+
{5D5AAD1B-A3F6-46D9-B7A3-A4627DED1E64}.Debug|x64.Build.0 = Debug|Any CPU
24+
{5D5AAD1B-A3F6-46D9-B7A3-A4627DED1E64}.Debug|x86.ActiveCfg = Debug|Any CPU
25+
{5D5AAD1B-A3F6-46D9-B7A3-A4627DED1E64}.Debug|x86.Build.0 = Debug|Any CPU
26+
{5D5AAD1B-A3F6-46D9-B7A3-A4627DED1E64}.Release|Any CPU.ActiveCfg = Release|Any CPU
27+
{5D5AAD1B-A3F6-46D9-B7A3-A4627DED1E64}.Release|Any CPU.Build.0 = Release|Any CPU
28+
{5D5AAD1B-A3F6-46D9-B7A3-A4627DED1E64}.Release|x64.ActiveCfg = Release|Any CPU
29+
{5D5AAD1B-A3F6-46D9-B7A3-A4627DED1E64}.Release|x64.Build.0 = Release|Any CPU
30+
{5D5AAD1B-A3F6-46D9-B7A3-A4627DED1E64}.Release|x86.ActiveCfg = Release|Any CPU
31+
{5D5AAD1B-A3F6-46D9-B7A3-A4627DED1E64}.Release|x86.Build.0 = Release|Any CPU
32+
EndGlobalSection
33+
GlobalSection(SolutionProperties) = preSolution
34+
HideSolutionNode = FALSE
35+
EndGlobalSection
36+
GlobalSection(NestedProjects) = preSolution
37+
{5D5AAD1B-A3F6-46D9-B7A3-A4627DED1E64} = {B8EFCA5F-814F-285C-A8CB-F00F14650265}
38+
EndGlobalSection
39+
EndGlobal
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net9.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Ocelot" Version="24.1.0" />
11+
<PackageReference Include="Ocelot.Provider.Polly" Version="24.1.0" />
12+
</ItemGroup>
13+
14+
</Project>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
namespace HttpsRichardy.Federation.Proxy;
2+
3+
internal static class Program
4+
{
5+
private static async Task Main(string[] args)
6+
{
7+
var builder = WebApplication.CreateBuilder(args);
8+
9+
builder.Configuration.AddJsonFile("ocelot.json", optional: false, reloadOnChange: true);
10+
builder.Configuration.AddEnvironmentVariables();
11+
12+
builder.Services
13+
.AddOcelot(builder.Configuration)
14+
.AddPolly();
15+
16+
var app = builder.Build();
17+
18+
app.UseHttpsRedirection();
19+
20+
await app.UseOcelot();
21+
await app.RunAsync();
22+
}
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"$schema": "https://json.schemastore.org/launchsettings.json",
3+
"profiles": {
4+
"http": {
5+
"commandName": "Project",
6+
"dotnetRunMessages": true,
7+
"launchBrowser": false,
8+
"applicationUrl": "http://localhost:5239",
9+
"environmentVariables": {
10+
"ASPNETCORE_ENVIRONMENT": "Development"
11+
}
12+
},
13+
"https": {
14+
"commandName": "Project",
15+
"dotnetRunMessages": true,
16+
"launchBrowser": false,
17+
"applicationUrl": "https://localhost:7292;http://localhost:5239",
18+
"environmentVariables": {
19+
"ASPNETCORE_ENVIRONMENT": "Development"
20+
}
21+
}
22+
}
23+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
global using Ocelot.DependencyInjection;
2+
global using Ocelot.Middleware;
3+
global using Ocelot.Provider.Polly;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning"
6+
}
7+
},
8+
"AllowedHosts": "*"
9+
}

0 commit comments

Comments
 (0)