-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
68 lines (63 loc) · 1.79 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
variables:
devops_rootdir: /opt/solid
devops_dir: $(devops_rootdir)/app
app_dir: /opt/app/app-$(Build.SourceBranchName)
app_rooturl: solid-app.52-174-17.190.nip.io
env_file: /tmp/env-$(Build.SourceBranchName)
trigger:
branches:
include:
- '*'
stages:
- stage: image
jobs:
- job: image
steps:
- task: Docker@2
displayName: Login to Docker Hub
inputs:
command: login
containerRegistry: dockerhub
- task: Docker@2
displayName: build
inputs:
command: build
arguments: --build-arg branch=$(Build.SourceBranch)
repository: wirvsvirussolid/solid
tags: |
app-$(Build.SourceBranchName)
- task: Docker@2
displayName: push
inputs:
command: push
containerRegistry: dockerhub
repository: wirvsvirussolid/solid
tags: |
app-$(Build.SourceBranchName)
- stage: deploy
dependsOn:
- image
condition: succeeded('image')
jobs:
- deployment: VMDeploy
displayName: deploy
environment:
name: SoliD
resourceType: VirtualMachine
strategy:
runOnce:
deploy:
steps:
- task: Bash@3
inputs:
targetType: 'inline'
workingDirectory: /
script: |
sudo mkdir -p $(app_dir)
sudo rsync -av $(devops_dir)/ $(app_dir)/
echo -e "APP_VIRTUAL_HOST=$(Build.SourceBranchName).$(app_rooturl)\nAPP_BRANCH=$(Build.SourceBranchName)" > $(env_file)
sudo mv $(env_file) $(app_dir)/.env
cd $(app_dir)
sudo docker-compose stop app
sudo docker-compose pull --parallel
sudo docker-compose up -d --no-deps app