为什么 AWS CodePipeline 抱怨 'Dockerfile' 和 'Dockerrun.aws.json'?

Why is AWS CodePipeline complaining about 'Dockerfile' and 'Dockerrun.aws.json'?

我正在为我的应用程序创建 CodePipeline,但是 AWS ElasticBeanstalk 的部署过程失败并出现以下错误:

Instance deployment: Both 'Dockerfile' and 'Dockerrun.aws.json' are missing in your source bundle. Include at least one of them. The deployment failed.

完整的消息错误为:

Deployment completed, but with errors: During an aborted deployment, some instances may have deployed the new application version. To ensure all instances are running the same version, re-deploy the appropriate application version. Failed to deploy application. Unsuccessful command execution on instance id(s) 'i-0b8823de2e7376c81'. Aborting the operation. [Instance: i-0b8823de2e7376c81] Command failed on instance. Return code: 1 Output: Engine execution has encountered an error.. Instance deployment failed. For details, see 'eb-engine.log'. Instance deployment: Both 'Dockerfile' and 'Dockerrun.aws.json' are missing in your source bundle. Include at least one of them. The deployment failed.

我的环境有 3 个容器,为了部署这个环境,我使用 docker-compose-qa.yml 文件和 AWS CodeBuild 我把这个文件定义为工件,如下图:

artifacts:
  files:
    - 'docker-compose-qa.yml'

docker-compose-qa.yml:

version: '3.8'

services:

    sitr-api:
        image: ${{ secrets.SITR_API_QA_URI_DOCKER_IMG }}
        container_name: sitr-api-qa
        environment:
            - ASPNETCORE_ENVIRONMENT=QA
        ports:
            - "9901:80"
        volumes:
            - "./Host-Logs:/app/App_Data/Logs"

    sitr-app:
        image: ${{ secrets.SITR_APP_QA_URI_DOCKER_IMG }}
        container_name: sitr-app-qa
        ports:
            - "9902:80"
    
    sitr-nginx: 
        image: ${{ secrets.SITR_NGINX_QA_URI_DOCKER_IMG }}
        container_name: sitr-nginx-qa
        depends_on: 
          - sitr-app
          - sitr-api
        ports: 
          - "80:80"

eb-engine.log 错误:

2021/10/26 22:07:27.977004 [ERROR] An error occurred during execution of command [app-deploy] - [Docker Specific Build Application]. Stop running the command. Error: Dockerfile and Dockerrun.aws.json are both missing, abort deployment

2021/10/26 22:07:27.977008 [INFO] Executing cleanup logic 2021/10/26 22:07:27.977098 [INFO] CommandService Response: {"status":"FAILURE","api_version":"1.0","results":[{"status":"FAILURE","msg":"Engine execution has encountered an error.","returncode":1,"events":[{"msg":"Instance deployment: Both 'Dockerfile' and 'Dockerrun.aws.json' are missing in your source bundle. Include at least one of them. The deployment failed.","timestamp":1635286047,"severity":"ERROR"},{"msg":"Instance deployment failed. For details, see 'eb-engine.log'.","timestamp":1635286047,"severity":"ERROR"}]}]}

我的 CodeBuild 只是构建了一个 dotnet 应用程序angular 应用程序 和为应用程序和 nginx 构建 3 docker 个容器

如果我手动 运行 我的 CodeBuild 然后在 AWS EB 中选择我的 docker-compose-qa.yml 文件,则发布是申请成功

我检查了 AWS S3 Bucket,正在将文件压缩到工件的文件夹中。

问题是:

为什么 Pipeline 抱怨 'Dockerfile''Dockerrun.aws.json' 文件不存在?如何指定它使用 docker-compose-qa.yml 文件?

根据评论。

问题是由错误的文件名引起的。它应该被称为 docker-compose.yml,而不是 docker-compose-qa.yml。重命名文件解决了问题。