通过Codepipleline在Docker上进行Beanstalk分发不完整

问题描述 投票:0回答:1

我正在使用Codepipeline和Beanstalk On Docker配置CI / CD。

在Codepipeline的生成过程之前,它可以正常工作,但是Deploy一直失败。

失败的原因尚不清楚,但以下发生错误。服务:AmazonCloudFormation,消息:名为堆栈'awseb--stack'中止操作。当前状态:“ UPDATE_ROLLBACK_IN_PROGRESS”原因:以下资源失败创建:[AWSEBUpdateWaitConditionAFyGSI,AWSEBInstanceLaunchWaitConditionaiyqOL]。

我的Dockerfile和buildspec.yml,以及dockerrun.aws.json文件是

Dockerfile

FROM node:12.16.3-alpine as tsbuild

RUN mkdir /usr/app
WORKDIR /usr/app

COPY . /usr/app

RUN npm install
RUN npm run build

FROM node:12.16.3-alpine

RUN mkdir /usr/app
WORKDIR /usr/app

COPY --from=tsbuild /usr/app/dist /usr/app
COPY package*.json /usr/app/

RUN npm install -g pm2
RUN npm install

EXPOSE 8080

CMD ["npm", "run", "prod"]

buildspec.yml

version: 0.2
env:
  variables:
    AWS_DEFAULT_REGION: ap-northeast-2
    AWS_EB_DEPLOY_ENV: docker
phases:
  install:
    runtime-versions:
      docker: 18
      nodejs: 10
    commands:
      - aws --version
      - $(aws ecr get-login --no-include-email --region ap-northeast-2)
      - npm install
  build:
    commands:
      - docker build -t image .
  post_build:
    commands:
      - docker tag image:latest <ECR_URL>
      - docker <ECR_URL>

Dockerrun.aws.json

{
  "AWSEBDockerrunVersion": "1",
  "Image": {
    "Name": <ECR_URL>,
    "Update": "true"
  },
  "Ports": [
    {
      "ContainerPort": "8080"
    }],
  "Volumes": [],
  "Logging": "/var/log/nodejs"
}

而且,我正在使用ts-node,但是当我打开Beanstalk中分发的zip时,找不到dist文件夹。

我正在CodeDeploy中使用BuildArtifacts,而不是SourceArtifacts。这可能是个问题吗?

我想知道我做错了。

node.js docker amazon-elastic-beanstalk aws-codepipeline aws-codebuild
1个回答
0
投票

在我看来,'Dockerrun.aws.json'没有进入源包。如果它位于代码存储库的根目录中,请在buildspec.yml中添加以下内容:

artifacts:
  files:
    -  '**/*'
© www.soinside.com 2019 - 2024. All rights reserved.