0

I have asp.net core solution, that contains 3 projects.

I want to deploy it to the docker container.

Here is how the solution looks likeenter image description here

Here is tree of solution

  TooSeeWeb
 |- aspnet-core(folder)
    |-TooSeeWeb (folder)
      |- TooSeeWeb.sln
      |-Dockerfile
      |- TooSeeWeb
         |- TooSeeWeb.csproj
      |- TooSeeWeb.Core(folder)
         |- TooSeeWeb.Core.csproj
      |- TooSeeWeb.Infrastructure(folder)
         |- TooSeeWeb.Infrastructure.csproj

Here is my dockerfile

   FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build-env
WORKDIR /app

# Copy csproj and restore as distinct layers
COPY *.sln ./
COPY TooSeeWeb/*.csproj ./TooSeeWeb/
COPY TooSeeWeb.Core/*.csproj ./TooSeeWeb.Core/
COPY TooSeeWeb.Infrastructure/.*csproj ./TooSeeWeb.Infrastructure/
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:2.2
WORKDIR /app/TooSeeWeb
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "tooseeweb.dll"]

My problem, that when I try to do docker build - < Dockerfile

I got this error

Step 3/13 : COPY *.sln ./ COPY failed: no source files were specified

How I can fix this?

8
  • from where you start the build command ? maybe you should copy using TooSeeWeb/*.sln ? Commented Nov 6, 2019 at 8:38
  • from folder where .sln file is @LinPy Commented Nov 6, 2019 at 8:39
  • the error indicate that *.sln return nothing, you need to double check that Commented Nov 6, 2019 at 8:40
  • tried your approach, same stuff @LinPy Commented Nov 6, 2019 at 8:40
  • I double-check it. with ls command in terminal. I see my .sln file @LinPy Commented Nov 6, 2019 at 8:43

1 Answer 1

1

When you use docker build - < Dockerfile, the local current directory isn't the directory you're running the command from.

You can see what the local directory is if you say COPY TooSeeWeb.sln ./ rather than *.sln. Then the error message will be something like COPY failed: stat /var/lib/docker/tmp/docker-builder87634958792798/TooSeeWeb.sln: no such file or directory.

If you instead use docker build . the local directory will be the directory you run the command from and your COPY command should work as expected.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.