简体   繁体   English

CodeDeploy 应用程序缺少 Composer 环境变量

[英]Composer Environment variable missing on CodeDeploy Application

I'm integrating AWS Auto Scaling Group with Code Deploy .我正在将AWS Auto Scaling GroupCode Deploy集成。

I wrote a bash script for AfterInstall hook.我为 AfterInstall 钩子写了一个 bash 脚本。

The script executes composer update , composer dump-autoload since my code is using PHP.该脚本执行composer updatecomposer dump-autoload因为我的代码使用的是 PHP。

And here is the problem.这就是问题所在。 When I deploy, deployment fails with this log.当我部署时,部署失败并显示此日志。

[RuntimeException] [运行时异常]

The HOME or COMPOSER_HOME environment variable must be set for composer to run correctly必须设置 HOME 或 COMPOSER_HOME 环境变量,composer 才能正常运行

But when I get to instance via SSH and run composer it works fine.但是当我通过 SSH 访问实例并运行 composer 时,它工作正常。

How do I fix this?我该如何解决? Anyone had worked around this issue?有人解决过这个问题吗?

Any answer will be appreciated.任何答案将不胜感激。 Thank you for your time.感谢您的时间。

I had a similar problem using Elastic Beanstalk and i did fixed it adding an Environment variable我在使用Elastic Beanstalk时遇到了类似的问题,我确实添加了一个环境变量来修复它

在此处输入图像描述

在此处输入图像描述

You should be able to achieve this in CodeDeploy too for example on creating the application.您也应该能够在CodeDeploy中实现这一点,例如在创建应用程序时。

在此处输入图像描述

See also https://github.com/composer/composer/issues/4789另见https://github.com/composer/composer/issues/4789

Could you make sure the env variable is also accessible by the user you specify in the appspec file to which runs the hook script?您能否确保您在运行挂钩脚本的 appspec 文件中指定的用户也可以访问 env 变量? If you have multiple user running on the instance, env variable might not be accessible to every user depends how you set it up.如果您有多个用户在实例上运行,则可能并非每个用户都可以访问 env 变量,这取决于您如何设置它。

I have the same concern regarding composer install using CodeDeploy.我对使用 CodeDeploy 安装 composer 也有同样的担忧。 It runs well in develop but when I ran it in production, I'm getting: [stderr] [RuntimeException] [stderr] The HOME or COMPOSER_HOME environment variable must be set for composer to run correctly I SSH to instance and run composer and I get:它在开发中运行良好,但是当我在生产中运行它时,我得到:[stderr] [RuntimeException] [stderr] 必须设置 HOME 或 COMPOSER_HOME 环境变量才能使 composer 正确运行我 SSH 到实例并运行 composer 和我得到:

user@server:~/httpdocs$ /opt/plesk/php/7.2/bin/php /usr/lib/plesk-9.0/composer.phar install

Loading composer repositories with package information Installing dependencies (including require-dev) from lock file Nothing to install or update Generating optimized autoload files user@server:~/httpdocs$使用包信息加载 composer 存储库 从锁定文件安装依赖项(包括 require-dev) 无需安装或更新 生成优化的自动加载文件 user@server:~/httpdocs$

I have one ec2 instance and I deploy in 2 separate directories for stg and prod.我有一个 ec2 实例,我为 stg 和 prod 部署在 2 个单独的目录中。 codedeploy deployment error codedeploy部署错误

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AWS CodeDeploy 说脚本丢失,即使它存在 - AWS CodeDeploy says script missing even though it exists 我们如何升级作曲家环境的 Cloud Composer 版本? - How can we upgrade the Cloud Composer version of our composer environment? 如何在 Fargate 上的 AWS ECS 环境中存储 GOOGLE_APPLICATION_CREDENTIALS? - How to store GOOGLE_APPLICATION_CREDENTIALS in an AWS ECS environment on Fargate? 环境变量从 golang 库中的 function 返回一个空字符串 - Environment variable returns an empty string from a function in golang library 如何将环境变量传递给 docker 在 gitlab ci cd 中运行 - How to pass environment variable to docker run in gitlab ci cd 列表中的 Escaping 字符作为环境变量发送到 GCP Cloud Run - Escaping characters in a list sent as environment variable to GCP Cloud Run 根据另一个环境变量设置 Google Cloud Run 环境变量值 - Set Google Cloud Run environment variables value based on another environment variable 如何使用 cloudformation 模板为不同的 elasticbeanstack 应用程序环境使用相同的应用程序负载均衡器? - How to use same application loadbalancer for different elasticbeanstack application environment using cloudformation template? 如何修复“运行此应用程序的环境不支持此操作。”location.protocol“...”错误? - How to fix "This operation is not supported in the environment this application is running on. "location.protocol" ..." error? 如何在不设置环境变量的情况下将谷歌语音的凭据设置为文本? - How do I set credentials for google speech to text without setting environment variable?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM