laravel-docker icon indicating copy to clipboard operation
laravel-docker copied to clipboard

Fix: Add missing composer install, .env setup, and Laravel artisan bootstrap to Docker entrypoint

Open fuadadhim24 opened this issue 3 months ago • 0 comments
trafficstars

What’s Fixed

This PR addresses two issues encountered during Docker container startup in a Laravel project:

  1. Missing vendor autoload error: Laravel fails with Failed opening required 'vendor/autoload.php' if composer install hasn't run.

    • Fix: Automatically run composer install if /var/www/vendor does not exist.
  2. Missing .env file and uninitialized Laravel app: Without .env, php artisan key:generate and other commands fail.

    • Fix: Copy .env.example to .env if needed, generate app key, cache config, and run migrations.

Why It Matters

Without these steps, fresh containers fail to start properly unless manually set up. These changes make the container self-initializing and reduce setup time for new developers or CI environments.

How to Test

  1. Build and run the container:
    docker-compose up --build
    

fuadadhim24 avatar Jul 28 '25 10:07 fuadadhim24