AWS Elastic Beanstalk 和 Composer [英] AWS Elastic Beanstalk and Composer
问题描述
我有一个包含 Composer 依赖项的应用程序,我想将其部署到 Elastic Beanstalk 容器.但是我的 composer.json 文件不在项目根文件夹中.我的项目根目录结构如下:
I have an application with Composer dependencies which I want to deploy to an Elastic Beanstalk container. However my composer.json file is not in the project root folder. My project root has the following structure:
- .ebextensions
- scripts
- www (Webroot)
- composer.json
并且我已在容器配置选项中将文档根目录设置为/www.问题是我需要在盒子上安装 composer 并运行 composer install 脚本来添加项目依赖项.我知道在部署期间 EB 将检查项目根目录中是否有 composer.json 文件并安装 Composer,但在这种情况下,我的 composer.json 文件位于子目录中.
And I have set the document root to /www in the container configuration options. The issue is that I need to install composer on the box and run the composer install script to add the project dependencies. I understand that during a deploy EB will check to see if there is a composer.json file in the project root and install Composer but in this case my composer.json file is in a sub-directory.
我认为可以在应用程序部署后使用 .ebextenstions 添加命令来安装 Composer 和依赖项.我使用以下容器命令创建了一个文件 .ebextensions/01-composer.config:
I thought that could use .ebextenstions to add commands to install Composer and dependencies after the application has been deployed. I created a file .ebextensions/01-composer.config with the following container commands:
container_commands:
01-install-composer:
command: "curl -sS https://getcomposer.org/installer | php"
02-install-packages:
command: "php composer.phar install"
cwd: "/var/app/current/www/"
但我的应用程序不会使用此配置进行部署.希望得到一些帮助,看看我哪里出错了.
But my app won't deploy with this configuration. Would appreciate some assistance to see where I am going wrong.
谢谢.
推荐答案
Composer 已经默认安装在 Beanstalk 的 PHP AMI 中.
Composer is already installed default in Beanstalk's PHP AMI.
还要考虑到 container_commands 是通过/var/app/ondeck"而不是当前运行的.尝试这样的事情:
Also consider that container_commands are ran through '/var/app/ondeck' and not on current. Try something like this:
container_commands:
01-install-packages:
command: "composer.phar install -d /var/app/ondeck/www"
这篇关于AWS Elastic Beanstalk 和 Composer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!