I am running a .netcore2.0 webapi using Visual studio 2017 for MAC. I have a project structure as below.
src
--Solution.sln
-- Common
-- commonPrj
-- Common.csproj
--Data
-- QM
-- QM.csproj
--Repo
--Repo.csproj
--Ser
-- Host
-- Api
--api.csproj
I have the DOCKERFILE content as well. Which is throwing error while doing the dotnet build process as the build agent could not resolve the common.csproj/ I think my dockerfile definition is wrong. Can someone please assist in getting this work [i tried lot of option here with dockerfile]>?
#FROM microsoft/aspnetcore-build:2.0 AS build-env
FROM microsoft/aspnetcore
# copy csproj and restore as distinct layers
#COPY *.csproj ./
#RUN dotnet restore
# copy everything else and build
#COPY . ./ ./ ./
#RUN dotnet restore
#RUN dotnet publish -c Release -o out
# build runtime image
#FROM microsoft/aspnetcore:2.0
#WORKDIR /app
#COPY --from=build-env /app/out .
#EXPOSE 5000
COPY ./out /out
WORKDIR /out
#WORKDIR /publish
ENTRYPOINT ["dotnet", "Rando.MortgageCenter.WebAPI.dll"]
I am trying to build this docker image using the Docker cloud environment [cloud.docker.com/swarm]
Error Log from docker cloud build
Building in Docker Cloud's infrastructure...
Cloning into '.'...
Warning: Permanently added the RSA host key for IP address '104.192.143.1' to the list of known hosts.
Reset branch 'master'
Your branch is up-to-date with 'origin/master'.
KernelVersion: 4.4.0-93-generic
Arch: amd64
BuildTime: 2017-08-17T22:50:04.828747906+00:00
ApiVersion: 1.30
Version: 17.06.1-ce
MinAPIVersion: 1.12
GitCommit: 874a737
Os: linux
GoVersion: go1.8.3
Starting build of index.docker.io/systreeau/mortgagecenter:latest...
Step 1/4 : FROM microsoft/aspnetcore
---> f79840764591
Step 2/4 : COPY ./out /out
COPY failed: stat /var/lib/docker/tmp/docker-builder177013174/out: no such file or directory
ERROR: Build failed: COPY failed: stat /var/lib/docker/tmp/docker-builder177013174/out: no such file or directory
ERROR: Build failed with exit code 2
So what I found was you have to place your DOCKERFILE in the src folder which is the root of the solution. so that docker context becomes this path.
Now you have a Dockerfile as below
FROM microsoft/aspnetcore-build:2.0 as build
WORKDIR /app
COPY . .
#COPY Solution.sln .
# RUN ls -l
RUN dotnet restore ./Solution.sln
COPY . .
RUN dotnet publish ./Ser/Host/Api/api.csproj --output /out/ --configuration Release
# runtime image
FROM microsoft/aspnetcore:2.0
WORKDIR /app
COPY --from=build /out .
ENTRYPOINT ["api.dll"]
Hope this help someone having the issue what i am facing