Dockerise Sprint 2 Code with bug fix

This commit is contained in:
Santhosh S
2023-08-28 01:03:24 -04:00
parent cd261a5556
commit a130aff300
38 changed files with 690 additions and 96 deletions

View File

@ -13,10 +13,13 @@ namespace DamageAssesment.Api.Surveys.Controllers
{
this.surveyProvider = surveyProvider;
}
/// <summary>
/// GET request for retrieving surveys.
/// GET request for retrieving surveys
/// </summary>
/// <remarks>
/// This endpoint retrieves surveys. You can use it to get all surveys or surveys for a specific language.
/// </remarks>
[Route("Surveys")]
[Route("{Language}/Surveys")]
[HttpGet]

View File

@ -5,6 +5,8 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
</PropertyGroup>
<ItemGroup>
@ -12,6 +14,7 @@
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.21" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.5" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
</ItemGroup>

View File

@ -0,0 +1,21 @@
#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:6.0 AS base
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["DamageAssesment.Api.Surveys/DamageAssesment.Api.Survey.csproj", "DamageAssesment.Api.Surveys/"]
RUN dotnet restore "DamageAssesment.Api.Surveys/DamageAssesment.Api.Survey.csproj"
COPY . .
WORKDIR "/src/DamageAssesment.Api.Surveys"
RUN dotnet build "DamageAssesment.Api.Survey.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "DamageAssesment.Api.Survey.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "DamageAssesment.Api.Survey.dll"]

View File

@ -6,6 +6,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.IdentityModel.Tokens;
using System.Text;
using System.Reflection;
using Microsoft.AspNetCore.Builder;
var builder = WebApplication.CreateBuilder(args);
@ -52,7 +53,7 @@ var app = builder.Build();
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
app.UseSwaggerUI(options => { options.SwaggerEndpoint("/swagger/v1/swagger.json", ""); });
}
app.UseAuthentication();

View File

@ -1,23 +1,14 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:51498",
"sslPort": 0
}
},
{
"profiles": {
"DamageAssesment.Api.Surveys": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5009",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5009"
},
"IIS Express": {
"commandName": "IISExpress",
@ -26,6 +17,21 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
"publishAllPorts": true
}
},
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:51498",
"sslPort": 0
}
}
}
}

View File

@ -54,7 +54,7 @@ namespace DamageAssesment.Api.Surveys.Providers
IEnumerable<Models.Survey> surveysList = null;
try
{
logger?.LogInformation("Gell all Surveys from DB");
logger?.LogInformation("Get all Surveys from DB");
var surveys = await surveyDbContext.Surveys.Where(s => s.IsEnabled == true).ToListAsync();
var surveyTranslations = await surveyDbContext.SurveysTranslation.ToListAsync();