I have a VS solution with multiple projects which are using docker compose as an orchestrator. When I publish with VS all docker files of each project will be run, which takes a lot of time even if I changed only one of the projects.
this is one example of a Dockerfile
which was generated by VS:
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ...
...
RUN dotnet build "Gateway.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Gateway.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Gateway.dll"]
I tried to run the docker file of the project directly with docker:
$ docker build .Dockerfile
I get this error:
[+] Building 0.0s (1/2)
=> ERROR [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 63B 0.0s
------
> [internal] load build definition from Dockerfile:
------
failed to solve with frontend dockerfile.v0: failed to read dockerfile: error from sender: walk Dockerfile: The system cannot find the path specified.
How can I build/publish only one project with VS or with CLI?