简体   繁体   中英

Docker image creation - Net core 3.1 web API - Single solution with multiple projects

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

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"] 

While build the application VS Code I got below error

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

Any help would be appreciated.

this is my project structure;

项目结构

And this is my Dockerfile in SampleApp.API;

Dockerfile

Maybe it can be an example for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM