[英]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/build
、 client/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/build
、 client/node_modules
和client/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.yml
的artifacts
部分。 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.