我在.net 7.0中使用N层架构创建了一个项目。我的项目中还有API层和UI层。我想对我的项目进行 docker 化

问题描述 投票:0回答:1

`也就是说,在一个N层架构中,有API层和UI层的项目中,dockerfile文件应该是什么样的?

FROM mcr.microsoft.com/dotnet/sdk:7.0 as build
WORKDIR /app


COPY ./SignalR.EntityLayer/*.csproj ./SignalR.EntityLayer/
COPY ./SignalR.DataAccessLayer/*.csproj ./SignalR.DataAccessLayer/
COPY ./SignalR.BussinessLayer/*.csproj ./SignalR.BussinessLayer/
COPY ./SignalR.DtoLayer/*.csproj ./SignalR.DtoLayer/
COPY ./SignalR.Api/*.csproj ./SignalR.Api/
COPY *.sln .
RUN dotnet restore


COPY . .
RUN dotnet publish ./SignalR.Api/*.csproj -o /publish/


FROM mcr.microsoft.com/dotnet/runtime:7.0
WORKDIR /app


COPY --from=build /usr/share/dotnet /usr/share/dotnet


COPY --from=build /publish .


ENV ASPNETCORE_URLS="http://*:5000"


ENTRYPOINT ["dotnet", "SignalR.Api.dll"]

我在解决方案中创建了这样一个dockerfile。但是在创建映像时 => => 错误 [build 9/11] RUN dotnet Restore 1.7s

[build 9/11] 运行 dotnet 恢复: 0.962 /usr/share/dotnet/sdk/7.0.404/NuGet.targets(400,5):错误 MSB3202:找不到项目文件“/app/SignalR.WebUI/SignalR.WebUI.csproj”。 [/app/SignalRProject.sln]

我收到错误。尽管我包含了 WebUI 层。换句话说,在一个N层架构中,有API层和UI层的项目中,dockerfile文件应该是什么样的? `

.net docker dockerfile docker-multi-stage-build
1个回答
0
投票

我建议使用 VS 或 VS Code 中的工具为您生成 Dockerfile:
在 VS Code 中添加 Dockerfile
在 VS 中添加 Dockerfile
他们将负责创建可以处理您的项目引用的 Dockerfile。
注意:您的 API 层和 UI 层将需要不同的 Dockerfile。

额外提示: 您可以使用这两个工具中的 Compose 支持来协调启动服务 VS Code 文档 / VS 文档

© www.soinside.com 2019 - 2024. All rights reserved.