后端踩坑记录
更新: 2025-03-02 16:32:41 字数: 0 字 时长: 0 分钟
1、Linux 环境下,字体不显示问题
.NET WebApi 部署到 docker 容器中,出现图形验证码显示为空的情况
解决方法:在 Dockerfile 中安装 Fontconfig
Dockerfile
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libfontconfig1 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
2、SkiaSharp 部署在 Linux 报错
The type initializer for 'SkiaSharp.SKImageInfo' threw an exception.
解决方法:需要安装支持 Linux 环境的包
xml
<ItemGroup>
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="3.116.1" />
</ItemGroup>
3、FFMpeg 在 Docker 容器中不能正常运行
解决方法:在 Dockerfile 中安装 ffmpeg
Dockerfile
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ffmpeg \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*