2 Commits

Author SHA1 Message Date
17f4a7930e Added Dockerfile and docker ignore file 2025-12-31 16:07:13 +03:30
d4e065f188 Upgraded pdf-service to .net 10 2025-12-31 16:06:54 +03:30
6 changed files with 43 additions and 38 deletions

25
.dockerignore Normal file
View File

@@ -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

11
PdfService/Dockerfile Normal file
View File

@@ -0,0 +1,11 @@
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
COPY . .
RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages \
dotnet publish --self-contained false -o /app
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS final
WORKDIR /app
COPY --from=build /app .
ENTRYPOINT ["dotnet", "PdfService.dll"]

View File

@@ -1,24 +0,0 @@
namespace PdfService;
public class ExceptionHandlerMiddleware
{
private readonly RequestDelegate _next;
public ExceptionHandlerMiddleware(RequestDelegate next)
{
_next = next;
}
public async Task InvokeAsync(HttpContext context)
{
try
{
await _next(context);
}
catch (Exception ex)
{
SentrySdk.CaptureException(ex);
throw;
}
}
}

View File

@@ -1,16 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="dotenv.net" Version="4.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Sentry" Version="6.0.0" />
<PackageReference Include="Stimulsoft.Reports.Engine.NetCore" Version="2025.2.3" /> <PackageReference Include="Stimulsoft.Reports.Engine.NetCore" Version="2025.2.3" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Content Include="..\.dockerignore">
<Link>.dockerignore</Link>
</Content>
</ItemGroup>
</Project> </Project>

View File

@@ -1,21 +1,11 @@
using System.Data; using System.Data;
using dotenv.net;
using Microsoft.AspNetCore.WebUtilities; using Microsoft.AspNetCore.WebUtilities;
using Newtonsoft.Json; using Newtonsoft.Json;
using PdfService; using PdfService;
DotEnv.Load();
SentrySdk.Init(options =>
{
options.Dsn = Environment.GetEnvironmentVariable("SENTRY_DSN");
});
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
var app = builder.Build(); var app = builder.Build();
app.UseMiddleware<ExceptionHandlerMiddleware>();
app.MapPost("/Print", async (HttpContext context) => app.MapPost("/Print", async (HttpContext context) =>
{ {
var request = context.Request; var request = context.Request;

View File

@@ -1 +0,0 @@
SENTRY_DSN=https://d3fd87d14e555556d3f76e42d94a63a0@sentry.rayvarz.center/10