30 lines
1.0 KiB
Docker
Raw Normal View History

2026-05-06 13:56:24 +08:00
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
# 设置时区环境变量并创建软链接
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# 构建阶段
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
2026-05-06 14:09:02 +08:00
COPY ["YD_PT_WeChatApplet/YD_PT_WeChatApplet.Api.csproj", "WeChatApplet/"]
COPY ["YD_PT_WeChatApplet.Commons/YD_PT_WeChatApplet.Commons.csproj", "YD_PT_WeChatApplet.Commons/"]
RUN dotnet restore "./YD_PT_WeChatApplet/YD_PT_WeChatApplet.Api.csproj"
2026-05-06 13:56:24 +08:00
COPY . .
2026-05-06 14:15:48 +08:00
WORKDIR "/src/YD_PT_WeChatApplet"
2026-05-06 14:09:02 +08:00
RUN dotnet build "./YD_PT_WeChatApplet.Api.csproj" -c $BUILD_CONFIGURATION -o /app/build
2026-05-06 13:56:24 +08:00
# 发布阶段
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
2026-05-06 14:09:02 +08:00
RUN dotnet publish "./YD_PT_WeChatApplet.Api.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
2026-05-06 13:56:24 +08:00
# 运行阶段
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
2026-05-06 14:09:02 +08:00
ENTRYPOINT ["dotnet", "YD_PT_WeChatApplet.Api.dll"]