I'm new to docker, so I would like to ask for help creating a Dockerfile for a .net core application. The application has the following architecture:
FarmHouse.Services.AuthenticationService
│ ├───FarmHouse.Services.AuthenticationService.Api
│ ├───FarmHouse.Services.AuthenticationService.Logic
│ └───Dockerfile
│
├───FarmHouse.Services.Common
│ └───FarmHouse.Services.Common.Models
│
└───FarmHouse.Services.EmailService
├───FarmHouse.Services.EmailService.Api
├───FarmHouse.Services.EmailService.Logic
└───Dockerfile
These three projects (FarmHouse.Services.EmailService, FarmHouse.Services.Common and FarmHouse.Services.AuthenticationService) are in the same solution and FarmHouse.Services.AuthenticationService uses objects from the Common project, i.e. FarmHouse.Services.Common is a dependency for it.
I want other services to link to Common as well. My Dockerfile for AuthenticationService looks like this:
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env
WORKDIR /app
# Copy csproj and restore as distinct layers
COPY ./*.sln .
COPY ./FarmHouse.Services.AuthenticationService/FarmHouse.Services.AuthenticationService.Logic/FarmHouse.Services.AuthenticationService.Logic.csproj ./FarmHouse.Services.AuthenticationService.Logic/FarmHouse.Services.AuthenticationService.Logic.csproj
COPY ./FarmHouse.Services.AuthenticationService/FarmHouse.Services.AuthenticationService.Api/FarmHouse.Services.AuthenticationService.Api.csproj ./FarmHouse.Services.AuthenticationService.Api/FarmHouse.Services.AuthenticationService.Api.csproj
COPY ./FarmHouse.Services.Common/FarmHouse.Services.Common.Models/FarmHouse.Services.Common.Models.csproj ./FarmHouse.Services.Common.Models/FarmHouse.Services.Common.Models.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", "FarmHouse.Services.AuthenticationService.Api.dll"]
And when I run docker build from the parent folder, I see the following errors:
>docker build -t coreapp -f ./FarmHouse.Services.AuthenticationService/Dockerfile .
#14 1.643 /usr/share/dotnet/sdk/3.1.406/NuGet.targets(282,5): error MSB3202: The project file "/app/FarmHouse.Services.AuthenticationService/FarmHouse.Services.AuthenticationService.Api/FarmHouse.Services.AuthenticationService.Api.csproj" was not found. [/app/FarmHouseServices.sln]417050dbf1abf19fd7c8a7a0eb5d56150a 0.0s
#14 1.643 /usr/share/dotnet/sdk/3.1.406/NuGet.targets(282,5): error MSB3202: The project file "/app/FarmHouse.Services.AuthenticationService/FarmHouse.Services.AuthenticationService.Logic/FarmHouse.Services.AuthenticationService.Logic.csproj" was not found. [/app/FarmHouseServices.sln] 0.0s
#14 1.643 /usr/share/dotnet/sdk/3.1.406/NuGet.targets(282,5): error MSB3202: The project file "/app/FarmHouse.Services.Common/FarmHouse.Services.Common.Models/FarmHouse.Services.Common.Models.csproj" was not found. [/app/FarmHouseServices.sln]uthenticationService/FarmHouse.Services.AuthenticationService.Api/FarmHouse.Services.AuthenticationService.Api.csproj ./FarmHous 0.0s
#14 1.643 /usr/share/dotnet/sdk/3.1.406/NuGet.targets(282,5): error MSB3202: The project file "/app/FarmHouse.Services.EmailService/FarmHouse.Services.EmailService.Api/FarmHouse.Services.EmailService.Api.csproj" was not found. [/app/FarmHouseServices.sln] 1.0s
#14 1.643 /usr/share/dotnet/sdk/3.1.406/NuGet.targets(282,5): error MSB3202: The project file "/app/FarmHouse.Services.EmailService/FarmHouse.Services.EmailService.Logic/FarmHouse.Services.EmailService.Logic.csproj" was not found. [/app/FarmHouseServices.sln]
Please, advice how to modify a Dockerfile in this case or the architecture. Thanks.