30 lines
982 B
Docker
Raw Normal View History

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