2026-03-06 20:30:18 +08:00

63 lines
2.2 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 请参阅 https://aka.ms/customizecontainer 以了解如何自定义调试容器,以及 Visual Studio 如何使用此 Dockerfile 生成映像以更快地进行调试。
# 此阶段用于在快速模式(默认为调试配置)下从 VS 运行时
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base
#修改apt-get源,加速apt下载
RUN sed -i s@/deb.debian.org/@/mirrors.163.com/@g /etc/apt/sources.list.d/debian.sources
#RUN cat /etc/apt/sources.list
# 第一步:清理并更新apt缓存
RUN apt-get clean
RUN apt-get update -y
# 第二步:单独安装fontconfig(字体配置工具)
RUN apt-get install -y --no-install-recommends fontconfig
# 第三步:单独安装文泉驿微米黑字体
RUN apt-get install -y --no-install-recommends fonts-wqy-microhei
# 第四步:单独安装文泉驿正黑字体(备用)
RUN apt-get install -y --no-install-recommends fonts-wqy-zenhei
# 第五步:刷新字体缓存(关键,确保系统识别新字体)
RUN fc-cache -fv
# 清理apt缓存,减小镜像体积
RUN apt-get clean
RUN rm -rf /var/lib/apt/lists/*
USER $APP_UID
WORKDIR /app
EXPOSE 8066
EXPOSE 443
# 此阶段用于生成服务项目
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["YD_Event.Web.Entry/YD_Event.Web.Entry.csproj", "YD_Event.Web.Entry/"]
COPY ["YD_Event.Web.Core/YD_Event.Web.Core.csproj", "YD_Event.Web.Core/"]
COPY ["YD_Event.Application/YD_Event.Application.csproj", "YD_Event.Application/"]
COPY ["YD_Event.Core/YD_Event.Core.csproj", "YD_Event.Core/"]
RUN dotnet restore "./YD_Event.Web.Entry/YD_Event.Web.Entry.csproj"
COPY . .
WORKDIR "/src/YD_Event.Web.Entry"
RUN dotnet build "./YD_Event.Web.Entry.csproj" -c $BUILD_CONFIGURATION -o /app/build
# 此阶段用于发布要复制到最终阶段的服务项目
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./YD_Event.Web.Entry.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
# 此阶段在生产中使用,或在常规模式下从 VS 运行时使用(在不使用调试配置时为默认值)
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
# 设置时区
ENV TZ=Asia/Shanghai
ENV ASPNETCORE_URLS 'http://*:8066'
ENTRYPOINT ["dotnet", "YD_Event.Web.Entry.dll"]