3

我正在使用 CodePipeline 将 git 主分支上的任何内容部署到 Elastic Beanstalk。

我按照本教程扩展了默认的 nginx 配置(特别是 max-body-size):https ://medium.com/swlh/using-ebextensions-to-extend-nginx-default-configuration-in-aws-elastic-豆茎-189b844ab6ad

但是,因为我没有使用标准的 eb deploy 命令,所以我认为 CodePipeline 流程不会进入 .ebextension 目录并执行它应该做的事情。

有没有办法使用代码管道(所以我可以从 master 获得 CI/CD)以及利用 .ebextension 的好处?

4

5 回答 5

3

如果您直接使用 eb deploy 命令,这是否有效?如果是,那么我会尝试使用管道执行历史来查找最近的工件以使用 eb deploy 命令下载和测试。

于 2019-10-04T23:03:25.037 回答
2

如果 CodePipeline 的 Elastic Beanstalk Job Worker 不能很好地与 ebextensions 配合使用,我会认为部署到 Elastic Beanstalk 完全没用。

我相信 ebextensions 本身存在一些问题。您可以调查这些日志文件中的执行情况,以查看部署期间是否出现问题:

  • /var/log/eb-activity.log
  • /var/log/eb-commandprocessor.log
  • /var/log/eb-version-deployment.log
于 2019-10-05T05:43:20.700 回答
1

在 Elastic Beanstalk 上部署时,.ebextension 下的所有配置文件将根据优先顺序执行。因此,无论您使用的是 codepipeline 还是 eb deploy,都将执行 ebextension 目录中的所有文件。所以,你不必担心这一点。

于 2019-10-09T05:37:25.327 回答
1

请注意您使用的平台,因为“64bit Amazon Linux 2 v5.0.2”而不是.ebextension您必须使用.platform.

  1. 创建.platform目录而不是.ebextension

  2. 像在这个路径中一样创建子文件夹和 proxy.conf 文件.platform/nginx/conf.d/proxy.conf

  3. proxy.conf写下你需要的东西,以防 req 正文大小client_max_body_size 20M;

于 2020-06-12T11:02:51.610 回答
0

我解决了这个问题。您需要在部署中包含 .ebextension 文件夹。我只复制 dist 文件,然后我也需要包含:- .ebextensions/**/*

例子:

## Required mapping. Represents the buildspec version. We recommend that you use 0.2.
version: 0.2

phases:
  ## install: install dependencies you may need for your build
  install:
    runtime-versions:
      nodejs: 12
    commands:
      - echo Installing Nest...
      - npm install -g @nestjs/cli
  ## pre_build: final commands to execute before build
  pre_build:
    commands:
      - echo Installing source NPM dependencies...
      - npm install
  ## build: actual build commands
  build:
    commands:
      # Build your app
      - echo Build started on `date`
      - echo Compiling the Node.js code
      - npm run build
      ## Clean up node_modules to keep only production dependencies
      # - npm prune --production

  ## post_build: finishing touches
  post_build:
    commands:
      - echo Build completed on `date`
# Include only the files required for your application to run.
artifacts:
  files:
    - dist/**/*
    - package.json
    - node_modules/**/*
    - .ebextensions/**/*

安德配置文件/.ebextensions/.node-settings.config:

option_settings:
  aws:elasticbeanstalk:container:nodejs:
    NodeCommand: "npm run start:prod"
于 2020-02-05T17:17:00.457 回答