generated from c17hawke/dvc-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
127 lines (111 loc) · 4.06 KB
/
azure-pipelines.yml
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
resources:
repositories:
- repository: source
type: git
name: Forecasty/timeseries-simulation
trigger:
branches:
include:
- demo
pool:
vmImage: 'ubuntu-latest'
variables:
- group: forecasty-docker
- name: REPOSITORY
value: timeseries-simulation
stages:
- stage: Publish
displayName: Publish container images
jobs:
- job: BuildAndPushContainerImage
displayName: Build and push container image
steps:
- checkout: git://Forecasty/timeseries-simulation@$(Build.SourceBranchName)
clean: 'true'
fetchDepth: '1'
persistCredentials: 'true'
- task: Docker@2
displayName: Login to ACR
inputs:
command: login
containerRegistry: forecastydevimages.azurecr.io
- task: Bash@3
displayName: Pull last image
inputs:
targetType: 'inline'
script: docker pull $(DOCKER_REGISTRY)/$(REPOSITORY):$(Build.SourceBranchName)
continueOnError: true
- task: Docker@2
displayName: Build new image
inputs:
command: build
dockerfile: $(Build.SourcesDirectory)/Dockerfile
repository: $(REPOSITORY)
containerRegistry: $(DOCKER_REGISTRY)
buildContext: $(Build.SourcesDirectory)
addPipelineData: false
addBaseImageData: false
arguments: --cache-from $(DOCKER_REGISTRY)/$(REPOSITORY):$(Build.SourceBranchName) --build-arg BUILDKIT_INLINE_CACHE=1
tags: |
$(Build.BuildNumber)
$(Build.SourceBranchName)
- task: Docker@2
displayName: Push new image
inputs:
command: push
repository: $(REPOSITORY)
containerRegistry: $(DOCKER_REGISTRY)
tags: |
$(Build.BuildNumber)
$(Build.SourceBranchName)
- task: Docker@2
displayName: Logout of ACR
inputs:
command: logout
containerRegistry: forecastydevimages.azurecr.io
- job: PrepareArtifacts
steps:
- task: Bash@3
displayName: Substitute placeholder with values
inputs:
targetType: 'inline'
script: |
sed -i "s%#{Build.BuildId}#%$(Build.BuildNumber)%g" "$(Build.SourcesDirectory)/k8s/kustomization.yaml"
- task: KubernetesManifest@0
name: bake
displayName: Kustomize K8s manifests
inputs:
action: bake
renderType: kustomize
kustomizationPath: $(Build.SourcesDirectory)/k8s
- task: Bash@3
displayName: Rename compiled kustomize file
inputs:
targetType: 'inline'
script: mv $(bake.manifestsBundle) $(Build.ArtifactStagingDirectory)/$(Build.SourceBranchName)-$(Build.BuildNumber).yaml
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: $(Build.ArtifactStagingDirectory)/$(Build.SourceBranchName)-$(Build.BuildNumber).yaml
ArtifactName: 'drop'
publishLocation: 'Container'
- stage: Deploy
displayName: Deploy images
jobs:
- deployment: DeployImages
displayName: Deploy to kubernetes
environment: $(Build.SourceBranchName)
strategy:
runOnce:
deploy:
steps:
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
artifactName: 'drop'
targetPath: '$(Pipeline.Workspace)'
- task: KubernetesManifest@0
displayName: Deploy K8s manifests
inputs:
namespace: 'demo'
manifests: '$(Pipeline.Workspace)/$(Build.SourceBranchName)-$(Build.BuildNumber).yaml'
kubernetesServiceConnection: '$(Build.SourceBranchName)-demo'