amazon-web-services - 尝试使用 codepipeline 将 spring boot + mysql 应用程序部署到 AWS 时出错
问题描述
我已经使用 AWS codepipeline 构建了一个 cicd 管道。来源来自成功的 Github。构建也成功。
我正在使用在 64 位 Amazon Linux 2 上运行的 Corretto 11 作为 Elastic Beanstalk 中的平台,因为在 64 位 Amazon Linux 上运行的 Java 8 显示它已被弃用。
在部署到 AWS Elastic Beanstalk 期间出现错误。
Action execution failed
Deployment completed, but with errors: Failed to deploy application. Unsuccessful command execution on instance id(s) 'i-03b7a9c8a86ffde8e'. Aborting the operation. [Instance: i-03b7a9c8a86ffde8e] Command failed on instance. Return code: 1 Output: Engine execution has encountered an error.. Instance deployment failed. For details, see 'eb-engine.log'.
我检查了 eb-engine.log 文件并看到以下错误消息。
...
...
2021/11/07 05:01:18.765214 [INFO] extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /tmp/extracted_app_source_bundle
2021/11/07 05:01:18.765227 [INFO] Running command /bin/sh -c /usr/bin/unzip -q -o /opt/elasticbeanstalk/deployment/app_source_bundle -d /tmp/extracted_app_source_bundle
2021/11/07 05:01:19.122461 [INFO] finished extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /tmp/extracted_app_source_bundle successfully
2021/11/07 05:01:19.122560 [INFO] app source bundle is zip file ...
2021/11/07 05:01:19.122566 [INFO] extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /var/app/staging/
2021/11/07 05:01:19.122578 [INFO] Running command /bin/sh -c /usr/bin/unzip -q -o /opt/elasticbeanstalk/deployment/app_source_bundle -d /var/app/staging/
2021/11/07 05:01:19.498171 [INFO] finished extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /var/app/staging/ successfully
2021/11/07 05:01:19.498694 [INFO] Executing instruction: RunAppDeployPreBuildHooks
2021/11/07 05:01:19.498712 [INFO] The dir .platform/hooks/prebuild/ does not exist in the application. Skipping this step...
2021/11/07 05:01:19.498717 [INFO] Executing instruction: Java Specific Build Application
2021/11/07 05:01:19.498724 [INFO] no buildfile found, skip building java application
2021/11/07 05:01:19.498731 [INFO] old env file for build tasks does not exist
2021/11/07 05:01:19.498742 [INFO] Executing instruction: CheckProcfileForJavaApplication
2021/11/07 05:01:19.498776 [ERROR] An error occurred during execution of command [app-deploy] - [CheckProcfileForJavaApplication]. Stop running the command. Error: there is no Procfile and no .jar file at root level of your source bundle
2021/11/07 05:01:19.498786 [INFO] Executing cleanup logic
2021/11/07 05:01:19.498869 [INFO] CommandService Response: {"status":"FAILURE","api_version":"1.0","results":[{"status":"FAILURE","msg":"Engine execution has encountered an error.","returncode":1,"events":[{"msg":"Instance deployment failed. For details, see 'eb-engine.log'.","timestamp":1636261279,"severity":"ERROR"}]}]}
...
...
下面是我的 buildspec.yml 文件。
version: 0.2
phases:
install:
runtime-versions:
java: corretto11
commands:
- echo install
pre_build:
commands:
- echo pre_build
build:
commands:
- mvn package
- echo build
post_build:
commands:
- echo post_build
artifacts:
files:
- target/course_reviews_backend-0.0.1-SNAPSHOT.jar
请帮忙!!
任何帮助都会得到帮助。提前致谢。
解决方案
您应该注意此错误消息:
2021/11/07 05:01:19.498776 [ERROR] An error occurred during execution of command [app-deploy] - [CheckProcfileForJavaApplication]. Stop running the command. Error: there is no Procfile and no .jar file at root level of your source bundle
Procfile
本质上,您必须在 spring boot 项目的根目录中添加一个名为的文件:
的内容Procfile
应该如下:
web: java -jar target/course_reviews_backend-0.0.1-SNAPSHOT.jar
推荐阅读
- mysql - MYSQL 添加索引 - 不添加索引?
- git - 防止未经检查的更改合并到主分支
- jwt - 使用 auth0 身份验证登录公司网站重定向回登录
- typescript - 打字稿:省略不会警告额外的道具
- mitmproxy - 使用 mitmproxy UI 编辑多部分/表单数据时出现问题
- c# - 将 ObservableCollection 绑定到 ItemsControl
- jquery - 数据表从解析的 json 更改文本颜色
- maven - Apache cxf-codegen-plugin 未在 Spring Tool Suite 中生成 Java 存根
- python - 使用 python 托盘将 json 文件(3d 绘图)导入 ARCHICAD 24
- ruby-on-rails - 如何从 Rails 缓存哈希上传照片?