Skip to content

Commit

Permalink
Merge pull request #45 from AngeloDotNet/develop
Browse files Browse the repository at this point in the history
Sync Main from Develop
  • Loading branch information
AngeloDotNet authored Dec 1, 2024
2 parents d5f8372 + a50ed65 commit f81c179
Show file tree
Hide file tree
Showing 18 changed files with 1,379 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Yarp.ReverseProxy" Version="2.2.0" />
</ItemGroup>

</Project>
20 changes: 20 additions & 0 deletions src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 5001

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/AutenticazioneSvc.LoadBalancer.csproj", "src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/"]
RUN dotnet restore "src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/AutenticazioneSvc.LoadBalancer.csproj"
COPY . .

WORKDIR "/src/src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer"
RUN dotnet build "AutenticazioneSvc.LoadBalancer.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "AutenticazioneSvc.LoadBalancer.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "AutenticazioneSvc.LoadBalancer.dll"]
33 changes: 33 additions & 0 deletions src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Microsoft.AspNetCore.Server.Kestrel.Core;

namespace AutenticazioneSvc.LoadBalancer;

public class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
/// <param name="args">The command-line arguments.</param>
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);

// Add reverse proxy services and load configuration from appsettings
builder.Services.AddReverseProxy()
.LoadFromConfig(builder.Configuration.GetSection("LoadBalancer"));

// Configure Kestrel server options
builder.Services.Configure<KestrelServerOptions>(builder.Configuration.GetSection("Kestrel"));

// Configure route options to use lowercase URLs
builder.Services.Configure<RouteOptions>(options => options.LowercaseUrls = true);

var app = builder.Build();

// Map reverse proxy routes
app.MapReverseProxy();

// Run the application
app.Run();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:24524",
"sslPort": 0
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:5083",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"LoadBalancer": {
"Routes": {
"route1": {
"ClusterId": "cluster1",
"Match": {
"Path": "{**catch-all}"
}
}
},
"Clusters": {
"cluster1": {
//"LoadBalancingPolicy": "RoundRobin",
"Destinations": {
"destination1": {
"Address": "http://NOME-DOCKER-API:5001"
}
//"destination1": {
// "Address": "http://[Host]:[Port]/"
//},
//"destination2": {
// "Address": "http://[Host]:[Port]/"
//}
}
}
}
},
"AllowedHosts": "*"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\AutenticazioneSvc.DataAccessLayer\AutenticazioneSvc.DataAccessLayer.csproj" />
</ItemGroup>

</Project>
Loading

0 comments on commit f81c179

Please sign in to comment.