Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

amazon web services - AWS Elastic Beanstalk and Composer

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

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.

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.

Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Composer is already installed default in Beanstalk's PHP AMI.

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"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...