This is a follow up to my previous blog post of Dockerizing DevOps, because I've discovered a better way to run containers within AzDO by using container jobs with step targeting:
trigger: none
resources:
containers:
- container: devcontainer
image: $(imageRepository):$(Build.BuildId)
endpoint: demoacr
options: --name devcontainer
variables:
- name: dockerRegistryServiceConnection
value: "demoserviceconnection"
- name: imageRepository
value: "demoacr.azurecr.io/foo-devcontainer"
stages:
- stage: BUILD
displayName: Docker build & push
jobs:
- job:
displayName: Devcontainer build & push
steps:
- task: Docker@2
displayName: Login to ACR
inputs:
command: login
containerRegistry: $(dockerRegistryServiceConnection)
- task: Docker@2
displayName: Build and push an image to container registry
inputs:
command: buildAndPush
repository: $(imageRepository)
dockerfile: ".devcontainer/Dockerfile"
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(Build.BuildId)
latest
- stage: TEST
displayName: Run tests and linters
dependsOn:
- BUILD
jobs:
- job: Tests
steps:
- task: Docker@2
displayName: Login to ACR
inputs:
command: login
containerRegistry: $(dockerRegistryServiceConnection)
- script: |
make lint
displayName: "Lint"
target: devcontainer
- script: |
make test
displayName: "Run all tests"
target: devcontainer
Top comments (0)