OpenAuth.Net/Dockerfile

47 lines
1.4 KiB
Docker
Raw Permalink Normal View History

2024-11-28 20:57:15 +08:00
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
2024-11-16 10:38:24 +08:00
WORKDIR /app
# WebApi
2024-11-27 21:44:35 +08:00
EXPOSE 52789
# Mvc
EXPOSE 1802
# Identity
EXPOSE 12796
2024-11-16 10:38:24 +08:00
2024-11-28 20:57:15 +08:00
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
2024-11-16 10:38:24 +08:00
WORKDIR /src
# 将当前目录下的所有文件和文件夹复制到容器的当前工作目录中
COPY *.sln ./
COPY ["OpenAuth.WebApi/", "./OpenAuth.WebApi/"]
2024-11-27 21:44:35 +08:00
COPY ["OpenAuth.Mvc/", "./OpenAuth.Mvc/"]
COPY ["OpenAuth.Identity/", "./OpenAuth.Identity/"]
2024-11-16 10:38:24 +08:00
COPY ["Infrastructure/", "./Infrastructure/"]
COPY ["OpenAuth.App/", "./OpenAuth.App/"]
COPY ["OpenAuth.Repository/", "./OpenAuth.Repository/"]
2024-11-16 11:39:18 +08:00
2024-11-27 21:44:35 +08:00
RUN dotnet restore OpenAuth.Net.sln
2024-11-16 10:38:24 +08:00
# 发布 WebApi
2024-11-16 10:38:24 +08:00
WORKDIR "/src/OpenAuth.WebApi"
RUN dotnet publish -c Release -o /app/publish/webapi
2024-11-16 10:38:24 +08:00
# 发布 Mvc
WORKDIR "/src/OpenAuth.Mvc"
RUN dotnet publish -c Release -o /app/publish/mvc
# 发布 Identity
WORKDIR "/src/OpenAuth.Identity"
RUN dotnet publish -c Release -o /app/publish/identity
2024-11-16 10:38:24 +08:00
FROM base AS final
WORKDIR /app
# 复制 WebApi 发布文件
COPY --from=build /app/publish/webapi ./webapi
# 复制 Mvc 发布文件
COPY --from=build /app/publish/mvc ./mvc
# 复制 Identity 发布文件
COPY --from=build /app/publish/identity ./identity
# 启动 WebApi, Mvc, 和 Identity,就算失败也保持运行,方便查询日志
ENTRYPOINT ["sh", "-c", "cd webapi && dotnet OpenAuth.WebApi.dll & cd mvc && dotnet OpenAuth.Mvc.dll & cd identity && dotnet OpenAuth.IdentityServer.dll || tail -f /dev/null"]
2024-11-27 21:44:35 +08:00