Skip to content

Commit

Permalink
More files
Browse files Browse the repository at this point in the history
  • Loading branch information
benbp committed Mar 18, 2024
1 parent 816b9b1 commit ec0555c
Show file tree
Hide file tree
Showing 3 changed files with 287 additions and 150 deletions.
129 changes: 129 additions & 0 deletions eng/pipelines/publish-docker-image-isolated.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# Additional sample inputs can be found in `eng/containers/ci.yml`, but here is an example.
# - name: test_proxy_linux
# dockerRepo: 'engsys/testproxy-lin'
# prepareScript: tools/test-proxy/docker/prepare.ps1
# excludeFromManifest: true/false
# configPath: 'tools/test-proxy/docker'
# stableTags:
# - 'latest'

# A "ManifestDeployment" is a secondary deployment that can be used to map multiple docker tags to a single platform-sensitive one. It waits until
# all previous tag deployments are created, then triggers a manifest upload that bundles all tags configured in DockerDeployments. To exclude an item from the
# manifest upload, set deployment config property excludeFromManifest to true.
# - name: test_proxy_manifest
# dockerRepo: 'engsys/testproxy'
# stableTags:
# - 'latest'
parameters:
- name: DockerDeployments
type: object
default: []
- name: ManifestDeployment
type: object
default: []
- name: ImageTag
type: string
- name: ContainerRegistry
type: string
default: 'azsdkengsys'
- name: Publish
type: boolean
default: true

stages:
- stage:
displayName: Build/Publish Containers
variables:
- template: /eng/pipelines/templates/variables/globals.yml
- template: /eng/pipelines/templates/variables/image.yml
jobs:
- ${{ each config in parameters.DockerDeployments }}:
- job: container_build_${{ config.name }}
displayName: Build ${{ config.name }} Image
pool:
name: $(LINUXPOOL)
image: $(LINUXVMIMAGE)
os: linux

${{ if parameters.Publish }}:
templateContext:
outputs:
- output: containerImage
displayName: Push ${{ config.name }}:${{ parameters.ImageTag }}
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
image: ${{ parameters.ContainerRegistry }}.azurecr.io/${{ config.dockerRepo }}:${{ parameters.ImageTag }}
- ${{ if config.stableTags }}:
- ${{ each stableTag in config.stableTags }}:
- output: containerImage
displayName: Push ${{ config.name }}:${{ stableTag }}
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
image: ${{ parameters.ContainerRegistry }}.azurecr.io/${{ config.dockerRepo }}:${{ stableTag }}

steps:
- ${{ if config.prepareScript }}:
- pwsh: |
./${{ config.prepareScript }}
displayName: "Run prep script"
- task: 1ES.BuildContainerImage@1
displayName: Build ${{ config.name }}:${{ parameters.ImageTag }}
inputs:
image: ${{ parameters.ContainerRegistry }}.azurecr.io/${{ config.dockerRepo }}:${{ parameters.ImageTag }}
path: ${{ config.configPath }}

- ${{ if and(parameters.ManifestDeployment, parameters.Publish) }}:
- ${{ each deployment in parameters.ManifestDeployment }}:
- job: container_build_${{ deployment.name }}
displayName: Build ${{ deployment.name }} Manifest
${{ if gt(length(parameters.DockerDeployments), 0) }}:
dependsOn:
- ${{ each config in parameters.DockerDeployments }}:
- container_build_${{ config.name }}
pool:
name: $(LINUXPOOL)
image: $(LINUXVMIMAGE)
os: linux

steps:
- task: Docker@2
displayName: Login to ACR
inputs:
command: login
containerRegistry: ${{ parameters.ContainerRegistry }}

- pwsh: |
$configurations = '${{ convertToJson(parameters.DockerDeployments) }}' -replace '\\', '/'
$assembledDependentTags = $(Build.SourcesDirectory)/eng/pipelines/templates/scripts/get-docker-manifest-input.ps1 `
-DockerDeploymentJson $configurations `
-ContainerRegistry "${{ parameters.ContainerRegistry }}" `
-ImageTag "${{ parameters.ImageTag }}" `
Write-Host "##vso[task.setvariable variable=ManifestVariable]$assembledDependentTags"
displayName: Generate Manifest Variable
- pwsh: |
docker manifest create ${{ parameters.ContainerRegistry }}.azurecr.io/${{ deployment.dockerRepo }}:${{ parameters.ImageTag }} $(ManifestVariable)
displayName: Generate Manifest
- pwsh: |
docker manifest push ${{ parameters.ContainerRegistry }}.azurecr.io/${{ deployment.dockerRepo }}:${{ parameters.ImageTag }}
displayName: Upload Manifest
- ${{ if deployment.stableTags }}:
- ${{ each stableTag in deployment.stableTags }}:
- pwsh: |
$configurations = '${{ convertToJson(parameters.DockerDeployments) }}' -replace '\\', '/'
$assembledDependentTags = $(Build.SourcesDirectory)/eng/pipelines/templates/scripts/get-docker-manifest-input.ps1 `
-DockerDeploymentJson $configurations `
-ContainerRegistry "${{ parameters.ContainerRegistry }}" `
-ImageTag "${{ stableTag }}" `
Write-Host "##vso[task.setvariable variable=ManifestVariable]$assembledDependentTags"
displayName: Generate Manifest Variable
- pwsh: |
docker manifest create ${{ parameters.ContainerRegistry }}.azurecr.io/${{ deployment.dockerRepo }}:${{ stableTag }} $(ManifestVariable)
displayName: Generate Manifest
- pwsh: |
docker manifest push ${{ parameters.ContainerRegistry }}.azurecr.io/${{ deployment.dockerRepo }}:${{ stableTag }}
displayName: Upload Manifest
Loading

0 comments on commit ec0555c

Please sign in to comment.