From 955c2c1f0ae20a47d25fddcde5493238d19a0545 Mon Sep 17 00:00:00 2001 From: Harsh-Microsoft Date: Fri, 7 Mar 2025 15:01:08 +0530 Subject: [PATCH 1/5] Updated Docker workflow to support main-image-migration branch and adjust registry login conditions --- .github/workflows/docker-build-and-push.yml | 35 ++++++++++++++------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/.github/workflows/docker-build-and-push.yml b/.github/workflows/docker-build-and-push.yml index 6cd52c78..fafbdcd7 100644 --- a/.github/workflows/docker-build-and-push.yml +++ b/.github/workflows/docker-build-and-push.yml @@ -2,7 +2,7 @@ name: Build Docker and Optional Push on: push: - branches: [main, dev, demo] + branches: [main, dev, demo, main-image-migration] pull_request: branches: [main, dev, demo] types: @@ -24,16 +24,16 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - - name: Log in to Azure Container Registry - if: ${{ github.ref_name == 'main' }} + - name: Log in to Azure Container Registry - External Registry + if: ${{ github.ref_name == 'main-image-migration' }} uses: azure/docker-login@v2 with: login-server: ${{ secrets.ACR_LOGIN_SERVER }} username: ${{ secrets.ACR_USERNAME }} password: ${{ secrets.ACR_PASSWORD }} - - name: Log in to Azure Container Registry (Dev/Demo/Dependabotchanges) - if: ${{ github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'dependabotchanges' }} + - name: Log in to Azure Container Registry (Main/Dev/Demo/Dependabotchanges) - Internal Registry + if: ${{ github.ref_name == 'main-image-migration' ||github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'dependabotchanges' }} uses: azure/docker-login@v2 with: login-server: ${{ secrets.ACR_DEV_LOGIN_SERVER }} @@ -44,14 +44,14 @@ jobs: id: date run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT - - name: Get registry - id: registry - run: echo "registry=${{ github.ref_name == 'main' && secrets.ACR_LOGIN_SERVER || secrets.ACR_DEV_LOGIN_SERVER }}" >> $GITHUB_OUTPUT + # - name: Get registry + # id: registry + # run: echo "registry=${{ github.ref_name == 'main' && secrets.ACR_LOGIN_SERVER || secrets.ACR_DEV_LOGIN_SERVER }}" >> $GITHUB_OUTPUT - name: Determine Tag Name Based on Branch id: determine_tag run: | - if [[ "${{ github.ref_name }}" == "main" ]]; then + if [[ "${{ github.ref_name }}" == "main-image-migration" ]]; then echo "tagname=latest" >> $GITHUB_OUTPUT elif [[ "${{ github.ref_name }}" == "dev" ]]; then echo "tagname=dev" >> $GITHUB_OUTPUT @@ -64,12 +64,25 @@ jobs: fi - - name: Build Docker Image and optionally push + - name: Build Docker Image and optionally push - Dev/Demo/Dependabotchanges uses: docker/build-push-action@v6 with: context: . file: WebApp.Dockerfile - push: ${{ github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'dependabotchanges' }} + push: ${{github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'dependabotchanges' }} tags: | ${{ steps.registry.outputs.registry }}/webapp:${{ steps.determine_tag.outputs.tagname }} ${{ steps.registry.outputs.registry }}/webapp:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }} + + - name: Build Docker Image and optionally push - Main + uses: docker/build-push-action@v6 + with: + context: . + file: WebApp.Dockerfile + push: ${{github.ref_name == 'main-image-migration' }} + tags: | + ${{ secrets.ACR_LOGIN_SERVER }}/webapp:${{ steps.determine_tag.outputs.tagname }} + ${{ secrets.ACR_LOGIN_SERVER }}/webapp:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }} + ${{ secrets.ACR_DEV_LOGIN_SERVER }}/webapp:${{ steps.determine_tag.outputs.tagname }} + ${{ secrets.ACR_DEV_LOGIN_SERVER }}/webapp:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }} + From f55ece9d8944701bc140c83338bbec656393d775 Mon Sep 17 00:00:00 2001 From: Harsh-Microsoft Date: Fri, 7 Mar 2025 15:07:46 +0530 Subject: [PATCH 2/5] Refactor Docker workflow to streamline registry handling and improve tag naming conventions --- .github/workflows/docker-build-and-push.yml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/docker-build-and-push.yml b/.github/workflows/docker-build-and-push.yml index fafbdcd7..34665c57 100644 --- a/.github/workflows/docker-build-and-push.yml +++ b/.github/workflows/docker-build-and-push.yml @@ -44,9 +44,11 @@ jobs: id: date run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT - # - name: Get registry - # id: registry - # run: echo "registry=${{ github.ref_name == 'main' && secrets.ACR_LOGIN_SERVER || secrets.ACR_DEV_LOGIN_SERVER }}" >> $GITHUB_OUTPUT + - name: Get registry + id: registry + run: | + echo "ext_registry=${{ secrets.ACR_LOGIN_SERVER }}" >> $GITHUB_OUTPUT + echo "int_registry=${{ secrets.ACR_DEV_LOGIN_SERVER }}" >> $GITHUB_OUTPUT - name: Determine Tag Name Based on Branch id: determine_tag @@ -71,8 +73,8 @@ jobs: file: WebApp.Dockerfile push: ${{github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'dependabotchanges' }} tags: | - ${{ steps.registry.outputs.registry }}/webapp:${{ steps.determine_tag.outputs.tagname }} - ${{ steps.registry.outputs.registry }}/webapp:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }} + ${{ steps.registry.outputs.int_registry }}/webapp:${{ steps.determine_tag.outputs.tagname }} + ${{ steps.registry.outputs.int_registry }}/webapp:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }} - name: Build Docker Image and optionally push - Main uses: docker/build-push-action@v6 @@ -81,8 +83,8 @@ jobs: file: WebApp.Dockerfile push: ${{github.ref_name == 'main-image-migration' }} tags: | - ${{ secrets.ACR_LOGIN_SERVER }}/webapp:${{ steps.determine_tag.outputs.tagname }} - ${{ secrets.ACR_LOGIN_SERVER }}/webapp:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }} - ${{ secrets.ACR_DEV_LOGIN_SERVER }}/webapp:${{ steps.determine_tag.outputs.tagname }} - ${{ secrets.ACR_DEV_LOGIN_SERVER }}/webapp:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }} + ${{ steps.registry.outputs.ext_registry }}/webapp:${{ steps.determine_tag.outputs.tagname }} + ${{ steps.registry.outputs.ext_registry }}/webapp:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }} + ${{ steps.registry.outputs.int_registry }}/webapp:${{ steps.determine_tag.outputs.tagname }} + ${{ steps.registry.outputs.int_registry }}/webapp:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }} From b654c52cd4c019e79f9c964bd0e2b0c6a89f4810 Mon Sep 17 00:00:00 2001 From: Harsh-Microsoft Date: Fri, 7 Mar 2025 15:20:46 +0530 Subject: [PATCH 3/5] Update Docker workflow to conditionally handle registry settings and improve image push logic for main-image-migration branch --- .github/workflows/docker-build-and-push.yml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docker-build-and-push.yml b/.github/workflows/docker-build-and-push.yml index 34665c57..9ef7609f 100644 --- a/.github/workflows/docker-build-and-push.yml +++ b/.github/workflows/docker-build-and-push.yml @@ -47,8 +47,12 @@ jobs: - name: Get registry id: registry run: | - echo "ext_registry=${{ secrets.ACR_LOGIN_SERVER }}" >> $GITHUB_OUTPUT - echo "int_registry=${{ secrets.ACR_DEV_LOGIN_SERVER }}" >> $GITHUB_OUTPUT + if [[ "${{ github.ref_name }}" == "main-image-migration" ]]; then + echo "ext_registry=${{ secrets.ACR_LOGIN_SERVER }}" >> $GITHUB_OUTPUT + echo "int_registry=${{ secrets.ACR_DEV_LOGIN_SERVER }}" >> $GITHUB_OUTPUT + else + echo "int_registry=${{ secrets.ACR_DEV_LOGIN_SERVER }}" >> $GITHUB_OUTPUT + fi - name: Determine Tag Name Based on Branch id: determine_tag @@ -63,20 +67,20 @@ jobs: echo "tagname=dependabotchanges" >> $GITHUB_OUTPUT else echo "tagname=default" >> $GITHUB_OUTPUT - fi - - name: Build Docker Image and optionally push - Dev/Demo/Dependabotchanges + - name: Build Docker Image and optionally push - Internal Registry uses: docker/build-push-action@v6 with: context: . file: WebApp.Dockerfile - push: ${{github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'dependabotchanges' }} + push: ${{ github.ref_name == 'main-image-migration' || github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'dependabotchanges' }} tags: | ${{ steps.registry.outputs.int_registry }}/webapp:${{ steps.determine_tag.outputs.tagname }} ${{ steps.registry.outputs.int_registry }}/webapp:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }} - - name: Build Docker Image and optionally push - Main + - name: Build Docker Image and optionally push - External Registry + if: ${{ github.ref_name == 'main-image-migration' }} uses: docker/build-push-action@v6 with: context: . @@ -85,6 +89,4 @@ jobs: tags: | ${{ steps.registry.outputs.ext_registry }}/webapp:${{ steps.determine_tag.outputs.tagname }} ${{ steps.registry.outputs.ext_registry }}/webapp:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }} - ${{ steps.registry.outputs.int_registry }}/webapp:${{ steps.determine_tag.outputs.tagname }} - ${{ steps.registry.outputs.int_registry }}/webapp:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }} From d557bf1eb3229d480fbcce1b58a387b6bc9956cf Mon Sep 17 00:00:00 2001 From: Harsh-Microsoft Date: Fri, 7 Mar 2025 15:46:20 +0530 Subject: [PATCH 4/5] Update Docker workflow to remove main-image-migration branch references and replace with main branch references --- .github/workflows/docker-build-and-push.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docker-build-and-push.yml b/.github/workflows/docker-build-and-push.yml index 9ef7609f..1590336c 100644 --- a/.github/workflows/docker-build-and-push.yml +++ b/.github/workflows/docker-build-and-push.yml @@ -2,7 +2,7 @@ name: Build Docker and Optional Push on: push: - branches: [main, dev, demo, main-image-migration] + branches: [main, dev, demo] pull_request: branches: [main, dev, demo] types: @@ -25,7 +25,7 @@ jobs: uses: docker/setup-buildx-action@v1 - name: Log in to Azure Container Registry - External Registry - if: ${{ github.ref_name == 'main-image-migration' }} + if: ${{ github.ref_name == 'main' }} uses: azure/docker-login@v2 with: login-server: ${{ secrets.ACR_LOGIN_SERVER }} @@ -33,7 +33,7 @@ jobs: password: ${{ secrets.ACR_PASSWORD }} - name: Log in to Azure Container Registry (Main/Dev/Demo/Dependabotchanges) - Internal Registry - if: ${{ github.ref_name == 'main-image-migration' ||github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'dependabotchanges' }} + if: ${{ github.ref_name == 'main' ||github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'dependabotchanges' }} uses: azure/docker-login@v2 with: login-server: ${{ secrets.ACR_DEV_LOGIN_SERVER }} @@ -47,7 +47,7 @@ jobs: - name: Get registry id: registry run: | - if [[ "${{ github.ref_name }}" == "main-image-migration" ]]; then + if [[ "${{ github.ref_name }}" == "main" ]]; then echo "ext_registry=${{ secrets.ACR_LOGIN_SERVER }}" >> $GITHUB_OUTPUT echo "int_registry=${{ secrets.ACR_DEV_LOGIN_SERVER }}" >> $GITHUB_OUTPUT else @@ -57,7 +57,7 @@ jobs: - name: Determine Tag Name Based on Branch id: determine_tag run: | - if [[ "${{ github.ref_name }}" == "main-image-migration" ]]; then + if [[ "${{ github.ref_name }}" == "main" ]]; then echo "tagname=latest" >> $GITHUB_OUTPUT elif [[ "${{ github.ref_name }}" == "dev" ]]; then echo "tagname=dev" >> $GITHUB_OUTPUT @@ -74,18 +74,18 @@ jobs: with: context: . file: WebApp.Dockerfile - push: ${{ github.ref_name == 'main-image-migration' || github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'dependabotchanges' }} + push: ${{ github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'dependabotchanges' }} tags: | ${{ steps.registry.outputs.int_registry }}/webapp:${{ steps.determine_tag.outputs.tagname }} ${{ steps.registry.outputs.int_registry }}/webapp:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }} - name: Build Docker Image and optionally push - External Registry - if: ${{ github.ref_name == 'main-image-migration' }} + if: ${{ github.ref_name == 'main' }} uses: docker/build-push-action@v6 with: context: . file: WebApp.Dockerfile - push: ${{github.ref_name == 'main-image-migration' }} + push: ${{github.ref_name == 'main' }} tags: | ${{ steps.registry.outputs.ext_registry }}/webapp:${{ steps.determine_tag.outputs.tagname }} ${{ steps.registry.outputs.ext_registry }}/webapp:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }} From 319beea86be7cd0f31a142f30aab06fb2ea825ec Mon Sep 17 00:00:00 2001 From: Harsh-Microsoft Date: Fri, 7 Mar 2025 16:24:18 +0530 Subject: [PATCH 5/5] Update WebAppImageName variable to use new container registry and add environmentName parameter to main.json --- infra/main.bicep | 2 +- infra/main.json | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/infra/main.bicep b/infra/main.bicep index 60e511be..b8fabf3a 100644 --- a/infra/main.bicep +++ b/infra/main.bicep @@ -166,7 +166,7 @@ param AzureOpenAIStopSequence string = '\n' @description('Whether or not to stream responses from Azure OpenAI? True or False.') param AzureOpenAIStream bool = true -var WebAppImageName = 'DOCKER|acrbyocga.azurecr.io/webapp:latest' +var WebAppImageName = 'DOCKER|byocgacontainerreg.azurecr.io/webapp:latest' var cosmosdb_database_name = 'db_conversation_history' var cosmosdb_container_name = 'conversations' var roleDefinitionId = '00000000-0000-0000-0000-000000000002' diff --git a/infra/main.json b/infra/main.json index 7c75b526..1a047a4b 100644 --- a/infra/main.json +++ b/infra/main.json @@ -5,14 +5,25 @@ "_generator": { "name": "bicep", "version": "0.33.93.31351", - "templateHash": "896617532796464630" + "templateHash": "7005910716688710298" } }, "parameters": { + "environmentName": { + "type": "string", + "minLength": 3, + "maxLength": 10, + "metadata": { + "description": "A unique prefix for all resources in this deployment. This should be 3-10 characters long:" + } + }, "HostingPlanName": { "type": "string", "defaultValue": "[guid(resourceGroup().id)]", "metadata": { + "azd": { + "type": "location" + }, "description": "Name of App Service plan" } }, @@ -263,7 +274,7 @@ } }, "variables": { - "WebAppImageName": "DOCKER|acrbyocga.azurecr.io/webapp:latest", + "WebAppImageName": "DOCKER|byocgacontainerreg.azurecr.io/webapp:latest", "cosmosdb_database_name": "db_conversation_history", "cosmosdb_container_name": "conversations", "roleDefinitionId": "00000000-0000-0000-0000-000000000002",