While creating a CI/CD via Azure Devops, my goal is to push two tags to the artifactory:
- latest
- build version (For example 1.0.X)
My docker-compose looks like:
version: '3.4'
services:
mycontainer:
image: ${Image}:${Tag}
build:
context: .
dockerfile: */Dockerfile
rabbitmq:
...
The yml related steps are:
variables:
- name: Tag
value: '1.0.1'
- name: 'Image'
value: 'myartifactory/myrepo/mycontainer'
- task: DockerCompose@0
displayName: 'Docker-Compose up data source'
inputs:
dockerComposeFile: 'docker-compose.yml'
dockerComposeFileArgs: |
Image=$(Image)
Tag=$(Tag)
action: 'Run a Docker Compose command'
dockerComposeCommand: 'up --build -d'
This step successfully creates this result and I'm able to successfully push the 1.0.1's tag to artifactory:
Successfully built ############
Successfully tagged myartifactory/myrepo/myproject:1.0.1
- task: ArtifactoryDocker@1
displayName: 'Push tagged image to artifactory'
inputs:
command: 'push'
artifactoryService: '...'
targetRepo: '...'
imageName: '$(DockerImage):$(Tag)'
Now, to push the latest
I need to copy paste these two steps again:
- task: DockerCompose@0
displayName: 'Docker-Compose up data source'
inputs:
dockerComposeFile: 'docker-compose.yml'
dockerComposeFileArgs: |
Image=$(Image)
Tag=latest
action: 'Run a Docker Compose command'
dockerComposeCommand: 'up --build -d'
- task: ArtifactoryDocker@1
displayName: 'Push tagged image to artifactory'
inputs:
command: 'push'
artifactoryService: '...'
targetRepo: '...'
imageName: '$(DockerImage):latest'
Is it possible to tag the latest
tag together with the 1.0.1
tag and push them together?
Because docker-compose up the project with latest again takes a lot of time.
I'm trying also to avoid using script step to run docker tag ...
to re-tag the image.