forked from Notalib/readium-lcp-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
190 lines (170 loc) · 6.71 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
trigger:
- master
variables:
resourceGroup_dev: 'lcp_dev'
appName_dev: 'LSDLCDserver'
acrName_dev: 'lcslsdcontainer'
databaseUrl_dev: $(DATABASE_URL_DEV)
resourceGroup_test: 'rg-lcp-test'
appName_test: 'app-lcplsd-test'
acrName_test: 'lcslsdcontainer'
databaseUrl_test: $(DATABASE_URL_TEST)
resourceGroup_prod: 'App-Lcp-Prod'
appName_prod: 'app-lcplsd-prod'
acrName_prod: 'lcslsdcontainer'
databaseUrl_prod: $(DATABASE_URL_PROD)
dockerComposeFile: 'ci/docker-compose.yaml'
containerRegistry: 'docker_lcp'
stages:
- stage: BuildAndPush
displayName: Build and Push with Docker Compose
jobs:
- job: Build
displayName: Build and Push
pool:
vmImage: 'ubuntu-latest'
steps:
- checkout: self
- script: |
sudo apt-get update
sudo apt-get install -y p7zip-full
displayName: 'Install p7zip'
- task: DownloadSecureFile@1
name: prodCertSecureFile
inputs:
secureFile: 'lcp-pki-mtm.7z' # Namnet på din Secure File
# Kör skriptet för att extrahera och kopiera certifikatfilerna
- script: |
chmod +x $(System.DefaultWorkingDirectory)/ci/apply_prod_cert.sh
$(System.DefaultWorkingDirectory)/ci/apply_prod_cert.sh "$(prodCertSecureFile.secureFilePath)"
displayName: "Apply Production Certificate"
env:
PROD_CERT_PASSWORD: $(PROD_CERT_PASSWORD)
- task: DownloadSecureFile@1
name: lcpPatcherArchive
inputs:
secureFile: 'lcp-patcher-v1p2.7z' # Namnet på din Secure File
# Kör patch-scriptet med sökvägen till den nedladdade filen
- script: |
sudo mkdir -p $(System.DefaultWorkingDirectory)/lcp/license
sudo chmod -R 777 $(System.DefaultWorkingDirectory)/lcp
chmod +x $(System.DefaultWorkingDirectory)/ci/apply_lcp_patch.sh
$(System.DefaultWorkingDirectory)/ci/apply_lcp_patch.sh "$(lcpPatcherArchive.secureFilePath)" "$(System.DefaultWorkingDirectory)"
displayName: "Apply LCP Patch using Secure File"
env:
LCP_PATCHER_PASSWORD: $(LCP_PATCHER_PASSWORD)
- script: |
sudo curl -L "https://github.com/docker/compose/releases/download/$(curl -s https://api.github.com/repos/docker/compose/releases/latest | jq -r .tag_name)/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
displayName: 'Install Docker Compose'
# Log in to Azure Container Registry
- task: Docker@2
displayName: 'Login to ACR'
inputs:
command: 'login'
containerRegistry: $(containerRegistry)
# Build and Push using Docker Compose
- script: |
docker-compose -f $(dockerComposeFile) build
docker-compose -f $(dockerComposeFile) push
displayName: 'Build and Push Docker Compose Images'
- stage: Deploy
displayName: Deploy to Azure Web App
dependsOn: BuildAndPush
jobs:
- job: Deploy
displayName: Deploy Docker Compose App
pool:
vmImage: 'ubuntu-latest'
steps:
- checkout: self
- task: AzureCLI@2
displayName: 'Login to Azure'
inputs:
azureSubscription: 'ACR-lcp'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: |
az account show
- task: AzureCLI@2
displayName: 'Deploy Dev'
inputs:
azureSubscription: 'ACR-lcp'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: |
echo "Using file: (System.DefaultWorkingDirectory)/$(dockerComposeFile)"
ls -l "$(System.DefaultWorkingDirectory)/$(dockerComposeFile)"
# Set up the container configuration with the specified compose file
az webapp config container set \
--name $(appName_dev) \
--resource-group $(resourceGroup_dev) \
--multicontainer-config-type compose \
--multicontainer-config-file "$(System.DefaultWorkingDirectory)/$(dockerComposeFile)"
- stage: Deploy_Test
displayName: Deploy to Test
dependsOn: Deploy
jobs:
- job: ManualApproval
displayName: 'Manual Approval for Test Deployment'
pool: server
steps:
- task: ManualValidation@0
displayName: 'Approve deployment to Test'
inputs:
instructions: 'Please review and approve the deployment to Test.'
onTimeout: 'reject'
notifyUsers: '[email protected]'
timeoutInMinutes: 60
- job: Deploy
dependsOn: ManualApproval
steps:
- checkout: self
- task: AzureCLI@2
displayName: 'Login to Azure'
inputs:
azureSubscription: 'sc-acr-lcp-test'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: |
az account show
- task: AzureCLI@2
displayName: 'Deploy Test'
inputs:
azureSubscription: 'sc-acr-lcp-test'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: |
az webapp config container set \
--name $(appName_test) \
--resource-group $(resourceGroup_test) \
--multicontainer-config-type compose \
--multicontainer-config-file "$(System.DefaultWorkingDirectory)/$(dockerComposeFile)"
- stage: Deploy_Prod
displayName: Deploy to Prod
dependsOn: Deploy_Test
jobs:
- job: Deploy
steps:
- checkout: self
- task: AzureCLI@2
displayName: 'Login to Azure'
inputs:
azureSubscription: 'sc-acr-lcp-prod'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: |
az account show
- task: AzureCLI@2
displayName: 'Deploy Prod'
inputs:
azureSubscription: 'sc-acr-lcp-prod'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: |
az webapp config container set \
--name $(appName_prod) \
--resource-group $(resourceGroup_prod) \
--multicontainer-config-type compose \
--multicontainer-config-file "$(System.DefaultWorkingDirectory)/$(dockerComposeFile)"