MAJOR FIX: Use named volume for vendor/ + pre-install in Dockerfile

This solves the Windows/WSL2 performance issue that caused composer install
to timeout after 300 seconds.

Changes:
1. docker-compose.yml:
   - Added vendor_data named volume for app, queue, scheduler services
   - vendor/ now uses fast Docker volume instead of slow bind mount

2. Dockerfile:
   - Pre-install composer dependencies during image build
   - Copy composer.json/lock first, run install, then copy rest of src
   - Runs as devuser to match runtime permissions
   - Dependencies baked into image = truly 'pre-installed'

3. setup.bat & setup.sh:
   - Removed composer install step (now in Dockerfile)
   - Added -T flag to all docker-compose exec commands (fixes Windows TTY hang)
   - Added 3-second wait for container readiness

Benefits:
-  Setup completes in 2-3 minutes (not 10+ minutes)
-  No composer timeout issues
-  Works on Windows/Mac/Linux
-  vendor/ persists in Docker volume (fast)
-  True 'everything pre-installed' experience

Trade-offs:
- vendor/ not visible in Windows filesystem (in Docker volume)
- Need to rebuild image when adding composer packages
- Slightly larger Docker image (~200MB more)

This is the correct approach for a Docker-based development template.
This commit is contained in:
2026-03-10 11:13:51 +02:00
parent 97acc5e8ea
commit 83131d8432
3 changed files with 27 additions and 9 deletions

View File

@@ -11,6 +11,7 @@ services:
working_dir: /var/www/html
volumes:
- ./src:/var/www/html:cached
- vendor_data:/var/www/html/vendor
- ./docker/php/local.ini:/usr/local/etc/php/conf.d/local.ini
networks:
- laravel_network
@@ -124,6 +125,7 @@ services:
working_dir: /var/www/html
volumes:
- ./src:/var/www/html
- vendor_data:/var/www/html/vendor
- ./docker/php/local.ini:/usr/local/etc/php/conf.d/local.ini
networks:
- laravel_network
@@ -143,6 +145,7 @@ services:
working_dir: /var/www/html
volumes:
- ./src:/var/www/html
- vendor_data:/var/www/html/vendor
- ./docker/php/local.ini:/usr/local/etc/php/conf.d/local.ini
networks:
- laravel_network
@@ -169,3 +172,4 @@ volumes:
mysql_data:
pgsql_data:
redis_data:
vendor_data: