带有docker和.NET Core 2.0的VSTS CI/CD-复制失败 [英] VSTS CI/CD with docker and .NET Core 2.0 - Copy failed

查看:71
本文介绍了带有docker和.NET Core 2.0的VSTS CI/CD-复制失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在遵循几个.NET Core 2.0 Visual Studio Team Services连续集成/连续交付示例的同时,我遇到了VSTS中的复制错误.

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.

通过VS17添加docker支持在本地使用这样的dockerfile很好.

Adding docker support via VS17 works great locally with a dockerfile like this.

FROM microsoft/aspnetcore:2.0
ARG source
WORKDIR /app
EXPOSE 80
COPY ${source:-obj/Docker/publish} .
ENTRYPOINT ["dotnet", "myapp.dll"]

借助MVC应用程序和WebAPI应用程序,它可以在本地与docker-compose一起很好地工作.

With an MVC app and a WebAPI app it worked well with docker-compose locally.

在添加VSTS CI构建过程并运行它时,我一直在副本中遇到错误.

When adding a VSTS CI build process and running it I kept hitting errors with the copy.

构建myapp服务"myapp"失败 内部版本:复制失败:GetFileAttributesEx \?\ C:\ Windows \ TEMP \ docker-builder91 \ obj \ Docker \ publish:该 系统找不到指定的路径. C:\程序 Files \ Docker \ docker-compose.exe失败,返回码:1

Building myapp Service 'myapp' failed to build: COPY failed: GetFileAttributesEx \?\C:\Windows\TEMP\docker-builder91\obj\Docker\publish: The system cannot find the path specified. C:\Program Files\Docker\docker-compose.exe failed with return code: 1

推荐答案

我找到的解决方法是请注意,他们在Linux docker计算机上遇到错误

Note that they hit an error on a linux docker machine

复制失败:stat/var/lib/docker/tmp/docker-builder613328056/obj/Docker/publish:没有这样的文件或目录 /usr/bin/docker失败,返回码:1

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

解决方案:

像这样制作一个Dockerfile.ci

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"]

它还需要修改.dockerignore文件.

It also requires modifying the .dockerignore file.

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

这使我可以继续执行CI流程,但是我认为可以更轻松地解决此问题.

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

这篇关于带有docker和.NET Core 2.0的VSTS CI/CD-复制失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