VSTS CI/CD with docker and .NET Core 2.0 - Copy failed

前端 未结 2 1669
醉酒成梦
醉酒成梦 2021-01-23 04:27

While following a couple .NET Core 2.0 Visual Studio Team Services Continuous Integration/Continuous Delivery examples I bumped into a copy error in VSTS.

Adding docker

相关标签:
2条回答
  • 2021-01-23 04:54

    I managed to build the service from within VSTS and copy them to the Docker image. I used .Net Core VSTS tasks to build and publish to "obj/Docker/Publish" folder and used "Docker-compose" tasks to build and publish docker container to private container repository.

    0 讨论(0)
  • 2021-01-23 04:59

    The workaround that I've found is from this blog.

    Note that they hit an error on a linux docker machine

    COPY failed: stat /var/lib/docker/tmp/docker-builder613328056/obj/Docker/publish: no such file or directory /usr/bin/docker failed with return code: 1

    Solution:

    Make a Dockerfile.ci like this

    FROM microsoft/aspnetcore-build:2.0 AS build-env
    WORKDIR /app
    
    # Copy csproj and restore as distinct layers
    COPY *.csproj ./
    RUN dotnet restore
    
    # Copy everything else and build
    COPY . ./
    RUN dotnet publish -c Release -o out
    
    # Build runtime image
    FROM microsoft/aspnetcore:2.0
    WORKDIR /app
    COPY --from=build-env /app/out .
    ENTRYPOINT ["dotnet", "SiliconValve.Vsts.DockerDemo.dll"]
    

    It also requires modifying the .dockerignore file.

    bin/
    obj/
    !*.dll
    !obj/Docker/publish/*
    !obj/Docker/empty/
    

    This allows me to continue the CI process, however I assume there's an easier fix to the problem.

    0 讨论(0)
提交回复
热议问题