Docker File - Skipping Project. Because it was not found
In my case the project file was not found because i was building a linux container, and for some reason, the project filename and it's path had different letter case then in the filesystem.
Based on your input I propose below folder structure and Dockerfile.
[Solution] 'BuySellApi' (3 Projects)
|
+-- Dockerfile
|
+-- [BuySellApi]
| |
| +--- BuySellApi.csproj
|
+-- [BuySellApi.Core]
| |
| +--- BuySellApi.Core.csproj
|
+-- [BuySellApi.Data]
|
+--- BuySellApi.Data.csproj
Dockerfile
FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 5000
ENV ASPNETCORE_URLS=http://+:5000
FROM microsoft/dotnet:2.2-sdk AS build
WORKDIR /src
COPY . .
RUN dotnet restore ". BuySellApi/BuySellApi.csproj"
WORKDIR "/src/BuySellApi"
RUN dotnet build "BuySellApi.csproj" -c Release -o /app
FROM build AS publish
WORKDIR "/src/BuySellApi"
RUN dotnet publish "BuySellApi.csproj" -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "BuySellApi.dll", "--server.urls", "http://0.0.0.0:5000"]
As suggested by @Mihai
I moved my Dockerfile directly under solution file and made some changes to it as below:
FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 5000
ENV ASPNETCORE_URLS=http://+:5000
FROM microsoft/dotnet:2.2-sdk AS build
WORKDIR /src
COPY ["BuySellApi/BuySellApi.csproj", "BuySellApi/"]
COPY ["BuySellApi.Core/BuySellApi.Core.csproj", "BuySellApi.Core/"]
COPY ["BuySellApi.Data/BuySellApi.Data.csproj", "BuySellApi.Data/"]
RUN dotnet restore "BuySellApi/BuySellApi.csproj"
COPY . .
WORKDIR "/src/BuySellApi"
RUN dotnet build "BuySellApi.csproj" -c Release -o /app
FROM build AS publish
RUN dotnet publish "BuySellApi.csproj" -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "BuySellApi.dll", "--server.urls", "http://0.0.0.0:5000"]