-
Notifications
You must be signed in to change notification settings - Fork 231
Expand file tree
/
Copy pathdocker-image-refresh.yml
More file actions
98 lines (88 loc) · 3.31 KB
/
Copy pathdocker-image-refresh.yml
File metadata and controls
98 lines (88 loc) · 3.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
#
# Scheduled rebuild of the microsoftgraph/powershell container image.
#
# Why this pipeline exists:
# The release pipeline (sdk-release.yml) only builds and pushes this image on `v*` tags, so
# between releases the published digest goes stale and keeps accruing Ubuntu USN / PowerShell
# CVEs. That is the root cause of the two S360 "Replace Vulnerable Registry Reference" items.
# This lightweight pipeline rebuilds the image on a cadence against a patched base and pushes a
# fresh digest to :latest, keeping the registry copy patched without re-running the full release.
#
# Setup (one-time): register this YAML as a new pipeline definition in the
# "Graph Developer Experiences" ADO project, targeting the default branch.
name: $(Date:yyyyMMdd)$(Rev:.r)_docker-image-refresh
parameters:
- name: LinuxPool
type: string
default: Azure-Pipelines-1ESPT-ExDShared
variables:
REGISTRY: 'msgraphprodregistry.azurecr.io'
IMAGE_NAME: 'public/microsoftgraph/powershell'
# Rebuild weekly so the image regularly picks up patched OS layers. `always: true` forces a run
# even when there are no new commits (the whole point is to refresh the base image).
schedules:
- cron: "0 6 * * 1" # 06:00 UTC every Monday
displayName: Weekly image refresh
branches:
include:
- main
always: true
# Do not build on every push/PR; the release pipeline already handles tag-driven publishes.
trigger: none
pr: none
resources:
repositories:
- repository: 1ESPipelineTemplates
type: git
name: 1ESPipelineTemplates/1ESPipelineTemplates
ref: refs/tags/release
extends:
template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates
parameters:
pool:
name: ${{ parameters.LinuxPool }}
image: ubuntu-latest
os: linux
settings:
networkIsolationPolicy: Permissive
customBuildTags:
- ES365AIMigrationTooling
stages:
- stage: RefreshDockerImage
displayName: 'Refresh docker image'
jobs:
- job: RebuildAndPush
displayName: 'Rebuild and push patched image'
pool:
name: ${{ parameters.LinuxPool }}
image: ubuntu-latest
os: linux
steps:
- checkout: self
- task: AzureCLI@2
displayName: 'Log in to Azure Container Registry'
inputs:
azureSubscription: 'ACR Images Push Service Connection'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: |
az acr login --name $(REGISTRY)
- script: |
docker run --privileged --rm tonistiigi/binfmt --install all
displayName: 'Enable multi-platform builds'
- script: |
docker buildx create --use --name refreshbuilder
displayName: 'Set up Docker BuildX'
- bash: |
set -euo pipefail
formatted_date=$(date +"%Y%m%d%H%M%S")
echo "Rebuilding $(REGISTRY)/$(IMAGE_NAME) on a patched base"
docker buildx build \
--platform linux/amd64 \
--push \
-t "$(REGISTRY)/$(IMAGE_NAME):latest" \
-t "$(REGISTRY)/$(IMAGE_NAME):$formatted_date" \
"$(Build.SourcesDirectory)"
displayName: 'Build and push refreshed image'