feat: Configuración inicial de Docker Compose, Nginx y proyectos .NET
This commit is contained in:
		
							
								
								
									
										25
									
								
								Elecciones-Web/src/Elecciones.Api/Dockerfile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								Elecciones-Web/src/Elecciones.Api/Dockerfile
									
									
									
									
									
										Normal file
									
								
							| @@ -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"] | ||||
							
								
								
									
										17
									
								
								Elecciones-Web/src/Elecciones.Api/Elecciones.Api.csproj
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								Elecciones-Web/src/Elecciones.Api/Elecciones.Api.csproj
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| <Project Sdk="Microsoft.NET.Sdk.Web"> | ||||
|  | ||||
|   <PropertyGroup> | ||||
|     <TargetFramework>net9.0</TargetFramework> | ||||
|     <Nullable>enable</Nullable> | ||||
|     <ImplicitUsings>enable</ImplicitUsings> | ||||
|   </PropertyGroup> | ||||
|  | ||||
|   <ItemGroup> | ||||
|     <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.5" /> | ||||
|   </ItemGroup> | ||||
|  | ||||
|   <ItemGroup> | ||||
|     <ProjectReference Include="..\Elecciones.Infrastructure\Elecciones.Infrastructure.csproj" /> | ||||
|   </ItemGroup> | ||||
|  | ||||
| </Project> | ||||
							
								
								
									
										6
									
								
								Elecciones-Web/src/Elecciones.Api/Elecciones.Api.http
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								Elecciones-Web/src/Elecciones.Api/Elecciones.Api.http
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,6 @@ | ||||
| @Elecciones.Api_HostAddress = http://localhost:5217 | ||||
|  | ||||
| GET {{Elecciones.Api_HostAddress}}/weatherforecast/ | ||||
| Accept: application/json | ||||
|  | ||||
| ### | ||||
							
								
								
									
										41
									
								
								Elecciones-Web/src/Elecciones.Api/Program.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								Elecciones-Web/src/Elecciones.Api/Program.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -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); | ||||
| } | ||||
| @@ -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" | ||||
|       } | ||||
|     } | ||||
|   } | ||||
| } | ||||
| @@ -0,0 +1,8 @@ | ||||
| { | ||||
|   "Logging": { | ||||
|     "LogLevel": { | ||||
|       "Default": "Information", | ||||
|       "Microsoft.AspNetCore": "Warning" | ||||
|     } | ||||
|   } | ||||
| } | ||||
							
								
								
									
										9
									
								
								Elecciones-Web/src/Elecciones.Api/appsettings.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								Elecciones-Web/src/Elecciones.Api/appsettings.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| { | ||||
|   "Logging": { | ||||
|     "LogLevel": { | ||||
|       "Default": "Information", | ||||
|       "Microsoft.AspNetCore": "Warning" | ||||
|     } | ||||
|   }, | ||||
|   "AllowedHosts": "*" | ||||
| } | ||||
| @@ -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" | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|   } | ||||
| } | ||||
| @@ -0,0 +1,16 @@ | ||||
| <?xml version="1.0" encoding="utf-8" standalone="no"?> | ||||
| <Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||||
|   <PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' "> | ||||
|     <RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess> | ||||
|     <RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool> | ||||
|     <ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile> | ||||
|     <NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot> | ||||
|     <NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\dmolinari\.nuget\packages\;D:\Microsoft\VisualStudio\Microsoft Visual Studio\Shared\NuGetPackages</NuGetPackageFolders> | ||||
|     <NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle> | ||||
|     <NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.14.0</NuGetToolVersion> | ||||
|   </PropertyGroup> | ||||
|   <ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' "> | ||||
|     <SourceRoot Include="C:\Users\dmolinari\.nuget\packages\" /> | ||||
|     <SourceRoot Include="D:\Microsoft\VisualStudio\Microsoft Visual Studio\Shared\NuGetPackages\" /> | ||||
|   </ItemGroup> | ||||
| </Project> | ||||
| @@ -0,0 +1,2 @@ | ||||
| <?xml version="1.0" encoding="utf-8" standalone="no"?> | ||||
| <Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" /> | ||||
		Reference in New Issue
	
	Block a user