Docker组成VSTS任务失败者 [英] Docker compose VSTS task failder
问题描述
我正在Linux上使用MSSQL开发Asp.Bet Core 2应用程序.我想将CI和CD配置为Azure. 我在Visual Studio Team Services中定义了docker-compose任务,但出现错误.
I'working on Asp.Bet Core 2 app with MSSQL on Linux. I would like to configure CI and CD to Azure. I defined docker-compose task in Visual Studio Team Services, but I'm getting an error.
2017-11-09T20:24:09.4725450Z ##[section]Starting: Create images
2017-11-09T20:24:09.4801610Z ==============================================================================
2017-11-09T20:24:09.4817660Z Task : Docker Compose
2017-11-09T20:24:09.4835680Z Description : Build, push or run multi-container Docker applications. Task can be used with Docker or Azure Container registry.
2017-11-09T20:24:09.4852370Z Version : 0.4.7
2017-11-09T20:24:09.4867100Z Author : Microsoft Corporation
2017-11-09T20:24:09.4881820Z Help : [More Information](https://go.microsoft.com/fwlink/?linkid=848006)
2017-11-09T20:24:09.4897520Z ==============================================================================
2017-11-09T20:24:10.5040990Z [command]/usr/local/bin/docker-compose -f /opt/vsts/work/1/s/docker-compose.yml -f /opt/vsts/work/1/s/docker-compose.ci.build.yml -f /home/vsts/agent/.docker-compose.1510259050468.yml -p Travelingowe build
2017-11-09T20:24:10.8628630Z db uses an image, skipping
2017-11-09T20:24:10.8646610Z Building api
2017-11-09T20:24:10.9373040Z Step 1/7 : FROM microsoft/aspnetcore:2.0
2017-11-09T20:24:12.0041790Z 2.0: Pulling from microsoft/aspnetcore
2017-11-09T20:25:03.6328690Z Digest: sha256:e36cb8d1edcd1bfd7aea0412349482a9c1a601089d76d1a294067f5f7f1098a9
2017-11-09T20:25:03.6497680Z Status: Downloaded newer image for microsoft/aspnetcore:2.0
2017-11-09T20:25:03.6524910Z ---> e0e49def2506
2017-11-09T20:25:03.6551560Z Step 2/7 : MAINTAINER Maciej Skuratowski <maciejskuratowski@gmail.com>
2017-11-09T20:25:03.7496070Z ---> Running in e7667861d293
2017-11-09T20:25:03.9222120Z ---> 24ba03484562
2017-11-09T20:25:03.9436840Z Removing intermediate container e7667861d293
2017-11-09T20:25:03.9458600Z Step 3/7 : ARG source
2017-11-09T20:25:04.0562980Z ---> Running in 7b57f9fc515f
2017-11-09T20:25:04.2292420Z ---> 4d07188edf18
2017-11-09T20:25:04.2503550Z Removing intermediate container 7b57f9fc515f
2017-11-09T20:25:04.2581270Z Step 4/7 : WORKDIR /app
2017-11-09T20:25:04.5347440Z ---> 4546b8dc771f
2017-11-09T20:25:04.5527690Z Removing intermediate container 0a595d10e668
2017-11-09T20:25:04.5558170Z Step 5/7 : EXPOSE 80
2017-11-09T20:25:04.6765650Z ---> Running in aa273cc9ca2c
2017-11-09T20:25:04.8330020Z ---> 6dd874db617e
2017-11-09T20:25:04.8619290Z Removing intermediate container aa273cc9ca2c
2017-11-09T20:25:04.8650100Z Step 6/7 : COPY ${source:-obj/Docker/publish} .
2017-11-09T20:25:04.8686070Z Service 'api' failed to build: COPY failed: stat /var/lib/docker/tmp/docker-builder211771018/obj/Docker/publish: no such file or directory
2017-11-09T20:25:04.9064960Z ##[error]db uses an image, skipping
2017-11-09T20:25:04.9127660Z ##[error]Building api
2017-11-09T20:25:04.9175860Z ##[error]Service 'api' failed to build: COPY failed: stat /var/lib/docker/tmp/docker-builder211771018/obj/Docker/publish: no such file or directory
2017-11-09T20:25:04.9258880Z ##[error]/usr/local/bin/docker-compose failed with return code: 1
2017-11-09T20:25:04.9325830Z ##[section]Finishing: Create images
这是我的docker-compose:
Here's my docker-compose:
version: '3'
services:
api:
image: api
container_name: api
build:
context: ./Api
dockerfile: Dockerfile
ports:
- "8000:80"
depends_on:
- db
db:
image: "microsoft/mssql-server-linux"
container_name: mssql
environment:
SA_PASSWORD: "testtest3030!"
ACCEPT_EULA: "Y"
MSSQL_PID: "Developer"
ports:
- "127.0.0.1:8001:1433"
和docker-compose.ci.build.yml文件:
and docker-compose.ci.build.yml file:
version: '3'
services:
ci-build:
image: microsoft/aspnetcore-build:1.0-1.1
volumes:
- .:/src
working_dir: /src
command: /bin/bash -c "dotnet restore ./Travelingowe.sln && dotnet publish ./Travelingowe.sln -c Release -o ./obj/Docker/publish"
我还附上了我的VSTS docker-compose taks:
Also I attached my VSTS docker-compose taks:
您是否知道我做错了?
推荐答案
关于错误,原因是没有obj/Docker/publish文件夹或文件. (检查列昂尼德的答案)
Regarding the error, the reason is that there isn’t the obj/Docker/publish folder or file. (check the answer of Leonid)
docker-compose.ci.build.yml
文件用于构建项目,而docker-compose.yml
文件用于运行项目,因此您需要使用Dokcer-compose任务通过docker-compose.ci.build.yml
文件构建项目,然后使用docker-compose.yml
具有Docker-compose任务的文件.
The docker-compose.ci.build.yml
file is for building the project and the docker-compose.yml
file is used for running the project, so you need to build the project through docker-compose.ci.build.yml
file with Dokcer-compose task, then build/run image with docker-compose.yml
file with Docker-compose task.
关于docker-compose.ci.build.yml,docker-compose.yml和Dockerfile有一个主题:
There is a thread about docker-compose.ci.build.yml, docker-compose.yml and Dockerfile: Asp.net core with linux docker container
更新:
请参考以下步骤将项目部署到Azure:
Refer to these steps to deploy project to Azure:
- 创建新的构建定义
- 添加Docker Compose任务(Docker Compose文件:
**/docker-compose.ci.build.yml
;操作:Run a Docker Compose command
;命令:run ci-build
) - 添加复制文件任务(源文件夹:
$(System.DefaultWorkingDirectory)/[your project path]/obj/Docker/publish
;内容:**
;目标文件夹:$(Build.ArtifactStagingDirectory)
) - 添加发布构建工件"任务(发布路径:
$(Build.ArtifactStagingDirectory)
) - 创建新版本的定义文件
- 添加Azure应用服务部署任务(包或文件夹:
$(System.DefaultWorkingDirectory)/[artifact build definition name]/[artifact name]
;取消选中Publish using Web Deploy option
)
- Create a new build definition
- Add Docker Compose task (Docker Compose File:
**/docker-compose.ci.build.yml
; Action:Run a Docker Compose command
; Command:run ci-build
) - Add Copy Files task (Source Folder:
$(System.DefaultWorkingDirectory)/[your project path]/obj/Docker/publish
; Contents:**
; Target Folder:$(Build.ArtifactStagingDirectory)
) - Add Publish Build Artifacts task (Path to publish:
$(Build.ArtifactStagingDirectory)
) - Create a new release definitioin
- Add Azure App Service Deploy task (Package or folder:
$(System.DefaultWorkingDirectory)/[artifact build definition name]/[artifact name]
; UncheckPublish using Web Deploy option
)
这篇关于Docker组成VSTS任务失败者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!