From f662a3f1105f5ec34b88f2d692e500b5b2c89ffd Mon Sep 17 00:00:00 2001 From: RealizmModz <74314445+RealizmModz@users.noreply.github.com> Date: Tue, 13 Oct 2026 15:21:55 -0700 Subject: [PATCH] Fix Linux OCR native loading and validate upgraded runtime during image build --- Dockerfile | 13 +++++++------ Dockerfile.web | 4 ++-- FullWorth.API/FullWorth.API.csproj | 2 +- .../FullWorth.ParserWorker.csproj | 2 +- FullWorth.ParserWorker/Program.cs | 18 ++++++++++++++++++ FullWorth.Tests/FullWorth.Tests.csproj | 2 +- FullWorth.Web/FullWorth.Web.csproj | 2 +- 7 files changed, 31 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 663767d0..cba99b2e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/sdk:10.0@sha256:35d40304542c8689331f8cab17c65926cdf48fe711e289321d71924b230a7d29 AS build +FROM mcr.microsoft.com/dotnet/sdk:10.0@sha256:e70cdb7f80b0348f5cb85f19a8f670fca061f033d57eed12fa003d58b0e06317 AS build WORKDIR /src @@ -23,7 +23,7 @@ RUN dotnet publish FullWorth.API/FullWorth.API.csproj \ --output /app/parser-worker-publish \ /p:UseAppHost=false -FROM mcr.microsoft.com/dotnet/aspnet:10.0@sha256:2d584d8147faddb0d678c5748d47953e5b8e18621ed4fb7049a91381d9d7746f AS parser-worker-final +FROM mcr.microsoft.com/dotnet/aspnet:10.0@sha256:222759b391a1aaf241166672c8f99b2d4ada452e7b5319f3c6e8f265a37b5ad4 AS parser-worker-final ARG BILLWATCH_RELEASE_ID=unknown @@ -54,12 +54,13 @@ RUN chmod 0755 /usr/local/bin/fullworth-parser-worker-entrypoint \ && test -n "$english_model" \ && test -n "$leptonica_library" \ && test -n "$tesseract_library" \ - && ln --symbolic "$leptonica_library" /app/x64/libleptonica-1.83.1.dll.so \ - && ln --symbolic "$tesseract_library" /app/x64/libtesseract53.dll.so \ + && ln --symbolic "$leptonica_library" /app/x64/libleptonica-1.85.0.dll.so \ + && ln --symbolic "$tesseract_library" /app/x64/libtesseract55.dll.so \ && ln --symbolic --force "$english_model" /app/tessdata/eng.traineddata \ && chown --recursive "$APP_UID:$APP_UID" \ /app \ - /var/run/fullworth-parser-tls + /var/run/fullworth-parser-tls \ + && dotnet FullWorth.ParserWorker.dll --ocr-native-self-test ENV ASPNETCORE_HTTP_PORTS=8081 \ DOTNET_EnableDiagnostics=0 @@ -71,7 +72,7 @@ HEALTHCHECK NONE ENTRYPOINT ["/usr/local/bin/fullworth-parser-worker-entrypoint"] CMD ["dotnet", "FullWorth.ParserWorker.dll"] -FROM mcr.microsoft.com/dotnet/aspnet:10.0@sha256:2d584d8147faddb0d678c5748d47953e5b8e18621ed4fb7049a91381d9d7746f AS final +FROM mcr.microsoft.com/dotnet/aspnet:10.0@sha256:222759b391a1aaf241166672c8f99b2d4ada452e7b5319f3c6e8f265a37b5ad4 AS final ARG BILLWATCH_RELEASE_ID=unknown diff --git a/Dockerfile.web b/Dockerfile.web index e89043a4..d568e755 100644 --- a/Dockerfile.web +++ b/Dockerfile.web @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/sdk:10.0@sha256:35d40304542c8689331f8cab17c65926cdf48fe711e289321d71924b230a7d29 AS build +FROM mcr.microsoft.com/dotnet/sdk:10.0@sha256:e70cdb7f80b0348f5cb85f19a8f670fca061f033d57eed12fa003d58b0e06317 AS build WORKDIR /src @@ -15,7 +15,7 @@ RUN dotnet publish FullWorth.Web/FullWorth.Web.csproj \ --output /app/publish \ /p:UseAppHost=false -FROM mcr.microsoft.com/dotnet/aspnet:10.0@sha256:2d584d8147faddb0d678c5748d47953e5b8e18621ed4fb7049a91381d9d7746f AS final +FROM mcr.microsoft.com/dotnet/aspnet:10.0@sha256:222759b391a1aaf241166672c8f99b2d4ada452e7b5319f3c6e8f265a37b5ad4 AS final ARG BILLWATCH_RELEASE_ID=unknown diff --git a/FullWorth.API/FullWorth.API.csproj b/FullWorth.API/FullWorth.API.csproj index b44983e1..2691a136 100644 --- a/FullWorth.API/FullWorth.API.csproj +++ b/FullWorth.API/FullWorth.API.csproj @@ -30,7 +30,7 @@ - + diff --git a/FullWorth.ParserWorker/FullWorth.ParserWorker.csproj b/FullWorth.ParserWorker/FullWorth.ParserWorker.csproj index f56506e2..76c81f80 100644 --- a/FullWorth.ParserWorker/FullWorth.ParserWorker.csproj +++ b/FullWorth.ParserWorker/FullWorth.ParserWorker.csproj @@ -6,7 +6,7 @@ - + diff --git a/FullWorth.ParserWorker/Program.cs b/FullWorth.ParserWorker/Program.cs index 3750883a..a06d7e95 100644 --- a/FullWorth.ParserWorker/Program.cs +++ b/FullWorth.ParserWorker/Program.cs @@ -13,6 +13,24 @@ Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping }; +// Build-time probe uses only the fixed synthetic image, never a supplied document. +// The production readiness probe still exercises the contained child-process path. +if (args.Length == 1 && args[0] == "--ocr-native-self-test") +{ + using var input = new MemoryStream(OcrRuntimeProbe.ImageBytes, writable: false); + var result = TesseractBillStatementOcrEngine.RunImageWorker( + input, + "image/png", + Path.Combine(AppContext.BaseDirectory, "tessdata")); + var healthy = OcrRuntimeProbe.IsHealthy(result); + var message = healthy + ? "OCR native runtime self-test passed." + : "OCR native runtime self-test failed."; + await (healthy ? Console.Out : Console.Error).WriteLineAsync(message); + Environment.ExitCode = healthy ? 0 : 70; + return; +} + if (args.Length == 1 && args[0] == "--containment-memory-child") { /* diff --git a/FullWorth.Tests/FullWorth.Tests.csproj b/FullWorth.Tests/FullWorth.Tests.csproj index 71a27def..3c803a64 100644 --- a/FullWorth.Tests/FullWorth.Tests.csproj +++ b/FullWorth.Tests/FullWorth.Tests.csproj @@ -23,7 +23,7 @@ + Version="18.11.0" /> - +