简体   繁体   English

AWS CodePipeline 在部署到 Elastic Beanstalk 后缺少目录/文件

[英]AWS CodePipeline missing directories/files after being deployed to Elastic Beanstalk

This is a more-narrowed-down problem stemming from my earlier question .这是源于我之前的问题的更缩小的问题

Here is my buildspec.yml:这是我的 buildspec.yml:

version: 0.2

phases:
  install:
    commands:
      # upgrade AWS CLI
      - pip install --upgrade awscli
      # install Node 12
      - curl -sL https://deb.nodesource.com/setup_12.x | bash -
      - apt install nodejs

  pre_build:
    commands:
      # install server dependencies
      - npm install
  build:
    commands:
      # install client dependencies and build static files
      - npm install --prefix client && npm run build --prefix client

  post_build:
    commands:
      # FOR TESTING AND DEBUGGING
      - ls -la
      - ls client -la
      - mkdir client/TEST
      - ls client -la

artifacts:
  files:
    - '**/*'
  discard-paths: no
  base-directory: '*'

In the post-build phase, I output directories for debugging and this is what they show:在构建后阶段,我在 output 目录进行调试,这就是它们显示的内容:

[Container] 2020/07/02 02:36:15 Entering phase POST_BUILD
[Container] 2020/07/02 02:36:15 Running command ls -la
total 132
drwxr-xr-x  11 root root  4096 Jul  2 02:34 .
drwxr-xr-x   3 root root  4096 Jul  2 02:34 ..
-rw-rw-r--   1 root root   129 Jul  2 02:33 .gitignore
-rw-rw-r--   1 root root    16 Jul  2 02:33 .npmrc
-rw-rw-r--   1 root root    34 Jul  2 02:33 README.md
-rw-rw-r--   1 root root  1737 Jul  2 02:33 app.js
drwxr-xr-x   2 root root  4096 Jul  2 02:34 bin
-rw-rw-r--   1 root root   655 Jul  2 02:33 buildspec.yml
drwxr-xr-x   6 root root  4096 Jul  2 02:35 client
drwxr-xr-x   2 root root  4096 Jul  2 02:34 config
drwxr-xr-x   2 root root  4096 Jul  2 02:34 graphql
drwxr-xr-x   2 root root  4096 Jul  2 02:34 models
drwxr-xr-x 197 root root  4096 Jul  2 02:34 node_modules
-rw-rw-r--   1 root root 63888 Jul  2 02:33 package-lock.json
-rw-rw-r--   1 root root   814 Jul  2 02:33 package.json
drwxr-xr-x   2 root root  4096 Jul  2 02:34 routes
drwxr-xr-x   2 root root  4096 Jul  2 02:34 services
drwxr-xr-x   2 root root  4096 Jul  2 02:34 views




[Container] 2020/07/02 02:36:15 Running command ls client -la
total 748
drwxr-xr-x    6 root root   4096 Jul  2 02:35 .
drwxr-xr-x   11 root root   4096 Jul  2 02:34 ..
drwxr-xr-x    3 root root   4096 Jul  2 02:36 build
drwxr-xr-x 1081 root root  36864 Jul  2 02:35 node_modules
-rw-rw-r--    1 root root 699332 Jul  2 02:33 package-lock.json
-rw-rw-r--    1 root root   1212 Jul  2 02:33 package.json
drwxr-xr-x    2 root root   4096 Jul  2 02:34 public
drwxr-xr-x    8 root root   4096 Jul  2 02:34 src



[Container] 2020/07/02 02:36:15 Running command mkdir client/TEST



[Container] 2020/07/02 02:36:15 Running command ls client -la
total 752
drwxr-xr-x    7 root root   4096 Jul  2 02:36 .
drwxr-xr-x   11 root root   4096 Jul  2 02:34 ..
drwxr-xr-x    2 root root   4096 Jul  2 02:36 TEST
drwxr-xr-x    3 root root   4096 Jul  2 02:36 build
drwxr-xr-x 1081 root root  36864 Jul  2 02:35 node_modules
-rw-rw-r--    1 root root 699332 Jul  2 02:33 package-lock.json
-rw-rw-r--    1 root root   1212 Jul  2 02:33 package.json
drwxr-xr-x    2 root root   4096 Jul  2 02:34 public
drwxr-xr-x    8 root root   4096 Jul  2 02:34 src




