This commit is contained in:
wanghu
2026-09-02 10:23:24 +08:00
parent 5a414b14d2
commit ce436cbb32
117 changed files with 13768 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
# ============ 多阶段构建:.NET 5.0 ============
# 构建阶段
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
# 复制解决方案与全部项目文件(利用层缓存)
COPY YHDocPrintCore.sln* ./
COPY src/*/*.csproj ./
RUN for f in src/*/*.csproj; do \
mkdir -p "$(dirname "$f")" && mv "$f" "$(dirname "$f")/"; \
done \
&& dotnet restore YHDocPrintCore.sln
# 复制源码并发布
COPY src/ src/
RUN dotnet publish src/YHDocPrintCore.WebApi/YHDocPrintCore.WebApi.csproj \
-c Release -o /app/publish --no-restore
# 运行阶段
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS runtime
WORKDIR /app
COPY --from=build /app/publish .
# 日志目录(接口访问日志唯一输出,挂载卷便于采集)
RUN mkdir -p /app/logs
VOLUME ["/app/logs"]
EXPOSE 80
ENV ASPNETCORE_URLS=http://+:80
# 生产配置通过环境变量注入(ConnectionStrings__SqlServer / Redis:ConnectionString 等)
ENTRYPOINT ["dotnet", "YHDocPrintCore.WebApi.dll"]