diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..fe1152b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,30 @@ +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*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 +!**/.gitignore +!.git/HEAD +!.git/config +!.git/packed-refs +!.git/refs/heads/** \ No newline at end of file diff --git a/HiVakil.Api/Dockerfile b/HiVakil.Api/Dockerfile new file mode 100644 index 0000000..5b5da9b --- /dev/null +++ b/HiVakil.Api/Dockerfile @@ -0,0 +1,24 @@ +#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. + +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +USER app +WORKDIR /app +EXPOSE 8080 + +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +ARG BUILD_CONFIGURATION=Release +WORKDIR /src +COPY ["HiVakil.Api/HiVakil.Api.csproj", "HiVakil.Api/"] +RUN dotnet restore "./HiVakil.Api/./HiVakil.Api.csproj" +COPY . . +WORKDIR "/src/HiVakil.Api" +RUN dotnet build "./HiVakil.Api.csproj" -c $BUILD_CONFIGURATION -o /app/build + +FROM build AS publish +ARG BUILD_CONFIGURATION=Release +RUN dotnet publish "./HiVakil.Api.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "HiVakil.Api.dll"] \ No newline at end of file diff --git a/HiVakil.Api/HiVakil.Api.csproj b/HiVakil.Api/HiVakil.Api.csproj new file mode 100644 index 0000000..eaef27d --- /dev/null +++ b/HiVakil.Api/HiVakil.Api.csproj @@ -0,0 +1,17 @@ + + + + net8.0 + enable + enable + true + Linux + + + + + + + + + diff --git a/HiVakil.Api/HiVakil.Api.http b/HiVakil.Api/HiVakil.Api.http new file mode 100644 index 0000000..42896c6 --- /dev/null +++ b/HiVakil.Api/HiVakil.Api.http @@ -0,0 +1,6 @@ +@HiVakil.Api_HostAddress = http://localhost:5090 + +GET {{HiVakil.Api_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/HiVakil.Api/Program.cs b/HiVakil.Api/Program.cs new file mode 100644 index 0000000..284b700 --- /dev/null +++ b/HiVakil.Api/Program.cs @@ -0,0 +1,42 @@ +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. +// 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(); +} + +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") +.WithOpenApi(); + +app.Run(); + +internal record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary) +{ + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); +} diff --git a/HiVakil.Api/Properties/launchSettings.json b/HiVakil.Api/Properties/launchSettings.json new file mode 100644 index 0000000..8594a8f --- /dev/null +++ b/HiVakil.Api/Properties/launchSettings.json @@ -0,0 +1,40 @@ +{ + "profiles": { + "http": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "dotnetRunMessages": true, + "applicationUrl": "http://localhost:5090" + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Docker": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger", + "environmentVariables": { + "ASPNETCORE_HTTP_PORTS": "8080" + }, + "publishAllPorts": true + } + }, + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:27137", + "sslPort": 0 + } + } +} \ No newline at end of file diff --git a/HiVakil.Api/appsettings.Development.json b/HiVakil.Api/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/HiVakil.Api/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/HiVakil.Api/appsettings.json b/HiVakil.Api/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/HiVakil.Api/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/HiVakil.sln b/HiVakil.sln new file mode 100644 index 0000000..4ce751f --- /dev/null +++ b/HiVakil.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34316.72 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HiVakil.Api", "HiVakil.Api\HiVakil.Api.csproj", "{E38E9183-01E9-4481-A770-68EAD4AD89C0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E38E9183-01E9-4481-A770-68EAD4AD89C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E38E9183-01E9-4481-A770-68EAD4AD89C0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E38E9183-01E9-4481-A770-68EAD4AD89C0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E38E9183-01E9-4481-A770-68EAD4AD89C0}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A102579B-8A98-4047-B6E9-D4EA782C3B84} + EndGlobalSection +EndGlobal