laravel-docker
laravel-docker copied to clipboard
Fix: Add missing composer install, .env setup, and Laravel artisan bootstrap to Docker entrypoint
trafficstars
What’s Fixed
This PR addresses two issues encountered during Docker container startup in a Laravel project:
-
Missing vendor autoload error: Laravel fails with
Failed opening required 'vendor/autoload.php'ifcomposer installhasn't run.- Fix: Automatically run
composer installif/var/www/vendordoes not exist.
- Fix: Automatically run
-
Missing
.envfile and uninitialized Laravel app: Without.env,php artisan key:generateand other commands fail.- Fix: Copy
.env.exampleto.envif needed, generate app key, cache config, and run migrations.
- Fix: Copy
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
- Build and run the container:
docker-compose up --build