Laravel failed deployement

Hi everyone,

Yesterday I was trying to deploy our Laravel application but I had an error fetching the docker image.

I don’t understand why because 3 months ago we had deployed our application with success and we didn’t touch the docker file.

Here is the error we received:

Error: failed to fetch an image or build from source: error building: failed to solve: executor failed running [/bin/sh -c composer install --optimize-autoloader --no-dev --no-scripts     && mkdir -p storage/logs     && php artisan optimize:clear     && php artisan ziggy:generate     && chown -R www-data:www-data /var/www/html     && sed -i 's/protected \$proxies/protected \$proxies = "*"/g' app/Http/Middleware/TrustProxies.php     && echo "MAILTO=\"\"\n* * * * * www-data /usr/bin/php /var/www/html/artisan schedule:run" > /etc/cron.d/laravel     && cp .fly/entrypoint.sh /entrypoint     && chmod +x /entrypoint]: exit code: 1

Thank you in advance for your help

Hi there!

So, the error failed to fetch an image or build from source in this case is the latter failure to build from source, meaning a command in the Dockerfile failed.

In this case, one of the commands here failed:

RUN composer install --optimize-autoloader --no-dev --no-scripts \
    && mkdir -p storage/logs \
    && php artisan optimize:clear \
    && php artisan ziggy:generate \
    && chown -R www-data:www-data /var/www/html \
    && sed -i 's/protected \$proxies/protected \$proxies = "*"/g' app/Http/Middleware/TrustProxies.php \
    && echo "MAILTO=\"\"\n* * * * * www-data /usr/bin/php /var/www/html/artisan schedule:run" > /etc/cron.d/laravel \
    && cp .fly/entrypoint.sh /entrypoint \
    && chmod +x /entrypoint

One of the commands in there is failing (exiting with a non-zero status code).

There MIGHT be more useful output hiding just after that in the output when trying to deploy.

However figuring out which command there is failing will be the key there.

The one customization I can spot is php artisan ziggy:generate - any chance that’s returning an error?

Or perhaps app/Http/Middleware/TrustProxies.php no longer matches the regex used for the find/replace in that file?

(Double check the output to see if there’s more useful info there!)

LMK if I can clarify anything there.

Hi there!

Thank you for your reply. I have found what was wrong.

I didn’t read my errors correctly and the solution was above.

 > [base 3/3] RUN composer install --optimize-autoloader --no-dev --no-scripts     && mkdir -p storage/logs     && php artisan optimize:clear     && php artisan ziggy:generate     && chown -R www-data:www-data /var/www/html     && sed -i 's/protected \$proxies/protected \$proxies = "*"/g' app/Http/Middleware/TrustProxies.php     && echo "MAILTO=""\n* * * * * www-data /usr/bin/php /var/www/html/artisan schedule:run" > /etc/cron.d/laravel     && cp .fly/entrypoint.sh /entrypoint     && chmod +x /entrypoint:
#0 4.086  97/97 [============================] 100%
#0 4.533 Generating optimized autoload files
#0 6.228 67 packages you are using are looking for funding.
#0 6.228 Use the `composer fund` command to find out more!
#0 6.373 
#0 6.383 In ProviderRepository.php line 206:
#0 6.383                                                                         
#0 6.383   Class "Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider" not found  
#0 6.383                                                                         
#0 6.383 

I had to remove the IdeHelperServiceProvider from my app.php configuration.

Thank you again !

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.