forked from MicrosoftLearning/eShopOnWeb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eshoponweb-ci-dockercompose.yml
78 lines (72 loc) · 2.38 KB
/
eshoponweb-ci-dockercompose.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
#NAME THE PIPELINE SAME AS FILE (WITHOUT ".yml")
# Docker
# Build a Docker image
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker
# trigger:
# - main
resources:
repositories:
- repository: self
trigger: none
variables:
tag: '$(Build.BuildId)'
resource-group: 'AZ400-EWebShop-NAME'
location: 'westeurope'
templateFile: '.azure/bicep/acr.bicep'
azureserviceconnection: 'azure subs'
subscriptionId: 'YOUR-SUBSCRIPTION-ID'
stages:
- stage: Build
displayName: Create ACR for images
jobs:
- job: Build
pool:
vmImage: ubuntu-latest
steps:
#Create ACR to keep docker images
- task: AzureResourceManagerTemplateDeployment@3
displayName: Deploy ACR Bicep
inputs:
deploymentScope: 'Resource Group'
azureResourceManagerConnection: $(azureserviceconnection)
subscriptionId: $(subscriptionId)
action: 'Create Or Update Resource Group'
resourceGroupName: '$(resource-group)'
location: '$(location)'
templateLocation: 'Linked artifact'
csmFile: '$(templateFile)'
deploymentMode: 'Incremental'
deploymentOutputs: 'acr-json'
#Parse ACR login server variable
- task: PowerShell@2
displayName: Parse Bicep Output
inputs:
targetType: 'inline'
script: |
$var=ConvertFrom-Json '$(acr-json)'
$value=$var.acrloginServer.value
Write-Host "##vso[task.setvariable variable=acrloginserver;]$value"
echo $acrloginserver
# docker compose build images
- task: DockerCompose@0
displayName: Build Docker Compose
inputs:
containerregistrytype: 'Azure Container Registry'
azureSubscription: '$(azureserviceconnection)'
azureContainerRegistry: '$(acrloginserver)'
dockerComposeFile: '**/docker-compose.yml'
projectName:
action: 'Build services'
additionalImageTags: '$(Build.BuildNumber)'
includeLatestTag: true
- task: DockerCompose@0
displayName: Push Docker Compose
inputs:
containerregistrytype: 'Azure Container Registry'
azureSubscription: $(azureserviceconnection)
azureContainerRegistry: '$(acrloginserver)'
dockerComposeFile: '**/docker-compose.yml'
projectName:
action: 'Push services'
additionalImageTags: '$(Build.BuildNumber)'
includeLatestTag: true