Net core project and I have many webapi, business layer and some other layers here. Below is the folder stucture.
Main Solution
- businessLayer
- data layer
- Web API layer 3.1 MyDockerFile
Below is my docker file.
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env
WORKDIR /app
COPY ["Enrichment.WebApi/Enrichment.WebApi.csproj", "Enrichment.WebApi/"]
COPY ["Enrichment.Facade/Enrichment.Facade.csproj", "Enrichment.Facade/"]
COPY ["Enrichment.Saga/Enrichment.Saga.csproj", "Enrichment.Saga/"]
COPY ["Enrichment.BusinessModel/Enrichment.BusinessModel.csproj", "Enrichment.BusinessModel/"]
RUN dotnet restore "Enrichment.WebApi/Enrichment.WebApi.csproj"
COPY *.csproj ./
RUN dotnet restore
# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out
# Build runtime image
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "Enrichment.WebApi.dll"]
When I run docker build -t enrichment.webapi . I get below output
Sending build context to Docker daemon 230.8MB
Step 1/16 : FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env
---> 9a88f73dec65
Step 2/16 : WORKDIR /app
---> Using cache
---> 9b50f1fc6721
Step 3/16 : COPY ["Enrichment.WebApi/Enrichment.WebApi.csproj", "Enrichment.WebApi/"]
COPY failed: stat /var/lib/docker/tmp/docker-builder437963979/Enrichment.WebApi/Enrichment.WebApi.csproj: no such file or directory
I am not able to understand why I am getting above error. Path looks like incorrect but I am not able to understand what would be the right path. can someone help me to understand any issue here. Any help would be appreciated. Thank you.
Step 9/16 : COPY *.csproj ./ COPY failed: no source files were specified
This is because of .dockerignore
file that ignores the csproj
. Notice the content of .dockerignore
below and Anything other than obj/Docker/publish/*
and obj/Docker/empty
is ignored.
*
!obj/Docker/publish/*
!obj/Docker/empty/
Incude this in your dockerfile
# build runtime image
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
WORKDIR /app
COPY --from=build-env /app/out ./
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.