-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
315 lines (310 loc) · 15.3 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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
trigger:
- master
pr: none
pool:
vmImage: 'ubuntu-latest'
stages:
- stage: Build
jobs:
- job: Build
steps:
- task: DockerCompose@0
displayName: docker-compose build
inputs:
containerregistrytype: 'Azure Container Registry'
azureSubscription: 'bacr(1)(c4530747-c19d-4a6d-b3b6-8fa1904c8b65)'
azureContainerRegistry: '{"loginServer":"bacrhub.azurecr.io", "id" : "/subscriptions/c4530747-c19d-4a6d-b3b6-8fa1904c8b65/resourceGroups/bacr/providers/Microsoft.ContainerRegistry/registries/bacrhub"}'
dockerComposeFile: '**/docker-compose.yaml'
projectName: 'sakhatyla'
action: 'Build services'
additionalImageTags: '$(Build.BuildNumber)'
includeLatestTag: true
- task: DockerCompose@0
displayName: docker-compose push
inputs:
containerregistrytype: 'Azure Container Registry'
azureSubscription: 'bacr(1)(c4530747-c19d-4a6d-b3b6-8fa1904c8b65)'
azureContainerRegistry: '{"loginServer":"bacrhub.azurecr.io", "id" : "/subscriptions/c4530747-c19d-4a6d-b3b6-8fa1904c8b65/resourceGroups/bacr/providers/Microsoft.ContainerRegistry/registries/bacrhub"}'
dockerComposeFile: '**/docker-compose.yaml'
projectName: 'sakhatyla'
action: 'Push services'
additionalImageTags: '$(Build.BuildNumber)'
includeLatestTag: true
- task: CopyFiles@2
displayName: copy docker-compose.yaml
inputs:
Contents: 'docker-compose.yaml'
TargetFolder: '$(build.artifactstagingdirectory)'
- task: file-creator@5
displayName: create docker-compose.Release.yaml
inputs:
fileoverwrite: true
filepath: '$(Build.ArtifactStagingDirectory)/docker-compose.Release.yaml'
filecontent: |
version: '3'
services:
web:
image: 'bacrhub.azurecr.io/sakhatyla_web:$(Build.BuildNumber)'
webng:
image: 'bacrhub.azurecr.io/sakhatyla_webng:$(Build.BuildNumber)'
site:
image: 'bacrhub.azurecr.io/sakhatyla_site:$(Build.BuildNumber)'
worker:
image: 'bacrhub.azurecr.io/sakhatyla_worker:$(Build.BuildNumber)'
- task: PublishPipelineArtifact@1
inputs:
path: $(Build.ArtifactStagingDirectory)
artifact: DockerCompose
- stage: Production
variables:
- group: SakhaTyla-Production
jobs:
- deployment: DeployApp
pool:
vmImage: 'ubuntu-latest'
environment:
name: Production
resourceType: VirtualMachine
variables:
DbHost: db
DbName: SakhaTyla-$(Environment.Name)
strategy:
runOnce:
deploy:
steps:
- task: DownloadPipelineArtifact@2
inputs:
artifact: DockerCompose
- task: CopyFiles@2
displayName: copy artifacts
inputs:
SourceFolder: '$(Pipeline.Workspace)/DockerCompose/'
Contents: '**'
TargetFolder: '$(AppDirectory)'
OverWrite: true
- task: file-creator@5
displayName: create docker-compose.Environment.yaml
inputs:
fileoverwrite: true
filepath: '$(AppDirectory)/docker-compose.$(Environment.Name).yaml'
filecontent: |
version: '3'
services:
web:
environment:
ASPNETCORE_URLS: 'http://+:5000'
ConnectionStrings__DefaultConnection: 'Server=tcp:$(DbHost),1433;Initial Catalog=$(DbName);Persist Security Info=False;User ID=$(DbUser);Password=$(DbPassword);MultipleActiveResultSets=False;Encrypt=False;Connection Timeout=30;'
IdentityServer__Clients__SakhaTyla.Web.Ng__RedirectUri: '$(Url)/authentication/login-callback'
IdentityServer__Clients__SakhaTyla.Web.Ng__LogoutUri: '$(Url)/authentication/logout-callback'
IdentityServer__Key__Type: File
IdentityServer__Key__FilePath: '$(CertificatePath)'
IdentityServer__Key__Password: '$(CertificatePassword)'
Services__SakhaTyla.Core.FileStorage.IFileStorage: SakhaTyla.Infrastructure.FileStorage.AWSS3Storage
AWSS3Storage__AccessKey: '$(S3AccessKey)'
AWSS3Storage__SecretKey: '$(S3SecretKey)'
AWSS3Storage__BucketName: '$(S3BucketName)'
AWSS3Storage__ServiceUrl: '$(S3ServiceUrl)'
Messaging__ConnectionUrl: 'rabbitmq://mq'
Messaging__Username: '$(MqUsername)'
Messaging__Password: '$(MqPassword)'
Authority: '$(IdUrl)'
Cors__Origin__0: '$(Url)'
Cors__Origin__1: '$(SiteUrl)'
Lucene__IndexPath: /index
Lucene__HunspellPath: /var/hunspell
EmailSender__DefaultFrom: 'SakhaTyla.Ru <[email protected]>'
EmailSender__SmtpServer: '$(EmailSmtpServer)'
EmailSender__SmtpPort: '$(EmailSmtpPort)'
EmailSender__UserName: '$(EmailUsername)'
EmailSender__Password: '$(EmailPassword)'
EmailSender__EnableSsl: 'true'
VIRTUAL_HOST: '$(IdHost)'
LETSENCRYPT_HOST: '$(IdHost)'
LETSENCRYPT_EMAIL: '[email protected]'
volumes:
- ./cert:/var/cert
- ./hunspell:/var/hunspell
- index:/index
- dpkeys:/root/.aspnet/DataProtection-Keys
restart: always
webng:
build:
context: .
volumes:
- ./webng/config.json:/usr/share/nginx/html/assets/config.json
environment:
VIRTUAL_HOST: '$(Host)'
LETSENCRYPT_HOST: '$(Host)'
LETSENCRYPT_EMAIL: '[email protected]'
restart: always
site:
environment:
ASPNETCORE_URLS: 'http://+:5000'
ConnectionStrings__DefaultConnection: 'Server=tcp:$(DbHost),1433;Initial Catalog=$(DbName);Persist Security Info=False;User ID=$(DbUser);Password=$(DbPassword);MultipleActiveResultSets=False;Encrypt=False;Connection Timeout=30;'
Services__SakhaTyla.Core.FileStorage.IFileStorage: SakhaTyla.Infrastructure.FileStorage.AWSS3Storage
AWSS3Storage__AccessKey: '$(S3AccessKey)'
AWSS3Storage__SecretKey: '$(S3SecretKey)'
AWSS3Storage__BucketName: '$(S3BucketName)'
AWSS3Storage__ServiceUrl: '$(S3ServiceUrl)'
Messaging__ConnectionUrl: 'rabbitmq://mq'
Messaging__Username: '$(MqUsername)'
Messaging__Password: '$(MqPassword)'
Lucene__IndexPath: /index
Lucene__HunspellPath: /var/hunspell
Server__ApiUrl: '$(IdUrl)'
VIRTUAL_HOST: '$(SiteHost),$(SiteWwwHost)'
LETSENCRYPT_HOST: '$(SiteHost),$(SiteWwwHost)'
LETSENCRYPT_EMAIL: '[email protected]'
volumes:
- ./hunspell:/var/hunspell
- index:/index
- dpkeys:/root/.aspnet/DataProtection-Keys
restart: always
worker:
environment:
ConnectionStrings__DefaultConnection: 'Server=tcp:$(DbHost),1433;Initial Catalog=$(DbName);Persist Security Info=False;User ID=$(DbUser);Password=$(DbPassword);MultipleActiveResultSets=False;Encrypt=False;Connection Timeout=30;'
Services__SakhaTyla.Core.FileStorage.IFileStorage: SakhaTyla.Infrastructure.FileStorage.AWSS3Storage
AWSS3Storage__AccessKey: '$(S3AccessKey)'
AWSS3Storage__SecretKey: '$(S3SecretKey)'
AWSS3Storage__BucketName: '$(S3BucketName)'
AWSS3Storage__ServiceUrl: '$(S3ServiceUrl)'
Messaging__ConnectionUrl: 'rabbitmq://mq'
Messaging__Username: '$(MqUsername)'
Messaging__Password: '$(MqPassword)'
Lucene__IndexPath: /index
Lucene__HunspellPath: /var/hunspell
Telegram__BotToken: '$(TelegramBotToken)'
volumes:
- ./hunspell:/var/hunspell
- index:/index
restart: always
db:
ports:
- '0.0.0.0:1433:1433'
environment:
ACCEPT_EULA: 'Y'
SA_PASSWORD: '$(DbPassword)'
MSSQL_PID: 'Express'
volumes:
- db:/var/opt/mssql
restart: always
backup:
image: bacr/backuputil
environment:
SqlBackup__ConnectionString: 'Server=tcp:$(DbHost),1433;User ID=$(DbUser);Password=$(DbPassword);MultipleActiveResultSets=false'
SqlBackup__Database: '$(DbName)'
SqlBackup__BackupPath: /var/opt/mssql/backup
DbBackupJob__BackupPath: /db/backup
DbBackupJob__StoragePath: backup
DbBackupJob__Archive: 'true'
Services__BackupUtil.Storage.IStorage: BackupUtil.Storage.AWSS3Storage
AWSS3Storage__AccessKey: $(S3AccessKey)
AWSS3Storage__SecretKey: $(S3SecretKey)
AWSS3Storage__BucketName: sakhatyla
AWSS3Storage__ServiceUrl: '$(S3ServiceUrl)'
BackupSchedulerJob__Db__0__Type: Full
BackupSchedulerJob__Db__0__Cron: '0 0 0 1 * ?'
BackupSchedulerJob__Db__1__Type: Differential
BackupSchedulerJob__Db__1__Cron: '0 0 1 ? * SUN'
BackupSchedulerJob__Db__2__Type: TransactionLog
BackupSchedulerJob__Db__2__Cron: '0 0 2 * * ?'
volumes:
- db:/db
restart: always
mq:
environment:
RABBITMQ_DEFAULT_USER: '$(MqUsername)'
RABBITMQ_DEFAULT_PASS: '$(MqPassword)'
volumes:
- mq:/var/lib/rabbitmq
restart: always
proxy:
image: jwilder/nginx-proxy
ports:
- '80:80'
- '443:443'
volumes:
- ./nginx/custom.conf:/etc/nginx/conf.d/st_custom.conf:ro
- certs:/etc/nginx/certs:ro
- conf:/etc/nginx/conf.d
- vhost:/etc/nginx/vhost.d
- dhparam:/etc/nginx/dhparam
- html:/usr/share/nginx/html
- /var/run/docker.sock:/tmp/docker.sock:ro
restart: always
labels:
- "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy"
letsencrypt:
image: jrcs/letsencrypt-nginx-proxy-companion
volumes:
- certs:/etc/nginx/certs:rw
- conf:/etc/nginx/conf.d
- vhost:/etc/nginx/vhost.d
- dhparam:/etc/nginx/dhparam
- html:/usr/share/nginx/html
- /var/run/docker.sock:/var/run/docker.sock:ro
restart: always
volumes:
db:
mq:
index:
dpkeys:
conf:
vhost:
html:
dhparam:
certs:
- task: DockerCompose@0
displayName: docker-compose pull
inputs:
containerregistrytype: 'Azure Container Registry'
azureSubscription: 'bacr(1)(c4530747-c19d-4a6d-b3b6-8fa1904c8b65)'
azureContainerRegistry: '{"loginServer":"bacrhub.azurecr.io", "id" : "/subscriptions/c4530747-c19d-4a6d-b3b6-8fa1904c8b65/resourceGroups/bacr/providers/Microsoft.ContainerRegistry/registries/bacrhub"}'
dockerComposeFile: '$(AppDirectory)/docker-compose.yaml'
additionalDockerComposeFiles: |
docker-compose.Release.yaml
docker-compose.$(Environment.Name).yaml
projectName: 'sakhatyla'
action: 'Run a Docker Compose command'
dockerComposeCommand: 'pull'
- task: file-creator@5
displayName: create config.json
inputs:
fileoverwrite: true
filepath: '$(AppDirectory)/webng/config.json'
filecontent: |
{
"apiBaseUrl": "$(IdUrl)"
}
- task: file-creator@5
displayName: create custom nginx conf
inputs:
fileoverwrite: true
filepath: '$(AppDirectory)/nginx/custom.conf'
filecontent: |
gzip on;
gzip_types application/json application/xml text/plain text/css text/json text/xml image/svg+xml;
gzip_vary on;
- task: DownloadSecureFile@1
displayName: download sakhatyla.pfx
inputs:
secureFile: 'sakhatyla.pfx'
- task: CopyFiles@2
displayName: copy cert
inputs:
SourceFolder: '$(Agent.TempDirectory)'
Contents: 'sakhatyla.pfx'
TargetFolder: '$(AppDirectory)/cert/'
- task: DockerCompose@0
displayName: docker-compose up
inputs:
containerregistrytype: 'Azure Container Registry'
azureSubscription: 'bacr(1)(c4530747-c19d-4a6d-b3b6-8fa1904c8b65)'
azureContainerRegistry: '{"loginServer":"bacrhub.azurecr.io", "id" : "/subscriptions/c4530747-c19d-4a6d-b3b6-8fa1904c8b65/resourceGroups/bacr/providers/Microsoft.ContainerRegistry/registries/bacrhub"}'
dockerComposeFile: '$(AppDirectory)/docker-compose.yaml'
additionalDockerComposeFiles: |
docker-compose.Release.yaml
docker-compose.$(Environment.Name).yaml
projectName: 'sakhatyla'
action: 'Run a Docker Compose command'
dockerComposeCommand: 'up -d --always-recreate-deps'