-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
71 lines (64 loc) · 1.82 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
trigger:
- master
resources:
- repo: self
variables:
dockerRegistryServiceConnection: 'docker-hub'
imageRepository: 'your-python-app'
containerRegistry: 'yourdockerhubusername'
dockerfilePath: '$(Build.SourcesDirectory)/Dockerfile'
tag: '$(Build.BuildId)'
AKSClusterName: 'yourAKSClusterName'
AKSResourceGroup: 'yourAKSResourceGroup'
AKSServiceConnection: 'yourAKSServiceConnection'
stages:
- stage: Build
displayName: Build and push stage
jobs:
- job: Build
displayName: Build
pool:
vmImage: 'ubuntu-latest'
steps:
- task: Cache@2
inputs:
key: 'docker | $(Build.SourcesDirectory)/Dockerfile'
restoreKeys: |
docker | $(Build.SourcesDirectory)/Dockerfile
path: $(DOCKER_CONFIG)
displayName: Cache Docker layers
- task: Docker@2
inputs:
command: 'build'
repository: '$(imageRepository)'
dockerfile: '$(dockerfilePath)'
containerRegistry: '$(dockerRegistryServiceConnection)'
tags: '$(tag)'
- task: Docker@2
inputs:
command: 'push'
repository: '$(imageRepository)'
containerRegistry: '$(dockerRegistryServiceConnection)'
tags: '$(tag)'
- publish: $(Build.ArtifactStagingDirectory)
artifact: 'drop'
- stage: Deploy
displayName: Deploy stage
dependsOn: Build
jobs:
- deployment: Deploy
displayName: Deploy
environment: 'production'
pool:
vmImage: 'ubuntu-latest'
strategy:
runOnce:
deploy:
steps:
- task: Kubernetes@1
inputs:
connectionType: 'Kubernetes Service Connection'
kubernetesServiceEndpoint: '$(AKSServiceConnection)'
namespace: 'default'
command: 'apply'
arguments: '-f $(Build.SourcesDirectory)/manifests/'