[Container] 2020/07/02 02:36:15 Phase complete: POST_BUILD State: SUCCEEDED
[Container] 2020/07/02 02:36:15 Phase context status code:  Message: 
[Container] 2020/07/02 02:36:15 Phase complete: UPLOAD_ARTIFACTS State: SUCCEEDED
[Container] 2020/07/02 02:36:15 Phase context status code:  Message:

Which shows that client/build , client/node_modules , and a test directory client/TEST were all created during the CodeBuild.这表明client/buildclient/node_modules和测试目录client/TEST都是在 CodeBuild 期间创建的。 However when I go to the Beanstalk environment I get the error:但是,当我 go 到 Beanstalk 环境时,我收到错误:

ENOENT: no such file or directory, stat '/var/app/current/client/build/index.html'

When I ssh into Beanstalk and check the /var/app/current/ directory, the node_modules in the root directory was successfully built.当我 ssh 进入 Beanstalk 并检查/var/app/current/目录时,根目录下的node_modules构建成功。 However, the client/build , client/node_modules , and client/TEST are all missing :但是, client/buildclient/node_modulesclient/TEST不见了

$ cd /var/app/current
$ ls
app.js  buildspec.yml  config  models  package.json  Procfile  routes  views
bin  client  graphql  node_modules  package-lock.json  README.md  services
$ cd client
$ ls
package.json package-lock.json public src

This indicates to me that something messed up in the Deploy stage of the CodePipeline, or maybe the artifacts section of the buildspec.yml .这向我表明,在 CodePipeline 的 Deploy 阶段出现了问题,或者可能是buildspec.ymlartifacts部分。 I have been stuck on this issue for so long and have no idea how to go about it.我已经在这个问题上停留了很长时间,并且不知道如何 go 关于它。

Based on the comments.根据评论。

To deploy to ElasticBeanstalk, CodePipepine is using Elastic Beanstalk provider in a Deploy action.为了部署到 ElasticBeanstalk,CodePipepine 在Deploy操作中使用Elastic Beanstalk提供程序。 As part of setting up this action, input artifacts need to be specified.作为设置此操作的一部分,需要指定input artifacts

The issue was that the input artifacts were set to use Source action, rather then the CodeBuild action.问题是输入工件被设置为使用Source操作,而不是CodeBuild操作。

The solution was to adjust the setting of the the Deploy action to use the CodeBuild artifacts, instead of Source artifacts.解决方案是调整Deploy操作的设置以使用CodeBuild工件,而不是 Source 工件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在将 web 部署到 AWS Elastic Beanstalk 后,Sequelize 无法正常工作 - Sequelize not working after the web being deployed to AWS Elastic Beanstalk 带有 CodePipeline 和 Elastic Beanstalk 的 .ebextensions - .ebextensions with CodePipeline and Elastic Beanstalk Elastic Beanstalk 上 Next.js 网站的 AWS 代码管道 - AWS codepipeline for Next.js website on Elastic Beanstalk AWS Elastic Beanstalk 代理 - AWS Elastic Beanstalk Proxy HTTPS AWS Elastic Beanstalk - HTTPS AWS Elastic Beanstalk 在 Elastic Beanstalk AWS 中为 nodeJs 应用程序提供静态文件 - Serve static files for a nodeJs application in Elastic Beanstalk AWS 我的aws弹性beantalk日志文件中出现Nginx错误 - Nginx error in my aws elastic beanstalk log files 部署后 AWS 弹性 beanstalk Express 服务 502 Bad Gateway - AWS elastic beanstalk Express service 502 Bad Gateway after deployment 上传/部署 zip 文件时,不会创建 .platform 挂钩中的 AWS Elastic Beanstalk 自定义 nginx .conf 文件 - AWS Elastic Beanstalk custom nginx .conf file in the .platform hooks is not created when zip file is uploaded/ deployed 如何从部署在 AWS Elastic beanstalk 上的 node.js express 应用程序获取客户端 ip? - How to get client ip from node.js express application deployed on AWS Elastic beanstalk?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM