【发布时间】:2020-11-24 21:12:27
【问题描述】:
我多次收到红色文档,但在 Elastic Beanstalk 上部署我的项目时仍然遇到问题。
我已经创建了现成的构建解决方案,可以在我的本地计算机上正常运行。
结构如下:
我还创建了管道作为 AWS 服务:
根据文档,我创建了 buildspec.yaml 文件: (它只是创建 dist 文件夹,将文件放入其中,安装 node_modules 并制作 zip 文件)
version: 0.2
phases:
install:
runtime-versions:
nodejs: 12
commands:
- yum install -y zip
- echo "Instal dependencies"
- npm install
build:
commands:
- npm run build
- cd dist
- zip -r application.zip ./* ../package.json ../package-lock.json ../.env ../node_modules ../Procfile
- cd ..
- mv ./dist/application.zip ./
artifacts:
files:
- application.zip
它以 zip 格式创建工件并在我下载它时放入 E3 存储桶,其结构与我本地计算机中的相同:
根据文档,我已包含在部署操作期间使用的 Procfile:
web: node app.js
问题发生在部署期间。我收到来自 Elastic Beanstalk 的错误:
2020/08/04 16:58:49.766428 [INFO] Executing instruction: StageApplication
2020/08/04 16:58:49.917998 [INFO] extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /var/app/staging/
2020/08/04 16:58:49.918039 [INFO] Running command /bin/sh -c /usr/bin/unzip -q -o /opt/elasticbeanstalk/deployment/app_source_bundle -d /var/app/staging/
2020/08/04 16:58:50.544212 [INFO] finished extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /var/app/staging/ successfully
2020/08/04 16:58:50.544764 [INFO] Executing instruction: RunPreBuildHooks
2020/08/04 16:58:50.544792 [INFO] The dir .platform/hooks/prebuild/ does not exist in the application. Skipping this step...
2020/08/04 16:58:50.544797 [INFO] Executing instruction: Install customer specified node.js version
2020/08/04 16:58:50.544802 [INFO] installing specified nodejs version...
2020/08/04 16:58:50.544809 [INFO] there is no package.json file, skip installing specified version of nodejs
2020/08/04 16:58:50.544814 [INFO] Executing instruction: Use NPM to install dependencies
2020/08/04 16:58:50.544822 [INFO] there is no package.json file, skip installing dependencies
2020/08/04 16:58:50.544827 [INFO] Executing instruction: check Procfile
2020/08/04 16:58:50.544831 [INFO] checking Procfile
2020/08/04 16:58:50.544837 [INFO] no Procfile found, generating Procfile
2020/08/04 16:58:50.544841 [INFO] checking package.json file
2020/08/04 16:58:50.544847 [INFO] checking app.js file from source
2020/08/04 16:58:50.544853 [INFO] checking server.js file from source
2020/08/04 16:58:50.544867 [ERROR] An error occurred during execution of command [app-deploy] - [check Procfile]. Stop running the command. Error: node.js may have issues starting. Please provide a package.json file or add server.js/app.js file in source bundle
在我看来,部署管道部分不会接收工件,因为它没有看到 package.json、Procfile 和 app.js 主文件。
此外,我想向您展示我已经在部署和构建部分之间建立了工件连接:
当我手动上传文件时 - 它可以工作.. 我究竟做错了什么?非常感谢您的建议!
【问题讨论】:
-
“当我手动上传文件时” - 你的意思是当你上传 CB 制作的 zip 工件时,它一切都按预期工作吗?部署阶段的
Details还说什么?
标签: node.js amazon-web-services amazon-elastic-beanstalk pipeline nestjs