-
Notifications
You must be signed in to change notification settings - Fork 0
/
frontend-pipeline.yml
103 lines (96 loc) · 3.42 KB
/
frontend-pipeline.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
# Docker
# Build and push an image to Azure Container Registry
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker
trigger:
- main
resources:
- repo: self
variables:
# Variable groups
- group: acr_service_connection
- group: arm_service_connection
- group: docker_build_arguments
# Hardcoded variables
- name: imageRepository
value: "dapalpha"
- name: dockerfilePath
value: "$(Build.SourcesDirectory)/app/Dockerfile"
- name: tag
value: "$(Build.BuildId)"
- name: vmImageName
value: "ubuntu-latest"
# Environment parameters to iterate through
parameters:
- name: environments
type: object
default:
- name: dev
arm_connection: "$(dev_arm_service_connections)"
acr_connection: "$(dev_acr_connection)"
acr_name: "$(dev_acr_name)"
container_port: "$(dev_container_port)"
- name: prod
arm_connection: "$(prod_arm_service_connections)"
acr_connection: "$(prod_acr_connection)"
acr_name: "$(prod_acr_name)"
container_port: "$(prod_container_port)"
stages:
# Build/deploy across environments
- ${{ each environment in parameters.environments}}:
# Build
- stage: Build_${{environment.name}}
displayName: "${{environment.name}}: Build and push stage"
condition: succeeded()
jobs:
- deployment: Build
displayName: Build
environment: "${{environment.name}}"
pool:
vmImage: $(vmImageName)
strategy:
runOnce:
deploy:
steps:
- checkout: self
- task: Docker@2
displayName: Build an image
inputs:
command: build
repository: $(imageRepository)
dockerfile: $(dockerfilePath)
containerRegistry: ${{environment.acr_connection}}
arguments: >
--build-arg CONTAINER_PORT=${{environment.container_port}}
--build-arg VITE_APP_ENV=${{environment.name}}
tags: |
$(tag)
latest
- task: Docker@2
displayName: Push an image to container registry
inputs:
command: push
repository: $(imageRepository)
containerRegistry: ${{environment.acr_connection}}
tags: |
$(tag)
latest
# Deploy
- stage: Deploy_${{environment.name}}
displayName: "${{environment.name}}: Deploy to Azure Web App"
condition: succeeded()
jobs:
- deployment: Deploy
displayName: Deploy
environment: "${{environment.name}}"
pool:
vmImage: "ubuntu-latest"
strategy:
runOnce:
deploy:
steps:
- task: AzureWebAppContainer@1
inputs:
appType: "webAppLinux"
appName: "dapalpha-${{environment.name}}-app"
azureSubscription: ${{environment.arm_connection}}
containers: "${{environment.acr_name}}.azurecr.io/$(imageRepository):$(tag)"