Docker映像创建-Net Core 3.1 Web API-具有多个项目的单个解决方案 [英] Docker image creation - Net core 3.1 web API - Single solution with multiple projects
问题描述
我已经在.net core 3.1中使用docker文件创建了Web api,并包含了DAL项目.DAL项目对于所有API都是通用的.这是我的项目结构
I have created web api in .net core 3.1 with docker file and include the DAL project. DAL project is common for all API. This is my project structure
--Solution
dockerfile
--DAL Project
这是我的docker文件格式
This is my docker file format
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /src
COPY ["Notification.csproj", ""]
COPY ["../DAL/DAL.csproj", "../DAL/"]
RUN dotnet restore "./Notification.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "Notification.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Notification.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Notification.dll"]
在构建应用程序VS Code时,出现以下错误
While build the application VS Code I got below error
复制失败:无法解析范围路径.. \ DAL_DAL.csproj():evalSymlinksInScope:\?\ C:\ ProgramData \ Docker \ tmp \ DAL \ DAL.csproj不在\?\ C:\ ProgramData \Docker \ tmp \ docker-builder572417841.可能的原因是在构建上下文之外有一条禁止的路径
COPY failed: failed to resolve scoped path ..\DAL_DAL.csproj (): evalSymlinksInScope: \?\C:\ProgramData\Docker\tmp\DAL\DAL.csproj is not in \?\C:\ProgramData\Docker\tmp\docker-builder572417841. Possible cause is a forbidden path outside the build context
任何帮助将不胜感激.
推荐答案
这是我的项目结构;
这是我在SampleApp.API中的Dockerfile;
And this is my Dockerfile in SampleApp.API;
也许可以为您举例.
这篇关于Docker映像创建-Net Core 3.1 Web API-具有多个项目的单个解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!