From ca7aed8d9fddb009d88844247d8981bf486e321c Mon Sep 17 00:00:00 2001 From: Matt Robey Date: Thu, 2 Jul 2020 17:21:29 -0500 Subject: [PATCH 1/3] testing out CI pipeline with microsoft flask tutorial repo [skip ci] --- azure-pipelines.yml | 87 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 azure-pipelines.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 000000000..a2076fd0e --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,87 @@ +# Python to Linux Web App on Azure +# Build your Python project and deploy it to Azure as a Linux Web App. +# Change python version to one thats appropriate for your application. +# https://docs.microsoft.com/azure/devops/pipelines/languages/python + +trigger: +- master + +variables: + # Azure Resource Manager connection created during pipeline creation + azureServiceConnectionId: 'c8420a67-37e8-41c6-a778-b26aa6884a81' + + # Web app name + webAppName: 'DSPK-Django-demo' + + # Agent VM image name + vmImageName: 'ubuntu-latest' + + # Environment name + environmentName: 'DSPK-Django-demo' + + # Project root folder. Point to the folder containing manage.py file. + projectRoot: $(System.DefaultWorkingDirectory) + + # Python version: 3.7 + pythonVersion: '3.7' + +stages: +- stage: Build + displayName: Build stage + jobs: + - job: BuildJob + pool: + vmImage: $(vmImageName) + steps: + - task: UsePythonVersion@0 + inputs: + versionSpec: '$(pythonVersion)' + displayName: 'Use Python $(pythonVersion)' + + - script: | + python -m venv antenv + source antenv/bin/activate + python -m pip install --upgrade pip + pip install setup + pip install -r requirements.txt + workingDirectory: $(projectRoot) + displayName: "Install requirements" + + - task: ArchiveFiles@2 + displayName: 'Archive files' + inputs: + rootFolderOrFile: '$(projectRoot)' + includeRootFolder: false + archiveType: zip + archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip + replaceExistingArchive: true + + - upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip + displayName: 'Upload package' + artifact: drop + +- stage: Deploy + displayName: 'Deploy Web App' + dependsOn: Build + condition: succeeded() + jobs: + - deployment: DeploymentJob + pool: + vmImage: $(vmImageName) + environment: $(environmentName) + strategy: + runOnce: + deploy: + steps: + + - task: UsePythonVersion@0 + inputs: + versionSpec: '$(pythonVersion)' + displayName: 'Use Python version' + + - task: AzureWebApp@1 + displayName: 'Deploy Azure Web App : DSPK-Django-demo' + inputs: + azureSubscription: $(azureServiceConnectionId) + appName: $(webAppName) + package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip \ No newline at end of file From 58fd4726b1c06af84ff94820484bf915b5c30fb2 Mon Sep 17 00:00:00 2001 From: Matt Robey Date: Thu, 2 Jul 2020 17:28:01 -0500 Subject: [PATCH 2/3] added gunicorn startup command --- azure-pipelines.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a2076fd0e..001939859 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -84,4 +84,6 @@ stages: inputs: azureSubscription: $(azureServiceConnectionId) appName: $(webAppName) - package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip \ No newline at end of file + package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip + + startUpCommand: 'gunicorn --bind=0.0.0.0 --workers=4 startup:app' \ No newline at end of file From b8fab8ed366f4af9c42ec76a8c4e2f390c9053d3 Mon Sep 17 00:00:00 2001 From: Matt Robey Date: Fri, 3 Jul 2020 13:33:35 -0500 Subject: [PATCH 3/3] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 001939859..a8e1aa391 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -11,13 +11,13 @@ variables: azureServiceConnectionId: 'c8420a67-37e8-41c6-a778-b26aa6884a81' # Web app name - webAppName: 'DSPK-Django-demo' + webAppName: 'DSPK-dev' # Agent VM image name vmImageName: 'ubuntu-latest' # Environment name - environmentName: 'DSPK-Django-demo' + environmentName: 'DSPK-dev' # Project root folder. Point to the folder containing manage.py file. projectRoot: $(System.DefaultWorkingDirectory)