diff --git a/Elecciones-Web/src/Elecciones.Api/Dockerfile b/Elecciones-Web/src/Elecciones.Api/Dockerfile new file mode 100644 index 0000000..72dd795 --- /dev/null +++ b/Elecciones-Web/src/Elecciones.Api/Dockerfile @@ -0,0 +1,25 @@ +# --- Etapa 1: Build --- +# Usamos la imagen del SDK de .NET 9 para compilar +FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build +WORKDIR /src + +# Copiamos los archivos .csproj para restaurar dependencias +COPY ["src/Elecciones.Api/Elecciones.Api.csproj", "Elecciones.Api/"] +COPY ["src/Elecciones.Infrastructure/Elecciones.Infrastructure.csproj", "Elecciones.Infrastructure/"] +COPY ["src/Elecciones.Core/Elecciones.Core.csproj", "Elecciones.Core/"] +COPY ["src/Elecciones.Database/Elecciones.Database.csproj", "Elecciones.Database/"] +RUN dotnet restore "Elecciones.Api/Elecciones.Api.csproj" + +# Copiamos el resto del código fuente +COPY src/. . + +# Publicamos la aplicación en modo Release +WORKDIR "/src/Elecciones.Api" +RUN dotnet publish "Elecciones.Api.csproj" -c Release -o /app/publish + +# --- Etapa 2: Final --- +# Usamos la imagen de runtime de ASP.NET, mucho más ligera +FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS final +WORKDIR /app +COPY --from=build /app/publish . +ENTRYPOINT ["dotnet", "Elecciones.Api.dll"] \ No newline at end of file diff --git a/Elecciones-Web/src/Elecciones.Api/Elecciones.Api.csproj b/Elecciones-Web/src/Elecciones.Api/Elecciones.Api.csproj new file mode 100644 index 0000000..b69e0bb --- /dev/null +++ b/Elecciones-Web/src/Elecciones.Api/Elecciones.Api.csproj @@ -0,0 +1,17 @@ + + + + net9.0 + enable + enable + + + + + + + + + + + diff --git a/Elecciones-Web/src/Elecciones.Api/Elecciones.Api.http b/Elecciones-Web/src/Elecciones.Api/Elecciones.Api.http new file mode 100644 index 0000000..19b1e47 --- /dev/null +++ b/Elecciones-Web/src/Elecciones.Api/Elecciones.Api.http @@ -0,0 +1,6 @@ +@Elecciones.Api_HostAddress = http://localhost:5217 + +GET {{Elecciones.Api_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/Elecciones-Web/src/Elecciones.Api/Program.cs b/Elecciones-Web/src/Elecciones.Api/Program.cs new file mode 100644 index 0000000..ee9d65d --- /dev/null +++ b/Elecciones-Web/src/Elecciones.Api/Program.cs @@ -0,0 +1,41 @@ +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. +// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi +builder.Services.AddOpenApi(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.MapOpenApi(); +} + +app.UseHttpsRedirection(); + +var summaries = new[] +{ + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" +}; + +app.MapGet("/weatherforecast", () => +{ + var forecast = Enumerable.Range(1, 5).Select(index => + new WeatherForecast + ( + DateOnly.FromDateTime(DateTime.Now.AddDays(index)), + Random.Shared.Next(-20, 55), + summaries[Random.Shared.Next(summaries.Length)] + )) + .ToArray(); + return forecast; +}) +.WithName("GetWeatherForecast"); + +app.Run(); + +record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary) +{ + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); +} diff --git a/Elecciones-Web/src/Elecciones.Api/Properties/launchSettings.json b/Elecciones-Web/src/Elecciones.Api/Properties/launchSettings.json new file mode 100644 index 0000000..1ce4b52 --- /dev/null +++ b/Elecciones-Web/src/Elecciones.Api/Properties/launchSettings.json @@ -0,0 +1,23 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "http://localhost:5217", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "https://localhost:7193;http://localhost:5217", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/Elecciones-Web/src/Elecciones.Api/appsettings.Development.json b/Elecciones-Web/src/Elecciones.Api/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/Elecciones-Web/src/Elecciones.Api/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/Elecciones-Web/src/Elecciones.Api/appsettings.json b/Elecciones-Web/src/Elecciones.Api/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/Elecciones-Web/src/Elecciones.Api/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/Elecciones-Web/src/Elecciones.Api/obj/Elecciones.Api.csproj.nuget.dgspec.json b/Elecciones-Web/src/Elecciones.Api/obj/Elecciones.Api.csproj.nuget.dgspec.json new file mode 100644 index 0000000..4cda936 --- /dev/null +++ b/Elecciones-Web/src/Elecciones.Api/obj/Elecciones.Api.csproj.nuget.dgspec.json @@ -0,0 +1,82 @@ +{ + "format": 1, + "restore": { + "E:\\Elecciones-2025\\Elecciones-Web\\src\\Elecciones.Api\\Elecciones.Api.csproj": {} + }, + "projects": { + "E:\\Elecciones-2025\\Elecciones-Web\\src\\Elecciones.Api\\Elecciones.Api.csproj": { + "version": "1.0.0", + "restore": { + "projectUniqueName": "E:\\Elecciones-2025\\Elecciones-Web\\src\\Elecciones.Api\\Elecciones.Api.csproj", + "projectName": "Elecciones.Api", + "projectPath": "E:\\Elecciones-2025\\Elecciones-Web\\src\\Elecciones.Api\\Elecciones.Api.csproj", + "packagesPath": "C:\\Users\\dmolinari\\.nuget\\packages\\", + "outputPath": "E:\\Elecciones-2025\\Elecciones-Web\\src\\Elecciones.Api\\obj\\", + "projectStyle": "PackageReference", + "fallbackFolders": [ + "D:\\Microsoft\\VisualStudio\\Microsoft Visual Studio\\Shared\\NuGetPackages" + ], + "configFilePaths": [ + "C:\\Users\\dmolinari\\AppData\\Roaming\\NuGet\\NuGet.Config", + "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config", + "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config" + ], + "originalTargetFrameworks": [ + "net9.0" + ], + "sources": { + "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, + "https://api.nuget.org/v3/index.json": {} + }, + "frameworks": { + "net9.0": { + "targetAlias": "net9.0", + "projectReferences": {} + } + }, + "warningProperties": { + "warnAsError": [ + "NU1605" + ] + }, + "restoreAuditProperties": { + "enableAudit": "true", + "auditLevel": "low", + "auditMode": "direct" + }, + "SdkAnalysisLevel": "9.0.300" + }, + "frameworks": { + "net9.0": { + "targetAlias": "net9.0", + "dependencies": { + "Microsoft.AspNetCore.OpenApi": { + "target": "Package", + "version": "[9.0.5, )" + } + }, + "imports": [ + "net461", + "net462", + "net47", + "net471", + "net472", + "net48", + "net481" + ], + "assetTargetFallback": true, + "warn": true, + "frameworkReferences": { + "Microsoft.AspNetCore.App": { + "privateAssets": "none" + }, + "Microsoft.NETCore.App": { + "privateAssets": "all" + } + }, + "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\9.0.300/PortableRuntimeIdentifierGraph.json" + } + } + } + } +} \ No newline at end of file diff --git a/Elecciones-Web/src/Elecciones.Api/obj/Elecciones.Api.csproj.nuget.g.props b/Elecciones-Web/src/Elecciones.Api/obj/Elecciones.Api.csproj.nuget.g.props new file mode 100644 index 0000000..438e8fa --- /dev/null +++ b/Elecciones-Web/src/Elecciones.Api/obj/Elecciones.Api.csproj.nuget.g.props @@ -0,0 +1,16 @@ + + + + True + NuGet + $(MSBuildThisFileDirectory)project.assets.json + $(UserProfile)\.nuget\packages\ + C:\Users\dmolinari\.nuget\packages\;D:\Microsoft\VisualStudio\Microsoft Visual Studio\Shared\NuGetPackages + PackageReference + 6.14.0 + + + + + + \ No newline at end of file diff --git a/Elecciones-Web/src/Elecciones.Api/obj/Elecciones.Api.csproj.nuget.g.targets b/Elecciones-Web/src/Elecciones.Api/obj/Elecciones.Api.csproj.nuget.g.targets new file mode 100644 index 0000000..3dc06ef --- /dev/null +++ b/Elecciones-Web/src/Elecciones.Api/obj/Elecciones.Api.csproj.nuget.g.targets @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/Elecciones-Web/src/Elecciones.Core/Class1.cs b/Elecciones-Web/src/Elecciones.Core/Class1.cs new file mode 100644 index 0000000..8fcbc9d --- /dev/null +++ b/Elecciones-Web/src/Elecciones.Core/Class1.cs @@ -0,0 +1,6 @@ +namespace Elecciones.Core; + +public class Class1 +{ + +} diff --git a/Elecciones-Web/src/Elecciones.Core/Elecciones.Core.csproj b/Elecciones-Web/src/Elecciones.Core/Elecciones.Core.csproj new file mode 100644 index 0000000..125f4c9 --- /dev/null +++ b/Elecciones-Web/src/Elecciones.Core/Elecciones.Core.csproj @@ -0,0 +1,9 @@ + + + + net9.0 + enable + enable + + + diff --git a/Elecciones-Web/src/Elecciones.Core/obj/Elecciones.Core.csproj.nuget.dgspec.json b/Elecciones-Web/src/Elecciones.Core/obj/Elecciones.Core.csproj.nuget.dgspec.json new file mode 100644 index 0000000..6321283 --- /dev/null +++ b/Elecciones-Web/src/Elecciones.Core/obj/Elecciones.Core.csproj.nuget.dgspec.json @@ -0,0 +1,73 @@ +{ + "format": 1, + "restore": { + "E:\\Elecciones-2025\\Elecciones-Web\\src\\Elecciones.Core\\Elecciones.Core.csproj": {} + }, + "projects": { + "E:\\Elecciones-2025\\Elecciones-Web\\src\\Elecciones.Core\\Elecciones.Core.csproj": { + "version": "1.0.0", + "restore": { + "projectUniqueName": "E:\\Elecciones-2025\\Elecciones-Web\\src\\Elecciones.Core\\Elecciones.Core.csproj", + "projectName": "Elecciones.Core", + "projectPath": "E:\\Elecciones-2025\\Elecciones-Web\\src\\Elecciones.Core\\Elecciones.Core.csproj", + "packagesPath": "C:\\Users\\dmolinari\\.nuget\\packages\\", + "outputPath": "E:\\Elecciones-2025\\Elecciones-Web\\src\\Elecciones.Core\\obj\\", + "projectStyle": "PackageReference", + "fallbackFolders": [ + "D:\\Microsoft\\VisualStudio\\Microsoft Visual Studio\\Shared\\NuGetPackages" + ], + "configFilePaths": [ + "C:\\Users\\dmolinari\\AppData\\Roaming\\NuGet\\NuGet.Config", + "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config", + "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config" + ], + "originalTargetFrameworks": [ + "net9.0" + ], + "sources": { + "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, + "https://api.nuget.org/v3/index.json": {} + }, + "frameworks": { + "net9.0": { + "targetAlias": "net9.0", + "projectReferences": {} + } + }, + "warningProperties": { + "warnAsError": [ + "NU1605" + ] + }, + "restoreAuditProperties": { + "enableAudit": "true", + "auditLevel": "low", + "auditMode": "direct" + }, + "SdkAnalysisLevel": "9.0.300" + }, + "frameworks": { + "net9.0": { + "targetAlias": "net9.0", + "imports": [ + "net461", + "net462", + "net47", + "net471", + "net472", + "net48", + "net481" + ], + "assetTargetFallback": true, + "warn": true, + "frameworkReferences": { + "Microsoft.NETCore.App": { + "privateAssets": "all" + } + }, + "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\9.0.300/PortableRuntimeIdentifierGraph.json" + } + } + } + } +} \ No newline at end of file diff --git a/Elecciones-Web/src/Elecciones.Core/obj/Elecciones.Core.csproj.nuget.g.props b/Elecciones-Web/src/Elecciones.Core/obj/Elecciones.Core.csproj.nuget.g.props new file mode 100644 index 0000000..438e8fa --- /dev/null +++ b/Elecciones-Web/src/Elecciones.Core/obj/Elecciones.Core.csproj.nuget.g.props @@ -0,0 +1,16 @@ + + + + True + NuGet + $(MSBuildThisFileDirectory)project.assets.json + $(UserProfile)\.nuget\packages\ + C:\Users\dmolinari\.nuget\packages\;D:\Microsoft\VisualStudio\Microsoft Visual Studio\Shared\NuGetPackages + PackageReference + 6.14.0 + + + + + + \ No newline at end of file diff --git a/Elecciones-Web/src/Elecciones.Core/obj/Elecciones.Core.csproj.nuget.g.targets b/Elecciones-Web/src/Elecciones.Core/obj/Elecciones.Core.csproj.nuget.g.targets new file mode 100644 index 0000000..3dc06ef --- /dev/null +++ b/Elecciones-Web/src/Elecciones.Core/obj/Elecciones.Core.csproj.nuget.g.targets @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/Elecciones-Web/src/Elecciones.Database/Class1.cs b/Elecciones-Web/src/Elecciones.Database/Class1.cs new file mode 100644 index 0000000..f063083 --- /dev/null +++ b/Elecciones-Web/src/Elecciones.Database/Class1.cs @@ -0,0 +1,6 @@ +namespace Elecciones.Database; + +public class Class1 +{ + +} diff --git a/Elecciones-Web/src/Elecciones.Database/Elecciones.Database.csproj b/Elecciones-Web/src/Elecciones.Database/Elecciones.Database.csproj new file mode 100644 index 0000000..125f4c9 --- /dev/null +++ b/Elecciones-Web/src/Elecciones.Database/Elecciones.Database.csproj @@ -0,0 +1,9 @@ + + + + net9.0 + enable + enable + + + diff --git a/Elecciones-Web/src/Elecciones.Database/obj/Elecciones.Database.csproj.nuget.dgspec.json b/Elecciones-Web/src/Elecciones.Database/obj/Elecciones.Database.csproj.nuget.dgspec.json new file mode 100644 index 0000000..2947840 --- /dev/null +++ b/Elecciones-Web/src/Elecciones.Database/obj/Elecciones.Database.csproj.nuget.dgspec.json @@ -0,0 +1,73 @@ +{ + "format": 1, + "restore": { + "E:\\Elecciones-2025\\Elecciones-Web\\src\\Elecciones.Database\\Elecciones.Database.csproj": {} + }, + "projects": { + "E:\\Elecciones-2025\\Elecciones-Web\\src\\Elecciones.Database\\Elecciones.Database.csproj": { + "version": "1.0.0", + "restore": { + "projectUniqueName": "E:\\Elecciones-2025\\Elecciones-Web\\src\\Elecciones.Database\\Elecciones.Database.csproj", + "projectName": "Elecciones.Database", + "projectPath": "E:\\Elecciones-2025\\Elecciones-Web\\src\\Elecciones.Database\\Elecciones.Database.csproj", + "packagesPath": "C:\\Users\\dmolinari\\.nuget\\packages\\", + "outputPath": "E:\\Elecciones-2025\\Elecciones-Web\\src\\Elecciones.Database\\obj\\", + "projectStyle": "PackageReference", + "fallbackFolders": [ + "D:\\Microsoft\\VisualStudio\\Microsoft Visual Studio\\Shared\\NuGetPackages" + ], + "configFilePaths": [ + "C:\\Users\\dmolinari\\AppData\\Roaming\\NuGet\\NuGet.Config", + "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config", + "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config" + ], + "originalTargetFrameworks": [ + "net9.0" + ], + "sources": { + "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, + "https://api.nuget.org/v3/index.json": {} + }, + "frameworks": { + "net9.0": { + "targetAlias": "net9.0", + "projectReferences": {} + } + }, + "warningProperties": { + "warnAsError": [ + "NU1605" + ] + }, + "restoreAuditProperties": { + "enableAudit": "true", + "auditLevel": "low", + "auditMode": "direct" + }, + "SdkAnalysisLevel": "9.0.300" + }, + "frameworks": { + "net9.0": { + "targetAlias": "net9.0", + "imports": [ + "net461", + "net462", + "net47", + "net471", + "net472", + "net48", + "net481" + ], + "assetTargetFallback": true, + "warn": true, + "frameworkReferences": { + "Microsoft.NETCore.App": { + "privateAssets": "all" + } + }, + "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\9.0.300/PortableRuntimeIdentifierGraph.json" + } + } + } + } +} \ No newline at end of file diff --git a/Elecciones-Web/src/Elecciones.Database/obj/Elecciones.Database.csproj.nuget.g.props b/Elecciones-Web/src/Elecciones.Database/obj/Elecciones.Database.csproj.nuget.g.props new file mode 100644 index 0000000..438e8fa --- /dev/null +++ b/Elecciones-Web/src/Elecciones.Database/obj/Elecciones.Database.csproj.nuget.g.props @@ -0,0 +1,16 @@ + + + + True + NuGet + $(MSBuildThisFileDirectory)project.assets.json + $(UserProfile)\.nuget\packages\ + C:\Users\dmolinari\.nuget\packages\;D:\Microsoft\VisualStudio\Microsoft Visual Studio\Shared\NuGetPackages + PackageReference + 6.14.0 + + + + + + \ No newline at end of file diff --git a/Elecciones-Web/src/Elecciones.Database/obj/Elecciones.Database.csproj.nuget.g.targets b/Elecciones-Web/src/Elecciones.Database/obj/Elecciones.Database.csproj.nuget.g.targets new file mode 100644 index 0000000..3dc06ef --- /dev/null +++ b/Elecciones-Web/src/Elecciones.Database/obj/Elecciones.Database.csproj.nuget.g.targets @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/Elecciones-Web/src/Elecciones.Infrastructure/Class1.cs b/Elecciones-Web/src/Elecciones.Infrastructure/Class1.cs new file mode 100644 index 0000000..98733e4 --- /dev/null +++ b/Elecciones-Web/src/Elecciones.Infrastructure/Class1.cs @@ -0,0 +1,6 @@ +namespace Elecciones.Infrastructure; + +public class Class1 +{ + +} diff --git a/Elecciones-Web/src/Elecciones.Infrastructure/Elecciones.Infrastructure.csproj b/Elecciones-Web/src/Elecciones.Infrastructure/Elecciones.Infrastructure.csproj new file mode 100644 index 0000000..c85186c --- /dev/null +++ b/Elecciones-Web/src/Elecciones.Infrastructure/Elecciones.Infrastructure.csproj @@ -0,0 +1,13 @@ + + + + + + + + net9.0 + enable + enable + + + diff --git a/Elecciones-Web/src/Elecciones.Infrastructure/obj/Elecciones.Infrastructure.csproj.nuget.dgspec.json b/Elecciones-Web/src/Elecciones.Infrastructure/obj/Elecciones.Infrastructure.csproj.nuget.dgspec.json new file mode 100644 index 0000000..7875b2b --- /dev/null +++ b/Elecciones-Web/src/Elecciones.Infrastructure/obj/Elecciones.Infrastructure.csproj.nuget.dgspec.json @@ -0,0 +1,73 @@ +{ + "format": 1, + "restore": { + "E:\\Elecciones-2025\\Elecciones-Web\\src\\Elecciones.Infrastructure\\Elecciones.Infrastructure.csproj": {} + }, + "projects": { + "E:\\Elecciones-2025\\Elecciones-Web\\src\\Elecciones.Infrastructure\\Elecciones.Infrastructure.csproj": { + "version": "1.0.0", + "restore": { + "projectUniqueName": "E:\\Elecciones-2025\\Elecciones-Web\\src\\Elecciones.Infrastructure\\Elecciones.Infrastructure.csproj", + "projectName": "Elecciones.Infrastructure", + "projectPath": "E:\\Elecciones-2025\\Elecciones-Web\\src\\Elecciones.Infrastructure\\Elecciones.Infrastructure.csproj", + "packagesPath": "C:\\Users\\dmolinari\\.nuget\\packages\\", + "outputPath": "E:\\Elecciones-2025\\Elecciones-Web\\src\\Elecciones.Infrastructure\\obj\\", + "projectStyle": "PackageReference", + "fallbackFolders": [ + "D:\\Microsoft\\VisualStudio\\Microsoft Visual Studio\\Shared\\NuGetPackages" + ], + "configFilePaths": [ + "C:\\Users\\dmolinari\\AppData\\Roaming\\NuGet\\NuGet.Config", + "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config", + "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config" + ], + "originalTargetFrameworks": [ + "net9.0" + ], + "sources": { + "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, + "https://api.nuget.org/v3/index.json": {} + }, + "frameworks": { + "net9.0": { + "targetAlias": "net9.0", + "projectReferences": {} + } + }, + "warningProperties": { + "warnAsError": [ + "NU1605" + ] + }, + "restoreAuditProperties": { + "enableAudit": "true", + "auditLevel": "low", + "auditMode": "direct" + }, + "SdkAnalysisLevel": "9.0.300" + }, + "frameworks": { + "net9.0": { + "targetAlias": "net9.0", + "imports": [ + "net461", + "net462", + "net47", + "net471", + "net472", + "net48", + "net481" + ], + "assetTargetFallback": true, + "warn": true, + "frameworkReferences": { + "Microsoft.NETCore.App": { + "privateAssets": "all" + } + }, + "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\9.0.300/PortableRuntimeIdentifierGraph.json" + } + } + } + } +} \ No newline at end of file diff --git a/Elecciones-Web/src/Elecciones.Infrastructure/obj/Elecciones.Infrastructure.csproj.nuget.g.props b/Elecciones-Web/src/Elecciones.Infrastructure/obj/Elecciones.Infrastructure.csproj.nuget.g.props new file mode 100644 index 0000000..438e8fa --- /dev/null +++ b/Elecciones-Web/src/Elecciones.Infrastructure/obj/Elecciones.Infrastructure.csproj.nuget.g.props @@ -0,0 +1,16 @@ + + + + True + NuGet + $(MSBuildThisFileDirectory)project.assets.json + $(UserProfile)\.nuget\packages\ + C:\Users\dmolinari\.nuget\packages\;D:\Microsoft\VisualStudio\Microsoft Visual Studio\Shared\NuGetPackages + PackageReference + 6.14.0 + + + + + + \ No newline at end of file diff --git a/Elecciones-Web/src/Elecciones.Infrastructure/obj/Elecciones.Infrastructure.csproj.nuget.g.targets b/Elecciones-Web/src/Elecciones.Infrastructure/obj/Elecciones.Infrastructure.csproj.nuget.g.targets new file mode 100644 index 0000000..3dc06ef --- /dev/null +++ b/Elecciones-Web/src/Elecciones.Infrastructure/obj/Elecciones.Infrastructure.csproj.nuget.g.targets @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/Elecciones-Web/src/Elecciones.Worker/Dockerfile b/Elecciones-Web/src/Elecciones.Worker/Dockerfile new file mode 100644 index 0000000..2ceca7d --- /dev/null +++ b/Elecciones-Web/src/Elecciones.Worker/Dockerfile @@ -0,0 +1,24 @@ +# --- Etapa 1: Build --- +FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build +WORKDIR /src + +# Copiamos los archivos .csproj para restaurar dependencias +COPY ["src/Elecciones.Worker/Elecciones.Worker.csproj", "Elecciones.Worker/"] +COPY ["src/Elecciones.Infrastructure/Elecciones.Infrastructure.csproj", "Elecciones.Infrastructure/"] +COPY ["src/Elecciones.Core/Elecciones.Core.csproj", "Elecciones.Core/"] +COPY ["src/Elecciones.Database/Elecciones.Database.csproj", "Elecciones.Database/"] +RUN dotnet restore "Elecciones.Worker/Elecciones.Worker.csproj" + +# Copiamos el resto del código fuente +COPY src/. . + +# Publicamos el worker +WORKDIR "/src/Elecciones.Worker" +RUN dotnet publish "Elecciones.Worker.csproj" -c Release -o /app/publish + +# --- Etapa 2: Final --- +# Usamos la imagen de runtime genérica de .NET, ya que no necesita ASP.NET +FROM mcr.microsoft.com/dotnet/runtime:9.0 AS final +WORKDIR /app +COPY --from=build /app/publish . +ENTRYPOINT ["dotnet", "Elecciones.Worker.dll"] \ No newline at end of file diff --git a/Elecciones-Web/src/Elecciones.Worker/Elecciones.Worker.csproj b/Elecciones-Web/src/Elecciones.Worker/Elecciones.Worker.csproj new file mode 100644 index 0000000..bc9e808 --- /dev/null +++ b/Elecciones-Web/src/Elecciones.Worker/Elecciones.Worker.csproj @@ -0,0 +1,17 @@ + + + + net9.0 + enable + enable + dotnet-Elecciones.Worker-b1c6e5c0-7ebf-4eaf-af95-9386d6883c03 + + + + + + + + + + diff --git a/Elecciones-Web/src/Elecciones.Worker/Program.cs b/Elecciones-Web/src/Elecciones.Worker/Program.cs new file mode 100644 index 0000000..66c5c94 --- /dev/null +++ b/Elecciones-Web/src/Elecciones.Worker/Program.cs @@ -0,0 +1,7 @@ +using Elecciones.Worker; + +var builder = Host.CreateApplicationBuilder(args); +builder.Services.AddHostedService(); + +var host = builder.Build(); +host.Run(); diff --git a/Elecciones-Web/src/Elecciones.Worker/Properties/launchSettings.json b/Elecciones-Web/src/Elecciones.Worker/Properties/launchSettings.json new file mode 100644 index 0000000..3eb589a --- /dev/null +++ b/Elecciones-Web/src/Elecciones.Worker/Properties/launchSettings.json @@ -0,0 +1,12 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "Elecciones.Worker": { + "commandName": "Project", + "dotnetRunMessages": true, + "environmentVariables": { + "DOTNET_ENVIRONMENT": "Development" + } + } + } +} diff --git a/Elecciones-Web/src/Elecciones.Worker/Worker.cs b/Elecciones-Web/src/Elecciones.Worker/Worker.cs new file mode 100644 index 0000000..e0b5ba3 --- /dev/null +++ b/Elecciones-Web/src/Elecciones.Worker/Worker.cs @@ -0,0 +1,23 @@ +namespace Elecciones.Worker; + +public class Worker : BackgroundService +{ + private readonly ILogger _logger; + + public Worker(ILogger logger) + { + _logger = logger; + } + + protected override async Task ExecuteAsync(CancellationToken stoppingToken) + { + while (!stoppingToken.IsCancellationRequested) + { + if (_logger.IsEnabled(LogLevel.Information)) + { + _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now); + } + await Task.Delay(1000, stoppingToken); + } + } +} diff --git a/Elecciones-Web/src/Elecciones.Worker/appsettings.Development.json b/Elecciones-Web/src/Elecciones.Worker/appsettings.Development.json new file mode 100644 index 0000000..b2dcdb6 --- /dev/null +++ b/Elecciones-Web/src/Elecciones.Worker/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/Elecciones-Web/src/Elecciones.Worker/appsettings.json b/Elecciones-Web/src/Elecciones.Worker/appsettings.json new file mode 100644 index 0000000..b2dcdb6 --- /dev/null +++ b/Elecciones-Web/src/Elecciones.Worker/appsettings.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/Elecciones-Web/src/Elecciones.Worker/obj/Elecciones.Worker.csproj.nuget.dgspec.json b/Elecciones-Web/src/Elecciones.Worker/obj/Elecciones.Worker.csproj.nuget.dgspec.json new file mode 100644 index 0000000..6288f33 --- /dev/null +++ b/Elecciones-Web/src/Elecciones.Worker/obj/Elecciones.Worker.csproj.nuget.dgspec.json @@ -0,0 +1,79 @@ +{ + "format": 1, + "restore": { + "E:\\Elecciones-2025\\Elecciones-Web\\src\\Elecciones.Worker\\Elecciones.Worker.csproj": {} + }, + "projects": { + "E:\\Elecciones-2025\\Elecciones-Web\\src\\Elecciones.Worker\\Elecciones.Worker.csproj": { + "version": "1.0.0", + "restore": { + "projectUniqueName": "E:\\Elecciones-2025\\Elecciones-Web\\src\\Elecciones.Worker\\Elecciones.Worker.csproj", + "projectName": "Elecciones.Worker", + "projectPath": "E:\\Elecciones-2025\\Elecciones-Web\\src\\Elecciones.Worker\\Elecciones.Worker.csproj", + "packagesPath": "C:\\Users\\dmolinari\\.nuget\\packages\\", + "outputPath": "E:\\Elecciones-2025\\Elecciones-Web\\src\\Elecciones.Worker\\obj\\", + "projectStyle": "PackageReference", + "fallbackFolders": [ + "D:\\Microsoft\\VisualStudio\\Microsoft Visual Studio\\Shared\\NuGetPackages" + ], + "configFilePaths": [ + "C:\\Users\\dmolinari\\AppData\\Roaming\\NuGet\\NuGet.Config", + "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config", + "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config" + ], + "originalTargetFrameworks": [ + "net9.0" + ], + "sources": { + "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, + "https://api.nuget.org/v3/index.json": {} + }, + "frameworks": { + "net9.0": { + "targetAlias": "net9.0", + "projectReferences": {} + } + }, + "warningProperties": { + "warnAsError": [ + "NU1605" + ] + }, + "restoreAuditProperties": { + "enableAudit": "true", + "auditLevel": "low", + "auditMode": "direct" + }, + "SdkAnalysisLevel": "9.0.300" + }, + "frameworks": { + "net9.0": { + "targetAlias": "net9.0", + "dependencies": { + "Microsoft.Extensions.Hosting": { + "target": "Package", + "version": "[9.0.5, )" + } + }, + "imports": [ + "net461", + "net462", + "net47", + "net471", + "net472", + "net48", + "net481" + ], + "assetTargetFallback": true, + "warn": true, + "frameworkReferences": { + "Microsoft.NETCore.App": { + "privateAssets": "all" + } + }, + "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\9.0.300/PortableRuntimeIdentifierGraph.json" + } + } + } + } +} \ No newline at end of file diff --git a/Elecciones-Web/src/Elecciones.Worker/obj/Elecciones.Worker.csproj.nuget.g.props b/Elecciones-Web/src/Elecciones.Worker/obj/Elecciones.Worker.csproj.nuget.g.props new file mode 100644 index 0000000..5ccde10 --- /dev/null +++ b/Elecciones-Web/src/Elecciones.Worker/obj/Elecciones.Worker.csproj.nuget.g.props @@ -0,0 +1,19 @@ + + + + True + NuGet + $(MSBuildThisFileDirectory)project.assets.json + $(UserProfile)\.nuget\packages\ + C:\Users\dmolinari\.nuget\packages\;D:\Microsoft\VisualStudio\Microsoft Visual Studio\Shared\NuGetPackages + PackageReference + 6.14.0 + + + + + + + + + \ No newline at end of file diff --git a/Elecciones-Web/src/Elecciones.Worker/obj/Elecciones.Worker.csproj.nuget.g.targets b/Elecciones-Web/src/Elecciones.Worker/obj/Elecciones.Worker.csproj.nuget.g.targets new file mode 100644 index 0000000..be34046 --- /dev/null +++ b/Elecciones-Web/src/Elecciones.Worker/obj/Elecciones.Worker.csproj.nuget.g.targets @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/Elecciones-Web/src/Elecciones.sln b/Elecciones-Web/src/Elecciones.sln new file mode 100644 index 0000000..d15ec3a --- /dev/null +++ b/Elecciones-Web/src/Elecciones.sln @@ -0,0 +1,90 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elecciones.Api", "Elecciones.Api\Elecciones.Api.csproj", "{6C88D221-9476-40B9-A9D1-3F718BFE2FEF}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elecciones.Worker", "Elecciones.Worker\Elecciones.Worker.csproj", "{871E5551-957F-4FE6-89C7-FB378E88D5C5}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elecciones.Infrastructure", "Elecciones.Infrastructure\Elecciones.Infrastructure.csproj", "{92EC4080-1DE2-4B88-A3CD-DC1B068B1165}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elecciones.Core", "Elecciones.Core\Elecciones.Core.csproj", "{86D78531-CCCB-4DD3-9AB3-3D269F693F9D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elecciones.Database", "Elecciones.Database\Elecciones.Database.csproj", "{ADC646D8-496D-4D3C-AB51-C603056055F0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6C88D221-9476-40B9-A9D1-3F718BFE2FEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6C88D221-9476-40B9-A9D1-3F718BFE2FEF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6C88D221-9476-40B9-A9D1-3F718BFE2FEF}.Debug|x64.ActiveCfg = Debug|Any CPU + {6C88D221-9476-40B9-A9D1-3F718BFE2FEF}.Debug|x64.Build.0 = Debug|Any CPU + {6C88D221-9476-40B9-A9D1-3F718BFE2FEF}.Debug|x86.ActiveCfg = Debug|Any CPU + {6C88D221-9476-40B9-A9D1-3F718BFE2FEF}.Debug|x86.Build.0 = Debug|Any CPU + {6C88D221-9476-40B9-A9D1-3F718BFE2FEF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6C88D221-9476-40B9-A9D1-3F718BFE2FEF}.Release|Any CPU.Build.0 = Release|Any CPU + {6C88D221-9476-40B9-A9D1-3F718BFE2FEF}.Release|x64.ActiveCfg = Release|Any CPU + {6C88D221-9476-40B9-A9D1-3F718BFE2FEF}.Release|x64.Build.0 = Release|Any CPU + {6C88D221-9476-40B9-A9D1-3F718BFE2FEF}.Release|x86.ActiveCfg = Release|Any CPU + {6C88D221-9476-40B9-A9D1-3F718BFE2FEF}.Release|x86.Build.0 = Release|Any CPU + {871E5551-957F-4FE6-89C7-FB378E88D5C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {871E5551-957F-4FE6-89C7-FB378E88D5C5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {871E5551-957F-4FE6-89C7-FB378E88D5C5}.Debug|x64.ActiveCfg = Debug|Any CPU + {871E5551-957F-4FE6-89C7-FB378E88D5C5}.Debug|x64.Build.0 = Debug|Any CPU + {871E5551-957F-4FE6-89C7-FB378E88D5C5}.Debug|x86.ActiveCfg = Debug|Any CPU + {871E5551-957F-4FE6-89C7-FB378E88D5C5}.Debug|x86.Build.0 = Debug|Any CPU + {871E5551-957F-4FE6-89C7-FB378E88D5C5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {871E5551-957F-4FE6-89C7-FB378E88D5C5}.Release|Any CPU.Build.0 = Release|Any CPU + {871E5551-957F-4FE6-89C7-FB378E88D5C5}.Release|x64.ActiveCfg = Release|Any CPU + {871E5551-957F-4FE6-89C7-FB378E88D5C5}.Release|x64.Build.0 = Release|Any CPU + {871E5551-957F-4FE6-89C7-FB378E88D5C5}.Release|x86.ActiveCfg = Release|Any CPU + {871E5551-957F-4FE6-89C7-FB378E88D5C5}.Release|x86.Build.0 = Release|Any CPU + {92EC4080-1DE2-4B88-A3CD-DC1B068B1165}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {92EC4080-1DE2-4B88-A3CD-DC1B068B1165}.Debug|Any CPU.Build.0 = Debug|Any CPU + {92EC4080-1DE2-4B88-A3CD-DC1B068B1165}.Debug|x64.ActiveCfg = Debug|Any CPU + {92EC4080-1DE2-4B88-A3CD-DC1B068B1165}.Debug|x64.Build.0 = Debug|Any CPU + {92EC4080-1DE2-4B88-A3CD-DC1B068B1165}.Debug|x86.ActiveCfg = Debug|Any CPU + {92EC4080-1DE2-4B88-A3CD-DC1B068B1165}.Debug|x86.Build.0 = Debug|Any CPU + {92EC4080-1DE2-4B88-A3CD-DC1B068B1165}.Release|Any CPU.ActiveCfg = Release|Any CPU + {92EC4080-1DE2-4B88-A3CD-DC1B068B1165}.Release|Any CPU.Build.0 = Release|Any CPU + {92EC4080-1DE2-4B88-A3CD-DC1B068B1165}.Release|x64.ActiveCfg = Release|Any CPU + {92EC4080-1DE2-4B88-A3CD-DC1B068B1165}.Release|x64.Build.0 = Release|Any CPU + {92EC4080-1DE2-4B88-A3CD-DC1B068B1165}.Release|x86.ActiveCfg = Release|Any CPU + {92EC4080-1DE2-4B88-A3CD-DC1B068B1165}.Release|x86.Build.0 = Release|Any CPU + {86D78531-CCCB-4DD3-9AB3-3D269F693F9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {86D78531-CCCB-4DD3-9AB3-3D269F693F9D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {86D78531-CCCB-4DD3-9AB3-3D269F693F9D}.Debug|x64.ActiveCfg = Debug|Any CPU + {86D78531-CCCB-4DD3-9AB3-3D269F693F9D}.Debug|x64.Build.0 = Debug|Any CPU + {86D78531-CCCB-4DD3-9AB3-3D269F693F9D}.Debug|x86.ActiveCfg = Debug|Any CPU + {86D78531-CCCB-4DD3-9AB3-3D269F693F9D}.Debug|x86.Build.0 = Debug|Any CPU + {86D78531-CCCB-4DD3-9AB3-3D269F693F9D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {86D78531-CCCB-4DD3-9AB3-3D269F693F9D}.Release|Any CPU.Build.0 = Release|Any CPU + {86D78531-CCCB-4DD3-9AB3-3D269F693F9D}.Release|x64.ActiveCfg = Release|Any CPU + {86D78531-CCCB-4DD3-9AB3-3D269F693F9D}.Release|x64.Build.0 = Release|Any CPU + {86D78531-CCCB-4DD3-9AB3-3D269F693F9D}.Release|x86.ActiveCfg = Release|Any CPU + {86D78531-CCCB-4DD3-9AB3-3D269F693F9D}.Release|x86.Build.0 = Release|Any CPU + {ADC646D8-496D-4D3C-AB51-C603056055F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ADC646D8-496D-4D3C-AB51-C603056055F0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ADC646D8-496D-4D3C-AB51-C603056055F0}.Debug|x64.ActiveCfg = Debug|Any CPU + {ADC646D8-496D-4D3C-AB51-C603056055F0}.Debug|x64.Build.0 = Debug|Any CPU + {ADC646D8-496D-4D3C-AB51-C603056055F0}.Debug|x86.ActiveCfg = Debug|Any CPU + {ADC646D8-496D-4D3C-AB51-C603056055F0}.Debug|x86.Build.0 = Debug|Any CPU + {ADC646D8-496D-4D3C-AB51-C603056055F0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ADC646D8-496D-4D3C-AB51-C603056055F0}.Release|Any CPU.Build.0 = Release|Any CPU + {ADC646D8-496D-4D3C-AB51-C603056055F0}.Release|x64.ActiveCfg = Release|Any CPU + {ADC646D8-496D-4D3C-AB51-C603056055F0}.Release|x64.Build.0 = Release|Any CPU + {ADC646D8-496D-4D3C-AB51-C603056055F0}.Release|x86.ActiveCfg = Release|Any CPU + {ADC646D8-496D-4D3C-AB51-C603056055F0}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/docker-compose.yml b/docker-compose.yml index e69de29..c12bf74 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -0,0 +1,65 @@ +services: + # Servicio del Backend API + elecciones-api: + build: + context: ./Elecciones-Web + dockerfile: src/Elecciones.Api/Dockerfile + container_name: elecciones-api + restart: unless-stopped + env_file: + - ./.env # Lee las variables de entorno desde el archivo .env + networks: + - elecciones-net + - shared-net # Se conecta a la red compartida para hablar con la DB + # No se exponen puertos directamente al host. El proxy se encarga. + + # Servicio del Worker para la ingesta de datos + elecciones-worker: + build: + context: ./Elecciones-Web + dockerfile: src/Elecciones.Worker/Dockerfile + container_name: elecciones-worker + restart: unless-stopped + env_file: + - ./.env + networks: + - shared-net # Solo necesita acceso a la DB y a la API electoral (internet). + # No se exponen puertos. + + # Servicio del Frontend (servido por Nginx) + # Lo definimos ahora, aunque lo construiremos más adelante. + elecciones-frontend: + build: + context: ./Elecciones-Web/frontend + dockerfile: Dockerfile + container_name: elecciones-frontend + restart: unless-stopped + networks: + - elecciones-net + # No se exponen puertos. + + # Proxy Inverso que expone los servicios al exterior + proxy: + image: nginx:1.25-alpine + container_name: elecciones-proxy + restart: unless-stopped + volumes: + # Mapea nuestro archivo de configuración local al contenedor de Nginx + - ./proxy/nginx.conf:/etc/nginx/conf.d/default.conf + ports: + # ÚNICO PUNTO DE ENTRADA: Expone el puerto 80 del contenedor al puerto 8600 del host. + - "8600:80" + networks: + - elecciones-net + depends_on: + - elecciones-api + - elecciones-frontend + +networks: + elecciones-net: + driver: bridge + + # Asumimos que la red 'shared-net' ya existe en Docker. + # Para crearla manualmente: docker network create shared-net + shared-net: + external: true \ No newline at end of file diff --git a/proxy/nginx.conf b/proxy/nginx.conf index e69de29..5ee2078 100644 --- a/proxy/nginx.conf +++ b/proxy/nginx.conf @@ -0,0 +1,55 @@ +# ./proxy/nginx.conf + +# Definimos los upstreams para referirnos a nuestros servicios por su nombre. +# Docker Compose se encargará de resolver estos nombres a las IPs de los contenedores. +upstream backend_api { + # Apunta al servicio de la API en el puerto que expone internamente. + # Por defecto, .NET en contenedores usa el 8080. + server elecciones-api:8080; +} + +upstream frontend_app { + # Apunta al contenedor que sirve los archivos estáticos del frontend. + # El Dockerfile del frontend usará un Nginx que escucha en el puerto 80. + server elecciones-frontend:80; +} + +server { + listen 80; + server_name _; # Escucha en cualquier hostname que llegue a este proxy. + + # --- UBICACIÓN PARA LA API --- + # Gestiona todas las peticiones que comienzan con /api/ + location /api/ { + proxy_pass http://backend_api; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + # --- UBICACIÓN PARA EL FRONTEND (RAÍZ Y CUALQUIER OTRA RUTA) --- + # Gestiona todas las demás peticiones. + location / { + # ¡CRUCIAL! Añade la cabecera CORS para permitir que los widgets + # se incrusten y carguen desde otros dominios como www.eldia.com. + add_header 'Access-Control-Allow-Origin' '*' always; + + # Manejo de peticiones pre-vuelo (preflight) OPTIONS. + if ($request_method = 'OPTIONS') { + add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS'; + add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range'; + add_header 'Access-Control-Max-Age' 1728000; + add_header 'Content-Type' 'text/plain; charset=utf-8'; + add_header 'Content-Length' 0; + return 204; + } + + # Redirige la petición al contenedor del frontend. + proxy_pass http://frontend_app; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} \ No newline at end of file