Skip to content
Open
53 changes: 53 additions & 0 deletions .github/workflows/main_loadvm1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and deploy JAR app to Azure Web App - loadvm1

on:
push:
branches:
- main
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Java version
uses: actions/setup-java@v1
with:
java-version: '11'

- name: Build with Maven
run: mvn clean install

- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
with:
name: java-app
path: '${{ github.workspace }}/target/*.jar'

deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'Production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v3
with:
name: java-app

- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: 'loadvm1'
slot-name: 'Production'
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_99C6DD75542E45AFB582FBD98BCBAB76 }}
package: '*.jar'
55 changes: 55 additions & 0 deletions azure-pipelines-1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Docker
# Build and push an image to Azure Container Registry
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker

trigger:
paths:
include:
- vote/*
resources:
- repo: self

variables:
# Container registry service connection established during pipeline creation
dockerRegistryServiceConnection: '6bbf1581-e456-477d-8d90-f6c230952911'
imageRepository: 'voteapp'
containerRegistry: 'mylab2024.azurecr.io'
dockerfilePath: '$(Build.SourcesDirectory)/result/Dockerfile'
tag: '$(Build.BuildId)'

pool:
poolz
stages:
- stage: Build
displayName: Build and push stage
jobs:
- job: Build
displayName: Build
pool:
poolz
steps:
- task: Docker@2
displayName: Build image
inputs:
containerRegistry: '$(dockerRegistryServiceConnection)'
repository: '$(imageRepository)'
command: 'build'
Dockerfile: 'vote/Dockerfile'
tags: '$(tag)'
- stage: Push
displayName: Push
jobs:
- job: Push
displayName: Push
pool:
poolz # Specify the self-hosted agent pool here
steps:
- task: Docker@2
displayName: Push an image to container registry
inputs:
command: push
repository: $(imageRepository)
dockerfile: vote/dockerfilePath
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
55 changes: 55 additions & 0 deletions azure-pipelines-2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Docker
# Build and push an image to Azure Container Registry
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker

trigger:
paths:
include:
- worker/*
resources:
- repo: self

variables:
# Container registry service connection established during pipeline creation
dockerRegistryServiceConnection: '6bbf1581-e456-477d-8d90-f6c230952911'
imageRepository: 'workerapp'
containerRegistry: 'mylab2024.azurecr.io'
dockerfilePath: '$(Build.SourcesDirectory)/result/Dockerfile'
tag: '$(Build.BuildId)'

pool:
poolz
stages:
- stage: Build
displayName: Build and push stage
jobs:
- job: Build
displayName: Build
pool:
poolz
steps:
- task: Docker@2
displayName: Build image
inputs:
containerRegistry: '$(dockerRegistryServiceConnection)'
repository: '$(imageRepository)'
command: 'build'
Dockerfile: 'worker/Dockerfile'
tags: '$(tag)'
- stage: Push
displayName: Push
jobs:
- job: Push
displayName: Push
pool:
poolz # Specify the self-hosted agent pool here
steps:
- task: Docker@2
displayName: Push an image to container registry
inputs:
command: push
repository: $(imageRepository)
dockerfile: worker/dockerfilePath
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
42 changes: 42 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Docker
# Build and push an image to Azure Container Registry
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker

trigger:
paths:
include:
- results/*

resources:
- repo: self

variables:
# Container registry service connection established during pipeline creation
dockerRegistryServiceConnection: '64bdd185-ed43-42cd-9e22-93bee0445236'
imageRepository: 'azresultapp'
containerRegistry: 'mylab2024.azurecr.io'
dockerfilePath: '$(Build.SourcesDirectory)/result/Dockerfile'
tag: '$(Build.BuildId)'

# Agent VM image name
pool:
poolz

stages:
- stage: Build
displayName: Build and push stage
jobs:
- job: Build
displayName: Build
pool:
poolz
steps:
- task: Docker@2
displayName: Build and push an image to container registry
inputs:
command: buildAndPush
repository: $(imageRepository)
dockerfile: $(dockerfilePath)
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
4 changes: 2 additions & 2 deletions vote/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import json
import logging

option_a = os.getenv('OPTION_A', "Cats")
option_b = os.getenv('OPTION_B', "Dogs")
option_a = os.getenv('OPTION_A', "Summer")
option_b = os.getenv('OPTION_B', "Winter")
hostname = socket.gethostname()

app = Flask(__name__)
Expand Down