Azure Devops Docker Compose Build

问题描述 投票:0回答:1

Azure Docker-Compose V0任务是否支持构建单个服务而不是构建所有服务?

以下是docker compose任务的Yaml转储。我想从环境变量构建单个服务。但这总是生成所有图像。

steps:
- task: DockerCompose@0
  displayName: 'Run a Docker Compose command'
  inputs:
    containerregistrytype: 'Container Registry'
    dockerComposeFile: 'pathto/docker-compose.yml'
    dockerComposeCommand: build
    arguments: '$(ProjectName)'

使用debug flag = true构建输出

[debug]arguments:
[debug]   -f
[debug]   /pathToCompose/docker-compose.yml
[debug]   -f
[debug]   /myagent/.docker-compose.1583974576607.yml
[debug]   -p
[debug]   repository
[debug]   build
/usr/sbin/docker-compose -f /pathToCompose/docker-compose.yml -f /myagent/.docker-compose.1583974576607.yml -p repository build
azure-devops azure-pipelines
1个回答
0
投票

Azure Docker-Compose V0任务是否支持构建单个服务而不是构建所有服务?

是,是的。

只需在任务的service name中指定要构建的argument,这就是您正在尝试的。

您需要在变量选项卡中将system.debug设置为true,然后确认详细的日志以确认是否已成功传递$(ProjectName)值。因为在调试日志中,我们打印了完整的命令:enter image description here

newsfeed是我的服务名称之一。


2020年3月13日更新:

任务定义的Arguments空白适用于Build service images操作,这意味着您只能在选择了Build service images操作之后才能在其中输入实际参数:

enter image description here

Arguments空白

无效

以及Run a Docker Compose command动作。
当您选择该动作时,所应用的参数方法应如下所示:

enter image description here

仅此,该参数才可用于任务。

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.