'How to implement aws-codepipeline using laravel?

here is my buildspec.yml

version: 0.2
phases:
   install:
     runtime-versions:
         php: 7.4
         nodejs: 14.x
     commands:
         - apt-get update -y
         - add-apt-repository ppa:ondrej/php -y 
         - apt-get install nginx software-properties-common  php7.4-fpm php7.4-redis unzip libpq-dev libzip-dev php7.4-common php7.4-mysql php7.4-xml php7.4-xmlrpc php7.4-curl php7.4-gd php7.4-imagick php7.4-cli php7.4-dev php7.4-imap php7.4-mbstring php7.4-opcache php7.4-soap php7.4-zip php7.4-intl php7.4-dom php7.4-pdo php7.4-bcmath php7.4-json -y
         - curl -sS https://getcomposer.org/installer | php7.4 -- --install-dir=/usr/local/bin --filename=composer
         - aws --version
   pre_build:
     commands:
         - aws s3 cp s3://my-credentials/.env.dev ./
         - mv .env.dev .env
         - cat .env
         - aws s3 cp s3://my-credentials/private.pem ./app
         - ls
         - npm install
         - npm run dev
         - composer install
   build:
     commands:
         - npm run production
        #  - php artisan migrate
         ## fresh install
         - node -v
         - npm -v
         - php --version
         - cat .env
         - php -m
         - php artisan migrate:fresh --seed
         #- php artisan db:seed
        # - php artisan db:seed --class=ServerHealthSeeder --force
         - php artisan key:generate
         - php artisan jwt:secret  
        #  - php artisan cache:clear
        #  - php artisan view:clear
artifacts:
   files:
         - '**/*'
   name: $(date +%Y-%m-%dT%H:%M:%S).zip
proxy:
   upload-artifacts: yes
   logs: yes

when the aws codebuilder run the script it breaks from the command "php artisan migrate:fresh --seed"

it gives me the below error


   LogicException 

  Please make sure the PHP Redis extension is installed and enabled.

  at vendor/laravel/framework/src/Illuminate/Redis/Connectors/PhpRedisConnector.php:77
    73|     protected function createClient(array $config)
    74|     {
    75|         return tap(new Redis, function ($client) use ($config) {
    76|             if ($client instanceof RedisFacade) {
  > 77|                 throw new LogicException(
    78|                     extension_loaded('redis')
    79|                         ? 'Please remove or rename the Redis facade alias in your "app" configuration file in order to avoid collision with the PHP Redis extension.'
    80|                         : 'Please make sure the PHP Redis extension is installed and enabled.'
    81|                 );

      +12 vendor frames 
  13  app/Model/Instrument.php:78
      Illuminate\Support\Facades\Facade::__callStatic()

  14  database/seeds/UpdateInstrumentSeeder.php:10
      App\Model\Instrument::getInstruments()

[Container] 2022/02/22 02:52:30 Command did not exit successfully php artisan migrate:fresh --seed exit status 1
[Container] 2022/02/22 02:52:30 Phase complete: BUILD State: FAILED
[Container] 2022/02/22 02:52:30 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: php artisan migrate:fresh --seed. Reason: exit status 1
[Container] 2022/02/22 02:52:30 Entering phase POST_BUILD

Connect with ssm

then I log into the instance using aws ssm and I go to the application location and i run command "php artisan migrate:fresh --seed" again. it gives me above error

then I run command "su" and run the command again it is working. can anyone help me?

laravel version:7.0
php: 7.4
codebuilder image: aws/codebuild/standard:5.0
os: ubuntu 20.04 lts


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source