REST Service under docker doesn't work

1 Answer 168 Views
General Discussions Report Viewer - HTML5 Rest Service
Jakub
Top achievements
Rank 1
Iron
Jakub asked on 09 Oct 2023, 09:06 AM | edited on 09 Oct 2023, 09:07 AM

Hello,

I'm trying to run Reporting REST service with docker under Linux environment. I'm using the .NET 6. In my separate Report Viewer application, I see the following error:

Unable to get report parameters. An error has occurred. Type: Telerik.Reporting.ReportSerialization.Current.ReportSerializable`1[Telerik.Reporting.Report]

This is a sample code from my Report Viewer application:

import { TelerikReportViewer } from '@progress/telerik-react-report-viewer'

export default function ReportViewer() {
    let viewer;
    return (
        <TelerikReportViewer
            ref={ e => viewer = e }
            serviceUrl="http://localhost:32788/api/reports/"
            reportSource={{
                report: 'SampleReport.trdp',
                parameters: {}
            }}
            viewerContainerStyle = {{
                position: 'absolute',
                left: '5px',
                right: '5px',
                top: '40px',
                bottom: '5px',
                overflow: 'hidden',
                clear: 'both',
                fontFamily: 'ms sans serif'
            }}
            viewMode="INTERACTIVE"
            scaleMode="SPECIFIC"
            scale={1.0}
            enableAccessibility={false} 
        />
    )
}

And this is my Dockerfile of the REST Service application:

FROM mcr.microsoft.com/dotnet/aspnet:6.0-jammy-amd64 AS base
WORKDIR /app
EXPOSE 80

RUN apt-get update \
    && apt-get install -y --allow-unauthenticated \
        libc6-dev \
        libgdiplus \
        libx11-dev \
    && rm -rf /var/lib/apt/lists/*

FROM mcr.microsoft.com/dotnet/sdk:6.0-jammy-amd64 AS build
WORKDIR /src
RUN dotnet nuget add source https://nuget.telerik.com/v3/index.json -n Telerik -u myemail@ishere.yea -p verysecretpassword --store-password-in-clear-text
COPY ["TelerikReportingRestService/TelerikReportingRestService.csproj", "TelerikReportingRestService/"]
RUN dotnet restore "TelerikReportingRestService/TelerikReportingRestService.csproj"
COPY . .
WORKDIR "/src/TelerikReportingRestService"
RUN dotnet build "TelerikReportingRestService.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "TelerikReportingRestService.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .

COPY "TelerikReportingRestService/Reports" /app/Reports

ENTRYPOINT ["dotnet", "TelerikReportingRestService.dll"]

Everything works if I deploy it locally on IIS, however, as soon as I deploy with docker, I'm unable to view reports. I also tried to add runtimeconfig.template.json file to my project root folder with the following:

{
  "configProperties": {
    "System.Drawing.EnableUnixSupport": true
  }
}

Without any luck.

The endpoints such as /api/reports/formats and /api/reports/version works fine even with docker:

[{"name":"PDF","localizedName":"Acrobat (PDF) file"},{"name":"CSV","localizedName":"CSV (comma delimited)"},{"name":"XLSX","localizedName":"Excel Worksheet"},{"name":"PPTX","localizedName":"PowerPoint Presentation"},{"name":"RTF","localizedName":"Rich Text Format"},{"name":"IMAGE","localizedName":"TIFF file"},{"name":"DOCX","localizedName":"Word Document"}]
"17.1.23.718"

Any help is appreciated. Thanks

1 Answer, 1 is accepted

Sort by
1
Accepted
Dimitar
Telerik team
answered on 12 Oct 2023, 08:59 AM

Hello Jakub,

Thank you for the provided information about your case!

Looking at the code snippets and the Dockerfile, you have correctly installed libgdiplus and the workaround from the System.Drawing.Common is not supported on non-Windows platforms starting with .NET 6 - Telerik Reporting article also appears correctly applied. The only thing that I would suggest checking in on that matter is whether you have set the runtimeconfig.template.json file to be always copied to the output directory so that it is present in the bin directory even when the project is run inside Docker.

Apart from that, the image that you are trying to use as base is Ubuntu 22.04, correct? For this version of Ubuntu to work with reporting, in your project, you need to install a newer version of the System.Drawing.Common NuGet package than the one our packages use by default. I suggest installing version 6.0.0 of that package, or older but not older than 4.6.0.

Last but not least, yesterday we released a new version of the product - Telerik Reporting - Progress® Telerik® Reporting R3 2023 (17.2.23.1010), in which we introduced a new graphics engine option for rendering the reports based on the SkiaSharp library. It should work with .NET 6+ without having to apply any workarounds like for libgdiplus so I recommend giving it a try. You may see the Configuring the processing Element - Telerik Reporting article for details on how to switch the graphics engine.

I hope that the provided information will help. Please let me know if you need further assistance.  

Regards,
Dimitar
Progress Telerik

Stay tuned by visiting our roadmap and feedback portal pages, enjoy a smooth take-off with our Getting Started resources, or visit the free self-paced technical training at https://learn.telerik.com/.
Jakub
Top achievements
Rank 1
Iron
commented on 12 Oct 2023, 09:12 AM

Hello Dimitar,

Yes, I've also made sure that the runtimeconfig.template.json is always copied to the output directory.

I've updated the System.Drawing.Common NuGet package to version 6.0.0 and now it works!

Thanks a lot for your help!

Tags
General Discussions Report Viewer - HTML5 Rest Service
Asked by
Jakub
Top achievements
Rank 1
Iron
Answers by
Dimitar
Telerik team
Share this question
or