feat: 初始化 Gateway 仓库
This commit is contained in:
25
Dockerfile
Normal file
25
Dockerfile
Normal file
@@ -0,0 +1,25 @@
|
||||
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
|
||||
WORKDIR /src
|
||||
|
||||
# 1. 先只复制 csproj 文件 (利用 Docker 缓存)
|
||||
COPY ["src/Gateway/TakeoutSaaS.ApiGateway/TakeoutSaaS.ApiGateway.csproj", "src/Gateway/TakeoutSaaS.ApiGateway/"]
|
||||
|
||||
# 2. 还原依赖 (如果 csproj 没变,这一步会直接使用缓存,瞬间完成)
|
||||
RUN dotnet restore "src/Gateway/TakeoutSaaS.ApiGateway/TakeoutSaaS.ApiGateway.csproj"
|
||||
|
||||
# 3. 再复制剩余的所有源代码
|
||||
COPY . .
|
||||
|
||||
# 4. 发布
|
||||
RUN dotnet publish "src/Gateway/TakeoutSaaS.ApiGateway/TakeoutSaaS.ApiGateway.csproj" -c Release -o /app/publish
|
||||
|
||||
# --- 运行时环境 ---
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:10.0
|
||||
WORKDIR /app
|
||||
COPY --from=build /app/publish .
|
||||
|
||||
# 显式声明端口
|
||||
EXPOSE 5000
|
||||
ENV ASPNETCORE_URLS=http://+:5000
|
||||
|
||||
ENTRYPOINT ["dotnet", "TakeoutSaaS.ApiGateway.dll"]
|
||||
Reference in New Issue
Block a user