A
A
Alucard7712020-09-07 04:05:27
.NET
Alucard771, 2020-09-07 04:05:27

Why does docker-compose crash but I can build?

Here is my

dockerfile
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-bionic AS base
WORKDIR /app
EXPOSE 5002

FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS publish
WORKDIR /src
COPY  ./ ./

WORKDIR /src/dirwithService
RUN dotnet publish "Someservice.csproj" -c Debug -o /app/publish

FROM base AS finalGit
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Someservice.dll"]
:

The build runs without problems.
Docker-compose starts it and several other services. Here is a piece dedicated to it.

version: '3'
services:
    Someservice:
        container_name: Someservice
        build:
            context: dirwithService/Someservice
            dockerfile: Dockerfile
        ports:
        - "5002:80"


It crashes with this text:
Step 8/12 : RUN dotnet publish "Someservice.csproj" -c Debug -o /app/publish                                                                                                                                                   ---> Running in acc9e5d5d7ed                                                                                                                                                                                                          Microsoft (R) Build Engine version 16.7.0-preview-20360-03+188921e2f for .NET                                                                                                                                                          Copyright (C) Microsoft Corporation. All rights reserved.                                                                                                                                                                                                                                                                                                                                                                                                                     MSBUILD : error MSB1009: Project file does not exist.                                                                                                                                                                                  Switch: Someservice.csproj                                                                                                                                                                                                    ERROR: Service 'Someservice' failed to build: The command '/bin/sh -c dotnet publish "Someservice.csproj" -c Debug -o /app/publish' returned a non-zero code: 1


================================================
Seems I understood. This is due to the fact that in the dockerfile I am copying from the parent directory.
It remains to understand how I can pass the required parameter in the docker compos so that the dockerfile can do this.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question