diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..cd967fc --- /dev/null +++ b/.dockerignore @@ -0,0 +1,25 @@ +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/.idea +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/azds.yaml +**/bin +**/charts +**/docker-compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +LICENSE +README.md \ No newline at end of file diff --git a/FichaBackend.sln b/FichaBackend.sln new file mode 100644 index 0000000..cb682cc --- /dev/null +++ b/FichaBackend.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FichaBackend", "FichaBackend\FichaBackend.csproj", "{D9831B70-A2EB-404E-A425-2A7585C87F16}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D9831B70-A2EB-404E-A425-2A7585C87F16}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D9831B70-A2EB-404E-A425-2A7585C87F16}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D9831B70-A2EB-404E-A425-2A7585C87F16}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D9831B70-A2EB-404E-A425-2A7585C87F16}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/FichaBackend/Controllers/WeatherForecastController.cs b/FichaBackend/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..3a80ae4 --- /dev/null +++ b/FichaBackend/Controllers/WeatherForecastController.cs @@ -0,0 +1,32 @@ +using Microsoft.AspNetCore.Mvc; + +namespace FichaBackend.Controllers; + +[ApiController] +[Route("[controller]")] +public class WeatherForecastController : ControllerBase +{ + private static readonly string[] Summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + private readonly ILogger _logger; + + public WeatherForecastController(ILogger logger) + { + _logger = logger; + } + + [HttpGet(Name = "GetWeatherForecast")] + public IEnumerable Get() + { + return Enumerable.Range(1, 5).Select(index => new WeatherForecast + { + Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), + TemperatureC = Random.Shared.Next(-20, 55), + Summary = Summaries[Random.Shared.Next(Summaries.Length)] + }) + .ToArray(); + } +} \ No newline at end of file diff --git a/FichaBackend/Dockerfile b/FichaBackend/Dockerfile new file mode 100644 index 0000000..8030b99 --- /dev/null +++ b/FichaBackend/Dockerfile @@ -0,0 +1,20 @@ +FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base +WORKDIR /app +EXPOSE 80 +EXPOSE 443 + +FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build +WORKDIR /src +COPY ["FichaBackend/FichaBackend.csproj", "FichaBackend/"] +RUN dotnet restore "FichaBackend/FichaBackend.csproj" +COPY . . +WORKDIR "/src/FichaBackend" +RUN dotnet build "FichaBackend.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "FichaBackend.csproj" -c Release -o /app/publish /p:UseAppHost=false + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "FichaBackend.dll"] diff --git a/FichaBackend/FichaBackend.csproj b/FichaBackend/FichaBackend.csproj new file mode 100644 index 0000000..1614fe2 --- /dev/null +++ b/FichaBackend/FichaBackend.csproj @@ -0,0 +1,21 @@ + + + + net7.0 + enable + enable + Linux + + + + + + + + + + .dockerignore + + + + diff --git a/FichaBackend/Program.cs b/FichaBackend/Program.cs new file mode 100644 index 0000000..8264bac --- /dev/null +++ b/FichaBackend/Program.cs @@ -0,0 +1,25 @@ +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. + +builder.Services.AddControllers(); +// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddSwaggerGen(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.UseSwagger(); + app.UseSwaggerUI(); +} + +app.UseHttpsRedirection(); + +app.UseAuthorization(); + +app.MapControllers(); + +app.Run(); \ No newline at end of file diff --git a/FichaBackend/Properties/launchSettings.json b/FichaBackend/Properties/launchSettings.json new file mode 100644 index 0000000..a31360e --- /dev/null +++ b/FichaBackend/Properties/launchSettings.json @@ -0,0 +1,41 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:63091", + "sslPort": 44383 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5242", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7218;http://localhost:5242", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/FichaBackend/WeatherForecast.cs b/FichaBackend/WeatherForecast.cs new file mode 100644 index 0000000..40760a4 --- /dev/null +++ b/FichaBackend/WeatherForecast.cs @@ -0,0 +1,12 @@ +namespace FichaBackend; + +public class WeatherForecast +{ + public DateOnly Date { get; set; } + + public int TemperatureC { get; set; } + + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); + + public string? Summary { get; set; } +} \ No newline at end of file diff --git a/FichaBackend/appsettings.Development.json b/FichaBackend/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/FichaBackend/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/FichaBackend/appsettings.json b/FichaBackend/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/FichaBackend/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +}