Skip to content

Docker Deployment

Peter Gill edited this page Jun 8, 2026 · 2 revisions

Docker Deployment

Majorsilence Reporting v5 runs on Linux inside Docker. The main requirement is that the SkiaSharp native library and a set of TrueType fonts are present in the image. This page covers production-ready Dockerfiles for both glibc-based and Alpine images.

glibc-based image (Debian / Ubuntu)

The standard mcr.microsoft.com/dotnet/aspnet image is Debian-based and includes glibc, which SkiaSharp requires.

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY . .
RUN dotnet publish -c Release -o /app/publish

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS final
WORKDIR /app

# Install fonts — pick one approach:

# Option A: Microsoft core fonts (Arial, Times New Roman, Courier New, etc.)
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        ttf-mscorefonts-installer \
        fontconfig && \
    apt-get clean && rm -rf /var/lib/apt/lists/* && \
    fc-cache -fv

# Option B: Liberation fonts (metric-compatible open-source replacements)
# RUN apt-get update && \
#     apt-get install -y --no-install-recommends \
#         fonts-liberation \
#         fontconfig && \
#     apt-get clean && rm -rf /var/lib/apt/lists/* && \
#     fc-cache -fv

COPY --from=build /app/publish .

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

Alpine image

Alpine uses musl libc. SkiaSharp ships a separate musl build; install Majorsilence.Reporting.RdlEngine.SkiaSharp (the .SkiaSharp NuGet variant) and add the runtime dependencies.

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY . .
RUN dotnet publish -c Release -o /app/publish

FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS final
WORKDIR /app

# SkiaSharp on Alpine requires these native packages
RUN apk add --no-cache \
    fontconfig \
    freetype \
    harfbuzz \
    ttf-dejavu

COPY --from=build /app/publish .

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

Alpine images are smaller but SkiaSharp's musl support may lag behind glibc releases. If you encounter rendering issues, switch to the Debian-based image.

Verifying fonts inside the container

After building, run the container interactively to confirm fonts are found:

docker run --rm -it myreportapp fc-list | sort

If fc-list returns an empty list or is missing, fontconfig was not installed or fc-cache was not run.

NuGet packages for Linux

Add the SkiaSharp variant packages in your project file. These include the native SkiaSharp binaries for Linux:

<PackageReference Include="Majorsilence.Reporting.RdlEngine.SkiaSharp" Version="*" />
<PackageReference Include="Majorsilence.Reporting.RdlCri.SkiaSharp" Version="*" />

Or via the CLI:

dotnet add package Majorsilence.Reporting.RdlEngine.SkiaSharp
dotnet add package Majorsilence.Reporting.RdlCri.SkiaSharp

Initialising the engine

Call RdlEngineConfigInit() once at application startup — in Program.cs before app.Run() for ASP.NET Core:

// Program.cs
RdlEngineConfig.RdlEngineConfigInit();

var builder = WebApplication.CreateBuilder(args);
// ...
var app = builder.Build();
app.Run();

Generating a report in a container

The standard no-GUI pattern works without modification inside Docker:

var rdlp = new RDLParser(await File.ReadAllTextAsync("/reports/sales.rdl"))
{
    Folder = "/reports"
};
using var report = await rdlp.Parse();
await report.RunGetData(null);

using var ms = new MemoryStreamGen();
await report.RunRender(ms, OutputPresentationType.PDF);
var pdf = ((MemoryStream)ms.GetStream()).ToArray();

See Streaming PDF in ASP.NET Core for the full HTTP response pattern.

Environment variables

If you keep report files outside the container (e.g. mounted volumes or object storage), pass the report directory via an environment variable:

ENV REPORTS_PATH=/mnt/reports
var reportsPath = Environment.GetEnvironmentVariable("REPORTS_PATH") ?? "/reports";

Troubleshooting

Symptom Likely cause Fix
Blank PDF / missing text No fonts installed Install fonts-liberation or ttf-mscorefonts-installer and run fc-cache -fv
DllNotFoundException: libSkiaSharp Wrong SkiaSharp variant Use .SkiaSharp NuGet packages; ensure linux-x64 or linux-musl-x64 RID is included
Unable to load shared library 'libfontconfig' fontconfig missing Install fontconfig (Debian) or fontconfig (Alpine)
Fonts present but wrong glyph rendering Font substitution Install the exact font the report was designed with

See Linux — Fonts and SkiaSharp setup for font installation details outside Docker.

Clone this wiki locally