Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run composer update command after code deploy on aws

I have setup Code Deploy service on aws and It's working great, but what I want is to run composer update command after deploying.

I have defined composer update command in AfterInstall hook, but It doesn't seem to work.

Here's my appspec.yml

version: 0.0
os: linux
files:
  - source: /
    destination: /var/www/laravel/
hooks:
  AfterInstall:
    - location: hooks/after-install.sh
      runas: root

and here's the after-install.sh file code:

#!/bin/bash

php /var/www/laravel/artisan clear-compiled
php /var/www/laravel/artisan optimize
php /var/www/laravel/artisan view:clear
php /var/www/laravel/artisan cache:clear

chown -R ubuntu:www-data /var/www/laravel
sudo find /var/www/laravel -type d -exec chmod 755 {} +
sudo find /var/www/laravel -type f -exec chmod 644 {} +
chmod -R 777 /var/www/laravel/storage

composer update

all other commands work except the composer update, any help is appreciated.

Thakns

like image 427
Rohit Khatri Avatar asked Jan 19 '26 10:01

Rohit Khatri


1 Answers

You must include absolute path for the directory where your project resides (where you have composer.json file for the dependencies).

Replace composer update with composer update -d /var/www/laravel

and It will work like charm.

like image 200
Daisy Saxena Avatar answered Jan 22 '26 05:01

Daisy Saxena



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!