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



这是一个更狭隘的问题,源于我之前的问题。

这是我的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: '*'

在构建后阶段,我输出目录进行调试,这就是它们显示的内容:

[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:

这表明client/buildclient/node_modules和测试目录client/TEST都是在 CodeBuild 期间创建的。但是,当我转到 Beanstalk 环境时,我收到错误:

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

当我 ssh 进入 Beanstalk 并检查/var/app/current/目录时,根目录中的node_modules已成功构建。但是,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

这向我表明,在CodePipeline的部署阶段,或者可能是buildspec.ymlartifacts部分,有些事情搞砸了。我一直被困在这个问题上这么久,不知道该怎么做。

基于注释。

为了部署到 ElasticBeanstalk,CodePipepine 在Deploy操作中使用 Elastic Beanstalk 提供程序。作为设置此操作的一部分,需要指定input artifacts

问题是输入项目设置为使用Source操作,而不是CodeBuild操作。

解决方案是调整Deploy操作的设置,以使用CodeBuild工件,而不是源工件。

相关内容

  • 没有找到相关文章

最新更新