Reputation: 41710
Because of a recent change in the ubuntu-latest
image that introduced a buggy version of docker-compose, I had to lock down the version of docker-compose on my pipelines.
However, there was a task that I used to help clean up my deploy scripts namely DockerCompose@0
. What I am trying to implement the equivalent of
- task: DockerCompose@0
displayName: 'Remove build options'
inputs:
action: 'Combine configuration'
removeBuildOptions: true
So basically I was thinking of using yq
which will parse the YAML file and remove the build options which are not applicable on the stack deployment. However, I am not exactly sure how to do it. Since I need to remove it from every service that MAY include it.
So given the following input
services:
def:
build: ./def
image: trajano/def
ghi:
image: trajano/ghi
version: '3.7'
I want to get
services:
def:
image: trajano/def
ghi:
image: trajano/ghi
version: '3.7'
Upvotes: 6
Views: 10170
Reputation: 2412
For newer yq versions (see Docs):
yq eval 'del(services.[].build)' foo.yml
Upvotes: 8
Reputation: 41710
yq d foo.yml 'services.*.build'
To do this in Azure pipelines
steps:
- bash: |
URL="https://github.com/docker/compose/releases/download/1.26.2/docker-compose-Linux-x86_64"
sudo curl -sL $URL -o /usr/local/bin/docker-compose
sudo snap install yq
displayName: Install additional software
- bash: |
docker-compose config | yq d - 'services.*.build' > $(Build.ArtifactStagingDirectory)/docker-compose.yml
displayName: Clean up docker-compose.yml
Upvotes: 0