forked from MDCPS/DamageAssessment_Backend
		
	Dockerise Sprint 2 Code with bug fix
This commit is contained in:
		| @ -1,10 +1,12 @@ | ||||
| <Project Sdk="Microsoft.NET.Sdk.Web"> | ||||
| <Project Sdk="Microsoft.NET.Sdk.Web"> | ||||
|  | ||||
|   <PropertyGroup> | ||||
|     <TargetFramework>net6.0</TargetFramework> | ||||
|     <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.9" /> | ||||
|     <PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.9" /> | ||||
|     <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" /> | ||||
|     <PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" /> | ||||
|   </ItemGroup> | ||||
|  | ||||
|  | ||||
							
								
								
									
										21
									
								
								DamageAssesmentApi/DamageAssesment.Api.Answers/Dockerfile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								DamageAssesmentApi/DamageAssesment.Api.Answers/Dockerfile
									
									
									
									
									
										Normal 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.Answers/DamageAssesment.Api.Answers.csproj", "DamageAssesment.Api.Answers/"] | ||||
| RUN dotnet restore "DamageAssesment.Api.Answers/DamageAssesment.Api.Answers.csproj" | ||||
| COPY . . | ||||
| WORKDIR "/src/DamageAssesment.Api.Answers" | ||||
| RUN dotnet build "DamageAssesment.Api.Answers.csproj" -c Release -o /app/build | ||||
|  | ||||
| FROM build AS publish | ||||
| RUN dotnet publish "DamageAssesment.Api.Answers.csproj" -c Release -o /app/publish /p:UseAppHost=false | ||||
|  | ||||
| FROM base AS final | ||||
| WORKDIR /app | ||||
| COPY --from=publish /app/publish . | ||||
| ENTRYPOINT ["dotnet", "DamageAssesment.Api.Answers.dll"] | ||||
| @ -2,6 +2,8 @@ using DamageAssesment.Api.Answers.Db; | ||||
| using DamageAssesment.Api.Answers.Interfaces; | ||||
| using DamageAssesment.Api.Answers.Providers; | ||||
| using Microsoft.EntityFrameworkCore; | ||||
| using Microsoft.Extensions.Options; | ||||
| using Microsoft.OpenApi.Models; | ||||
| using System.Reflection; | ||||
|  | ||||
| var builder = WebApplication.CreateBuilder(args); | ||||
| @ -14,10 +16,13 @@ builder.Services.AddEndpointsApiExplorer(); | ||||
| //builder.Services.AddSwaggerGen(); | ||||
| builder.Services.AddSwaggerGen(c => | ||||
| { | ||||
|    | ||||
|     // Include XML comments from your assembly | ||||
|     var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; | ||||
|     var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); | ||||
|     c.IncludeXmlComments(xmlPath); | ||||
|    | ||||
|  | ||||
| }); | ||||
| builder.Services.AddScoped<IAnswersProvider, AnswersProvider>(); | ||||
| builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); //4/30 | ||||
| @ -31,7 +36,11 @@ var app = builder.Build(); | ||||
| if (app.Environment.IsDevelopment()) | ||||
| { | ||||
|     app.UseSwagger(); | ||||
|     app.UseSwaggerUI(); | ||||
|     app.UseSwaggerUI(options => | ||||
|     { | ||||
|         options.SwaggerEndpoint("/swagger/v1/swagger.json","" ); | ||||
|        // options.RoutePrefix = "";  // Serve Swagger UI at the root URL | ||||
|     }); | ||||
| } | ||||
|  | ||||
| app.UseAuthorization(); | ||||
|  | ||||
		Reference in New Issue
	
	Block a user