【问题标题】:Getting error when trying to deploy spring boot + mysql app to AWS using codepipeline尝试使用 codepipeline 将 spring boot + mysql 应用程序部署到 AWS 时出错
【发布时间】:2021-12-20 17:04:04
【问题描述】:

我已经使用 AWS 代码管道构建了一个 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

请帮忙!!

任何帮助都会得到帮助。提前致谢。

【问题讨论】:

    标签: amazon-web-services amazon-ec2 amazon-elastic-beanstalk amazon-rds aws-codepipeline


    【解决方案1】:

    你应该注意这个错误信息:

    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 
    

    基本上你必须在你的 spring boot 项目的根目录中添加一个名为 Procfile 的文件:

    Procfile的内容应该如下:

    web: java -jar target/course_reviews_backend-0.0.1-SNAPSHOT.jar
    

    【讨论】:

    • 您好欧文,感谢您的回复。我做了和你说的完全一样的事情。我在我的应用程序的根目录中添加了 Procfile。我在 Procfile web 中添加以下内容:java -jar target/course_reviews_backend-0.0.1-SNAPSHOT.jar 但我在 eb-engine.log 文件 2021/11/07 05:01:19.498776 [ERROR] An执行命令 [app-deploy] - [CheckProcfileForJavaApplication] 期间发生错误。停止运行命令。错误:源包的根级别没有 Procfile 和 .jar 文件你认为我还缺少什么吗?感谢您的帮助
    猜你喜欢
    • 2020-07-05
    • 2020-12-01
    • 2017-06-14
    • 2015-01-25
    • 2014-05-03
    • 2019-11-11
    • 1970-01-01
    • 2019-04-03
    • 2019-11-17
    相关资源
    最近更新 更多