Azure / webapps-deploy

Enable GitHub developers to deploy to Azure WebApps using GitHub Actions
MIT License
262 stars 184 forks source link

Multi-Container deployment errors for "Absent Docker-Compose" despite configuration-file input #297

Closed nathanroberts55 closed 1 year ago

nathanroberts55 commented 1 year ago

Using Azure Web Apps to deploy a small multi-container app using GitHub Actions (azure/webapps-deploy@v2). Ran into an issue while running the action for a test deployment. I have the following code in a main_appName.yml that was originally generated by Azure Web Apps when I switched to GitHub actions and modified to work for both containers.

I have the build that works perfectly fine:

# 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 container app to Azure Web App - appName

on:
  push:
    branches:
      - main
  workflow_dispatch:

jobs:
  build:
    runs-on: 'ubuntu-latest'

    steps:
    - name: Checkout
      uses: actions/checkout@v2

    - name: Set up Docker Buildx
      uses: docker/setup-buildx-action@v1

    - name: Log in to registry
      uses: docker/login-action@v1
      with:
        registry: https://index.docker.io/v1/
        username: ${{ secrets.AzureAppService_ContainerUsername_264c9a4b8acd41ef96e3fbe0b252a0bc }}
        password: ${{ secrets.AzureAppService_ContainerPassword_e7819aeed4ed40f7a3938fbdbae9df93 }}

    - name: Build and push App container image to registry
      uses: docker/build-push-action@v2
      with:
        push: true
        context: ./app
        tags: username_REDACTED/containerName_REDACTED-app:${{ github.sha }}
        file: ./app/Dockerfile

    - name: Build and push container Web image to registry
      uses: docker/build-push-action@v2
      with:
        push: true
        context: ./scraping
        tags: username_REDACTED/containerName_REDACTED-web:${{ github.sha }}
        file: ./scraping/Dockerfile

The problem occurs in the deployment:

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

    steps:
    - name: Login via Az module
      uses: azure/login@v1
      with:
        creds: ${{secrets.AZURE_CREDENTIALS}}

    - name: Deploy App to Azure Web App
      id: deploy-to-webapp
      uses: azure/webapps-deploy@v2
      with:
        app-name: 'appName_REDACTED'
        slot-name: 'production'
        images: |-
          'index.docker.io/${{ secrets.AzureAppService_ContainerUsername_264c9a4b8acd41ef96e3fbe0b252a0bc }}/username_REDACTED/containerName_REDACTED-app:${{ github.sha }}' 
          'index.docker.io/${{ secrets.AzureAppService_ContainerUsername_264c9a4b8acd41ef96e3fbe0b252a0bc }}/username_REDACTED/containerName_REDACTED-web:${{ github.sha }}'
        configuration-file: azure-compose.yml

When the deployment runs, I get the error:

Run azure/webapps-deploy@v[2](https://github.com/username_REDACTED/repoName_REDACTED/actions/runs/4337777575/jobs/7574027053#step:3:2)
  with:
    app-name: appName_REDACTED
    slot-name: production
    images: 'index.docker.io/***/***/containerName_REDACTED:0687ea5ec5[3](https://github.com/username_REDACTED/repoName_REDACTED/actions/runs/4337777575/jobs/7574027053#step:3:3)e9377d2[4](https://github.com/username_REDACTED/repoName_REDACTED/actions/runs/4337777575/jobs/7574027053#step:3:4)0e2223d1[5](https://github.com/username_REDACTED/repoName_REDACTED/actions/runs/4337777575/jobs/7574027053#step:3:5)28034c273952' 
  'index.docker.io/***/***/containerName_REDACTED-web:0[6](https://github.com/username_REDACTED/repoName_REDACTED/actions/runs/4337777575/jobs/7574027053#step:3:6)8[7](https://github.com/username_REDACTED/repoName_REDACTED/actions/runs/4337777575/jobs/7574027053#step:3:7)ea5ec53e9377d240e2223d152[8](https://github.com/username_REDACTED/repoName_REDACTED/actions/runs/4337777575/jobs/7574027053#step:3:8)034c273[9](https://github.com/username_REDACTED/repoName_REDACTED/actions/runs/4337777575/jobs/7574027053#step:3:9)52'
    configuration-file: azure-compose.yml
    package: .
  env:
    AZURE_HTTP_USER_AGENT: 
    AZUREPS_HOST_ENVIRONMENT:
*Error: Deployment Failed with Error: Error: Multiple images indicate multi-container deployment type, but Docker-compose file is absent.

I thought from my understanding and reference to the actions.yml where it says that the configuration-file: is for Web App Containers to specify the path of the Docker-Compose and the error message is specifying that I need the Docker-Compose that I was meeting all of the requirements. However I continue to get the same error.

Here is my azure-compose.yml. It worked when I was initially using it for when I was setup using the container registry:

version: '3'
services:
  app:
    image: username_REDACTED/containerName_REDACTED-app:latest
    container-name:containerName_REDACTED
    restart: unless-stopped
    volumes:
      - output:/app/output
    command: streamlit run app.py --server.port=80
    ports:
      - 80:80
  web:
    image: username_REDACTED/containerName_REDACTED-web:latest
    container-name: containerName_REDACTED
    restart: unless-stopped
    volumes:
      - output:/scraping/output
    ports:
      - 8080:8080

volumes:
  output:
    driver: azure_file
    driver_opts:
     share_name: shareName_REDACTED
     storage_account_name: storageName_REDACTED

and here is my repo directory structure:

ProjectName
|   .env
|   .gitignore
|   azure-compose.yml
|   docker-compose.yml
|   README.md
|   
+---.github
|   \---workflows
|           main_appName.yml
|           
+---app
|       app.py
|       Dockerfile
|       requirements.txt   
+---output
+---scraping
        Dockerfile
|   |   
|   +---output
|   

I could completely be missing something (so any guidance would be appreciated), additionally, I know that the multi-container features are still being built out. But as of right now I'm not sure exactly what I might be doing wrong and why it isn't working. Thanks!

github-actions[bot] commented 1 year ago

This issue is idle because it has been open for 14 days with no activity.

sgollapudi77 commented 1 year ago

Hi @nathanroberts55 , my assumption is the docker-compose file is not in the PWD(Present Working directory) the code is running. You can check this by printing ls -R and echo $PWD in the github actions to verify. The workaround is you can utilize the actions/checkout action to fetch the repository contents in to the PWD and run the github action.

Please check if this works for you.

github-actions[bot] commented 1 year ago

This issue is idle because it has been open for 14 days with no activity.

sgollapudi77 commented 1 year ago

"We're closing this issue, please check the work around mentioned and feel free to open this issue if anything comes up".