Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 530
Adrian Walls Avatar asked Jul 08 '13 08:07

Adrian Walls


2 Answers

Just a note, most of the PHP containers that AWS is using in Elastic Beanstalk are auto deploying by running composer.phar install now. You should be able to skip this step if you don't have a "vendors" folder present. If you want to run it manually, the above methods should work, but you should only need something like @kewubenduben mentioned.

If you are trying to access a private remote repository, check out the Q and A here: AWS Elastic Beanstalk using PHP with Private Composer Repositories , shameless plug.

like image 173
four43 Avatar answered Nov 15 '22 20:11

four43


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"
like image 26
Ker Ruben Ramos Avatar answered Nov 15 '22 21:11

Ker Ruben Ramos