ql_apimanager_backend/Apimanager_backend/Dockerfile

24 lines
655 B
Docker
Raw Permalink 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.

# 使用微软官方的 .NET 8.0 SDK 镜像作为构建阶段
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /app
# 复制项目文件并还原依赖
COPY *.csproj ./
RUN dotnet restore
# 复制项目所有文件并发布(发布到 /app/publish
COPY . ./
RUN dotnet publish -c Release -o /app/publish
# 使用更小的运行时镜像运行发布的应用
FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
COPY --from=build /app/publish ./
# 设置环境变量为 Development
ENV ASPNETCORE_ENVIRONMENT=Development
# 声明容器将监听端口
EXPOSE 8080
# 容器启动时执行应用
ENTRYPOINT ["dotnet", "Apimanager_backend.dll"]