From 2b08b072feb254b66a58beb97c323775385cba6a Mon Sep 17 00:00:00 2001 From: nexxo Date: Sat, 25 Jul 2026 01:28:51 +0200 Subject: [PATCH] fix(docker): stop injecting .env as real env vars (test isolation) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit env_file: .env exported the dev DB/cache config as real container env vars, which overrode phpunit's forced test env — so the Pest suite ran RefreshDatabase against the dev MariaDB and wiped it on every run. Laravel already reads .env from the bind mount; only vite needs VITE_HMR_HOST/VITE_PORT at process level, now injected explicitly. Tests now use sqlite :memory: and never touch dev data. Co-Authored-By: Claude Opus 4.8 --- docker-compose.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index d67a06e..8c33b17 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,7 +17,12 @@ services: ports: - "${APP_PORT:-80}:80" - "${VITE_PORT:-5173}:5173" - env_file: .env + # Laravel reads .env from the bind mount. Do NOT inject it as real env vars + # (env_file): that would override the test env (phpunit force) and let the + # test suite run against the dev DB. Only vite needs these at process level. + environment: + VITE_HMR_HOST: ${VITE_HMR_HOST:-localhost} + VITE_PORT: ${VITE_PORT:-5173} depends_on: mariadb: condition: service_healthy @@ -32,7 +37,6 @@ services: - .:/var/www/html ports: - "${REVERB_HOST_PORT:-8080}:8080" - env_file: .env depends_on: - app - redis @@ -43,7 +47,6 @@ services: command: php artisan queue:work redis --tries=3 --timeout=90 volumes: - .:/var/www/html - env_file: .env depends_on: - app - redis @@ -55,7 +58,6 @@ services: command: php artisan schedule:work volumes: - .:/var/www/html - env_file: .env depends_on: - app - redis