This commit is contained in:
zpc 2026-03-18 00:56:17 +08:00
parent 79f313ddf5
commit 2c7693c4e3
2 changed files with 10 additions and 1 deletions

View File

@ -39,4 +39,11 @@ RUN dotnet publish MiAssessment.Api.csproj -c $BUILD_CONFIGURATION -o /app/publi
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
# 创建 PDF 输出目录和静态图片目录,并赋予写入权限
USER root
RUN mkdir -p /app/wwwroot/reports /app/wwwroot/images/report \
&& chown -R $APP_UID:$APP_UID /app/wwwroot/reports /app/wwwroot/images/report
USER $APP_UID
ENTRYPOINT ["dotnet", "MiAssessment.Api.dll"]

View File

@ -205,7 +205,9 @@ public class PdfGenerationService : IPdfGenerationService
return null;
}
var imagePath = Path.Combine("wwwroot", "images", "static-pages", config.ImageUrl);
// 去掉前导斜杠,避免 Path.Combine 在 Linux 上将其视为绝对路径
var relativePath = config.ImageUrl.TrimStart('/');
var imagePath = Path.Combine("wwwroot", relativePath);
if (!File.Exists(imagePath))
{
_logger.LogWarning("静态图片文件不存在,跳过页面: {PageName},路径: {ImagePath}",