The document doesn’t process an image, it shows nothing instead of an image. I have tried adding fontconfig and harfbuzz as well but it doesn’t seem to work. I have also added SkiaSharp for the Alpine but it doesn’t seem to work.
FROM mcr.microsoft.com/dotnet/sdk:6.0.402-alpine3.16-amd64 AS base
RUN apk update && apk upgrade && apk add fontconfig && apk add harfbuzz
dotnet add package StoneCold.SkiaSharp.NativeAssets.AlpineLinux --version 2.88.3
@datfcfmt You might encounter the same problem as described here:
https://docs.microsoft.com/en-us/answers/questions/728280/running-net-6-project-in-docker-throws-globalizati.html
To resolve the problem you need to install the following packages:
# Requred to make code works on 6.0-alpine3.15. See https://docs.microsoft.com/en-us/answers/questions/728280/running-net-6-project-in-docker-throws-globalizati.html
RUN apk add --no-cache icu-libs krb5-libs libgcc libintl libssl1.1 libstdc++ zlib
Here is my working Dokerfile for Alpine Linux:
FROM mcr.microsoft.com/dotnet/runtime:6.0-alpine3.15 AS base
WORKDIR /app
# Required to make SkiaSharp 2.80.1 work. If use 2.80.3 SkiaSharp.NativeAssets.Linux.NoDependencies it is not required.
#RUN apk add --no-cache fontconfig
# Requred to make code works on 6.0-alpine3.15. See https://docs.microsoft.com/en-us/answers/questions/728280/running-net-6-project-in-docker-throws-globalizati.html
RUN apk add --no-cache icu-libs krb5-libs libgcc libintl libssl1.1 libstdc++ zlib
# For debug purposes.
RUN apk add --no-cache bash
# Add the missed ld-linux-x86-64.so.2 dependency.
RUN apk add --no-cache gcompat
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["TestNet6.csproj", "."]
RUN dotnet restore "./TestNet6.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "TestNet6.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "TestNet6.csproj" -c Release -r linux-x64 --no-self-contained -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "TestNet6.dll"]
Also, please note that Aspose.Words for .NET6 or .NET Standard uses SkiaShap to deal with graphics. To make it work on Linux you should install SkiaSharp Linux native assets. Here is dependencies:
<PackageReference Include="Aspose.Words" Version="22.7.0" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="2.80.3" />
Note, I have used 2.80.3
version of SkiaSharp.NativeAssets
because there was a mistake in NoDependencies package in 2.80.1
and it still requires fontconfig
package (See comments in Dockerfile).