AWSEBDockerrunVersion 在 Dockerrun.aws.json 和构建工件中,但部署显示它丢失。

huangapple go评论53阅读模式
英文:

AWSEBDockerrunVersion is in Dockerrun.aws.json and Build artifact but Deploy says it is missing

问题

"我正在尝试将Web应用程序部署到ElasticBeanstalk,并使用CodePipeline来进行源代码管理、构建和部署。源代码管理和构建已经完成并正常工作。但当到达部署阶段时,我收到以下错误消息:

部署已完成,但存在错误:无法部署应用程序。ECS应用程序源捆绑验证错误:缺少AWSEBDockerrunVersion。

供参考,以下是我的buildspec.yml:

version: 0.2
phases:
  pre_build:
    commands:
      - echo 登录到Docker
      - docker login --username $DOCKERHUB_USERNAME --password $DOCKERHUB_PASS
      - echo 登录到Amazon ECR...
      - aws ecr get-login-password --region ${AWS_DEFAULT_REGION} | docker login --username AWS --password-stdin ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com
  build:
    commands:
      - echo 构建开始于 `date`
      - echo 正在构建Docker镜像...
      - docker-compose --file=docker-compose.aws.production.yml build
  post_build:
    commands:
      - echo 构建完成于 `date`
      - echo 推送Docker镜像
      - docker-compose --file=docker-compose.aws.production.yml push
artifacts:
  files:
    - 'Dockerrun.aws.json'

以及我的Dockerrun.aws.json:

{
    "AWSEBDockerrunversion": 2,
    "containerDefinitions": [
        {
            "name": "client",
            "image": "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/orcinus-client-prod",
            "hostname": "client",
            "essential": true,
            "memory": 1024,
            "portMappings": [
                {
                    "hostPort": 80,
                    "containerPort": 80
                }
            ]
        },
        {
            "name": "server",
            "image": "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/orcinus-server-prod",
            "hostname": "server",
            "essential": true,
            "memory": 512,
            "portMappings":[
                {
                    "hostPort": 4000,
                    "containerPort": 4000
                }
            ]
        }
    ]
}

部署阶段正在使用从构建阶段导出的BuildArtifact作为输入工件。我的EB环境使用64位Amazon Linux 2/3.2.9平台上运行的ECS。我曾尝试使用Docker平台,但文档中建议使用其他平台。我已经尝试寻找解决方法一段时间了,但一直没有成功。我对AWS和应用程序部署相对新手,因此非常感谢任何帮助。"

请注意,我已经删除了重复的部分,只保留了一次提及的内容。

英文:

I am trying to deploy an web app to ElasticBeanstalk and am usind CodePipeline to source, build, and deploy. Source and Build are completing and working fine. When it gets to Deploy, I get the following error:

Deployment completed, but with errors: Failed to deploy application. ECS Application sourcebundle validation error: AWSEBDockerrunVersion is missing.

For reference, here is my buildspec.yml:

version: 0.2
phases:
  pre_build:
    commands:
      - echo Logging in to Docker
      - docker login --username $DOCKERHUB_USERNAME --password $DOCKERHUB_PASS
      - echo Logging in to Amazon ECR...
      - aws ecr get-login-password --region ${AWS_DEFAULT_REGION} | docker login --username AWS --password-stdin ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com
  build:
    commands:
      - echo Build started on `date`
      - echo Building the Docker image...
      - docker-compose --file=docker-compose.aws.production.yml build
  post_build:
    commands:
      - echo Build complete on `date`
      - echo Pushing the Docker image
      - docker-compose --file=docker-compose.aws.production.yml push
artifacts:
  files:
    - 'Dockerrun.aws.json'

and my Dockerrun.aws.json:

{
    "AWSEBDockerrunversion": 2,
    "containerDefinitions": [
        {
            "name": "client",
            "image": "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/orcinus-client-prod",
            "hostname": "client",
            "essential": true,
            "memory": 1024,
            "portMappings": [
                {
                    "hostPort": 80,
                    "containerPort": 80
                }
            ]
        },
        {
            "name": "server",
            "image": "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/orcinus-server-prod",
            "hostname": "server",
            "essential": true,
            "memory": 512,
            "portMappings":[
                {
                    "hostPort": 4000,
                    "containerPort": 4000
                }
            ]
        }
    ]
}

The Deploy stage is using the BuildArtifact exported from the Build stage as an Input Artifact as well.

My EB Environment is using the ECS running on 64bit Amazon Linux 2/3.2.9 platform. I've tried using the Docker platform but it recommends otherwise in the docs. I have been trying to find a solution to this for a while but haven't been able to. I am pretty new to AWS and deploying apps so any help would be greatly appreciated.

The Deploy stage is using the BuildArtifact exported from the Build stage as an Input Artifact as well.

My EB Environment is using the docker platform with ECS running on 64bit Amazon Linux 2/3.2.9 platform branch. I've tried using the Docker platform branch but it recommends otherwise in the docs. I have been trying to find a solution to this for a while but haven't been able to. I've tried using the input artifacts from SourceArtifact instead and that didn't work. I've updated my the value of AWSEBDockerrunversion to use double quotes or version 1 or 3 and got similar. I've tried to look at the ECS instance associated with the environment but I couldn't find anything related and nothing related to my Dockerrun.aws.json in the task definitions. I am pretty new to AWS and deploying apps so any help would be greatly appreciated.

答案1

得分: 0

我找到了问题。问题在于需要将关键字更改为AWSEBDockerrunVersion,而不是AWSEBDockerrunversion。

英文:

I found the issue. It was the key needing to be AWSEBDockerrunVersion not AWSEBDockerrunversion.

huangapple
  • 本文由 发表于 2023年7月13日 20:33:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/76679434.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定