Skip to content

Commit f4786ca

Browse files
author
Florian Wagner
authored
Adding Pipelines as Code (#26)
* Add yaml pipelines and build status Signed-off-by: Florian Wagner <[email protected]> * Correct Schema for OneClickDeploy YAML Signed-off-by: Florian Wagner <[email protected]> * Add docker build, container OneClickDeploy pipe Signed-off-by: Florian Wagner <[email protected]>
1 parent 9e9a5c4 commit f4786ca

File tree

7 files changed

+344
-1
lines changed

7 files changed

+344
-1
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
FROM ubuntu:16.04
2+
3+
# CREATE and SET WORKDIR
4+
RUN mkdir /prep
5+
WORKDIR /prep
6+
7+
# Update the list of products
8+
RUN apt-get update
9+
10+
# Install wget
11+
RUN apt-get -y install wget
12+
13+
# Install nslookup
14+
RUN apt-get -y install dnsutils
15+
16+
# Prerequisite for several installations
17+
RUN apt-get -y install apt-transport-https
18+
19+
# Install PowerShell Core
20+
RUN wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb
21+
RUN dpkg -i packages-microsoft-prod.deb
22+
RUN apt-get update
23+
RUN apt-get -y install powershell
24+
25+
# Install cURL
26+
RUN apt-get -y install curl
27+
28+
# Install Azure CLI with one command
29+
RUN curl -sL https://aka.ms/InstallAzureCLIDeb | bash -
30+
31+
# Install Terraform
32+
RUN wget -q https://releases.hashicorp.com/terraform/0.12.18/terraform_0.12.18_linux_amd64.zip
33+
RUN apt-get -y install unzip
34+
RUN unzip terraform_0.12.18_linux_amd64.zip
35+
RUN mv terraform /usr/local/bin
36+
37+
# Install .NET Core SDK
38+
RUN apt-get -y install dotnet-sdk-3.1
39+
40+
# Install NodeJS
41+
RUN curl -sL https://deb.nodesource.com/setup_13.x | bash -
42+
RUN apt-get -y install nodejs
43+
44+
# Install LUIS CLI
45+
RUN npm install -g luis-apis
46+
47+
# Last Update & upgrade
48+
RUN apt-get -y update
49+
RUN apt-get -y upgrade
50+
51+
# SET WORKDIR & REMOVE PREP folder
52+
WORKDIR /
53+
RUN rm /prep -r

AzureDevOps/agentbuild.yaml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# CI trigger
2+
trigger:
3+
branches:
4+
include:
5+
- master
6+
paths:
7+
include:
8+
- AzureDevOps/Agent
9+
10+
# PR builds
11+
pr:
12+
branches:
13+
include:
14+
- master
15+
paths:
16+
include:
17+
- AzureDevOps/Agent
18+
19+
# Scheduled Build on change Mo-Sa
20+
schedules:
21+
- cron: "30 17 * * 1-6"
22+
displayName: Daily 2:30am build on change (Seoul)
23+
branches:
24+
include:
25+
- master
26+
always: false
27+
- cron: "30 17 * * 0"
28+
displayName: Weekly 2:30am build (Seoul)
29+
branches:
30+
include:
31+
- master
32+
always: true
33+
34+
jobs:
35+
- job: pipelineagent_build
36+
displayName: 'Create and Push Pipeline Agent image'
37+
pool:
38+
name: Azure Pipelines
39+
vmImage: 'ubuntu-16.04'
40+
variables:
41+
- name: RepoName
42+
value: h2floh/geobotagent
43+
steps:
44+
- task: Docker@0
45+
displayName: 'Build an image'
46+
inputs:
47+
dockerFile: AzureDevOps/Agent/pipelineagent.dockerfile
48+
imageName: '$(RepoName):$(Build.BuildId)'
49+
includeLatestTag: true
50+
51+
- task: Docker@0
52+
displayName: 'Push an image'
53+
inputs:
54+
containerregistrytype: 'Container Registry'
55+
imageName: '$(RepoName):$(Build.BuildId)'
56+
dockerRegistryConnection: 'DockerHub h2floh'
57+
action: 'Push an image'
58+
includeLatestTag: true

AzureDevOps/geobotbuild.yaml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# No CI trigger
2+
trigger: none
3+
4+
# PR builds
5+
pr:
6+
branches:
7+
include:
8+
- master
9+
paths:
10+
include:
11+
- GeoBot
12+
13+
# Scheduled Build on change Mo-Sa
14+
schedules:
15+
- cron: "0 17 * * 1-6"
16+
displayName: Daily 2am build on change (Seoul)
17+
branches:
18+
include:
19+
- master
20+
always: false
21+
- cron: "0 17 * * 0"
22+
displayName: Weekly 2am build (Seoul)
23+
branches:
24+
include:
25+
- master
26+
always: true
27+
28+
jobs:
29+
- job: geobotnetcore
30+
displayName: Sample GeoBot Build
31+
pool:
32+
name: Azure Pipelines
33+
vmImage: 'ubuntu-16.04'
34+
variables:
35+
- name: BuildConfiguration
36+
value: Release
37+
- name: BuildPlatform
38+
value: 'any cpu'
39+
- name: BuildProjects
40+
value: 'GeoBot/**/*.csproj'
41+
- name: TestProjects
42+
value: 'GeoBot/**/*[Tt]ests/*.csproj'
43+
steps:
44+
- task: DotNetCoreCLI@2
45+
displayName: Restore
46+
inputs:
47+
command: restore
48+
projects: '$(BuildProjects)'
49+
50+
- task: DotNetCoreCLI@2
51+
displayName: Build
52+
inputs:
53+
projects: '$(BuildProjects)'
54+
arguments: '--configuration $(BuildConfiguration)'
55+
56+
- task: DotNetCoreCLI@2
57+
displayName: Test
58+
inputs:
59+
command: test
60+
projects: '$(TestProjects)'
61+
arguments: '--configuration $(BuildConfiguration)'
62+
63+
- task: DotNetCoreCLI@2
64+
displayName: Publish
65+
inputs:
66+
command: publish
67+
publishWebProjects: True
68+
arguments: '--configuration $(BuildConfiguration) --output $(build.artifactstagingdirectory)'
69+
zipAfterPublish: False

AzureDevOps/keyvaultcertbotbuild.yaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# CI trigger
2+
trigger:
3+
branches:
4+
include:
5+
- master
6+
paths:
7+
include:
8+
- SSL/Docker
9+
10+
# PR builds
11+
pr:
12+
branches:
13+
include:
14+
- master
15+
paths:
16+
include:
17+
- SSL/Docker
18+
19+
# Scheduled Build on change Mo-Sa
20+
schedules:
21+
- cron: "45 17 * * 1-6"
22+
displayName: Daily 2:45am build on change (Seoul)
23+
branches:
24+
include:
25+
- master
26+
always: false
27+
- cron: "45 17 * * 0"
28+
displayName: Weekly 2:45am build (Seoul)
29+
branches:
30+
include:
31+
- master
32+
always: true
33+
34+
jobs:
35+
- job: keyvaultcertbot_build
36+
displayName: 'Create and Push KeyVault CertBot image'
37+
pool:
38+
name: Azure Pipelines
39+
vmImage: 'ubuntu-16.04'
40+
variables:
41+
- name: RepoName
42+
value: h2floh/letsencrypt
43+
- name: ImageTag
44+
value: keyvault
45+
steps:
46+
- task: Docker@0
47+
displayName: 'Build an image'
48+
inputs:
49+
dockerFile: SSL/Docker/Dockerfile
50+
imageName: '$(RepoName):$(ImageTag)'
51+
includeLatestTag: false
52+
53+
- task: Docker@0
54+
displayName: 'Push an image'
55+
inputs:
56+
containerregistrytype: 'Container Registry'
57+
imageName: '$(RepoName):$(ImageTag)'
58+
dockerRegistryConnection: 'DockerHub h2floh'
59+
action: 'Push an image'
60+
includeLatestTag: false

AzureDevOps/oneclickdeploytest.yaml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
resources:
2+
containers:
3+
- container: geobotagent
4+
image: h2floh/geobotagent
5+
6+
# No CI trigger
7+
trigger: none
8+
9+
# PR builds
10+
pr:
11+
branches:
12+
include:
13+
- master
14+
paths:
15+
include:
16+
- Deploy
17+
18+
# Scheduled Build on change Mo-Sa
19+
schedules:
20+
- cron: "0 18 * * 1-6"
21+
displayName: Daily 3am build on change (Seoul)
22+
branches:
23+
include:
24+
- master
25+
always: false
26+
- cron: "0 18 * * 0"
27+
displayName: Weekly 3am build (Seoul)
28+
branches:
29+
include:
30+
- master
31+
always: true
32+
33+
jobs:
34+
- job: deploy_destroy
35+
displayName: 'Deploy & Destroy'
36+
pool:
37+
name: Azure Pipelines
38+
vmImage: 'ubuntu-16.04'
39+
container: geobotagent
40+
variables:
41+
- group: VSEFlorian
42+
steps:
43+
- pwsh: |
44+
# generate random bot name
45+
$BOTNAME = -join ((97..122) | Get-Random -Count 1 | % {[char]$_}) + -join ((48..57) + (97..122) | Get-Random -Count 9 | % {[char]$_})
46+
47+
Write-Host "##vso[task.setvariable variable=BOTNAME]$BOTNAME"
48+
displayName: 'Generate Bot Name'
49+
errorActionPreference: continue
50+
51+
- pwsh: |
52+
# Azure Login
53+
az login --service-principal --username $(ServicePrincipalID) --password $(ServicePrincipalSecret) --tenant $(TenantId)
54+
55+
# Terraform
56+
Write-Host "##vso[task.setvariable variable=ARM_CLIENT_ID]$(ServicePrincipalID)"
57+
Write-Host "##vso[task.setvariable variable=ARM_CLIENT_SECRET]$(ServicePrincipalSecret)"
58+
Write-Host "##vso[task.setvariable variable=ARM_SUBSCRIPTION_ID]$(SubscriptionId)"
59+
Write-Host "##vso[task.setvariable variable=ARM_TENANT_ID]$(TenantId)"
60+
displayName: 'Prepare Azure connection for CLI & Terraform '
61+
62+
- pwsh: |
63+
# One Click Deploy
64+
65+
Deploy/OneClickDeploy.ps1 -BOT_NAME $env:BOTNAME -YOUR_CERTIFICATE_EMAIL [email protected] -LETS_ENCRYPT_STAGING $True -AUTOAPPROVE $True
66+
67+
# $Lastexitcode $True -> Success, we have to change it to 0
68+
exit -not $LASTEXITCODE
69+
errorActionPreference: continue
70+
displayName: OneClickDeploy
71+
72+
- pwsh: |
73+
# One Click Destroy
74+
75+
Deploy/OneClickDestroy.ps1 -BOT_NAME $env:BOTNAME -AUTOAPPROVE $True
76+
77+
# $Lastexitcode $True -> Success, we have to change it to 0
78+
exit -not $LASTEXITCODE
79+
errorActionPreference: continue
80+
displayName: OneClickDestroy
81+
condition: always()
82+
83+
- pwsh: |
84+
# Az logout
85+
az logout
86+
87+
# Clear ENV Variables
88+
# Terraform
89+
$env:ARM_CLIENT_ID=""
90+
$env:ARM_CLIENT_SECRET=""
91+
$env:ARM_SUBSCRIPTION_ID=""
92+
$env:ARM_TENANT_ID=""
93+
failOnStderr: true
94+
displayName: 'Az Logout'
95+
condition: always()
96+
97+

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Azure Bot Framework based Geo Distributed Bot with failover capability
22

3+
[![Test OneClickDeploy](https://dev.azure.com/h2floh/GeoDistributedAzureBot/_apis/build/status/GeoDistributedAzureBot-Deploy?branchName=master&label=Test%20OneClickDeploy)](https://dev.azure.com/h2floh/GeoDistributedAzureBot/_build/latest?definitionId=6)
4+
[![Build Status Sample GeoBot](https://dev.azure.com/h2floh/GeoDistributedAzureBot/_apis/build/status/GeoDistributedAzureBot-Bot?branchName=master&label=Build%20GeoBot)](https://dev.azure.com/h2floh/GeoDistributedAzureBot/_build/latest?definitionId=5)
5+
6+
[![Build Status KeyVault CertBot Image](https://dev.azure.com/h2floh/GeoDistributedAzureBot/_apis/build/status/GeoDistributedAzureBot-KeyVaultCertBot?branchName=master&label=KeyVault%20CertBot)](https://dev.azure.com/h2floh/GeoDistributedAzureBot/_build/latest?definitionId=8)
7+
[![Build Status Pipeline Agent Image](https://dev.azure.com/h2floh/GeoDistributedAzureBot/_apis/build/status/GeoDistributedAzureBot-PipelineAgent?branchName=master&label=Pipeline%20Agent)](https://dev.azure.com/h2floh/GeoDistributedAzureBot/_build/latest?definitionId=7)
8+
39
This repo contains deployment scripts and a sample bot to spin up a geo distributed and geo failover capable bot, which can be accessed like any other Azure Bot Framework Service based bot via the Bot Framework Service Channels (Directline/WebChat and may more).
410

511
The idea of this repo is to give you a full working starting point for a Azure Cloud Native architecture pattern from where you can customize it for your Bot and your needs.

SSL/Docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ RUN apt-get -y install pwgen
99
# Install cURL
1010
RUN apt-get -y install curl
1111
# Install Azure CLI with one command
12-
RUN curl -sL https://aka.ms/InstallAzureCLIDeb | bash
12+
RUN curl -sL https://aka.ms/InstallAzureCLIDeb | bash -
1313

1414
# WORKDIR
1515
WORKDIR /

0 commit comments

Comments
 (0)