From 4fbbeaccc6ad10ef03bf58063d353b40127823b0 Mon Sep 17 00:00:00 2001 From: roble Date: Tue, 20 Oct 2026 09:24:54 +0100 Subject: [PATCH 1/2] feat: Docker driver sets the Taskfile APP prefix (sc-1052) Co-Authored-By: Claude Opus 5.5 --- CLAUDE.md | 2 +- src/Environments/DockerEnvironment.php | 23 +++++++++++++ .../Environments/DockerEnvironmentTest.php | 32 +++++++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/CLAUDE.md b/CLAUDE.md index bf0b5dc..ab003ef 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -63,7 +63,7 @@ composer install 4. `generateSsl()` — mkcert for `*.localhost` (no-op if disabled or certs exist) 5. `ensureEnvFile()` → `setDockerEnvDefaults()` → `applyDockerEnvDefaults()`: `DB_CONNECTION=mysql`, MySQL creds, `MAIL_MAILER=smtp`, `APP_URL=https://localhost` (or `http://` if SSL off) 6. `startDocker()` — `docker compose restart` + `up -d --wait --build` (30 min timeout, streaming), cwd = target -7. `runComposerInContainer()` → `generateAppKey()` → `runMigrations()` via `execInContainer()` +7. `runComposerInContainer()` → core install steps → `setTaskfilePrefix()` (empty `APP: ''` in `Taskfile.yml` → `'docker compose exec app'`) → `generateAppKey()` → `runMigrations()` via `execInContainer()` 8. `runStack()` — **runs on the host** (files are volume-mounted) by delegating to `InstallCommand::runStack()`, not inside the container 9. `installModules()` — batched `composer require` in container → `applyModulePatches()` on host → `modules:sync` / `migrate` / per-module seed in container 10. `createStorageLink()` + `clearCaches()` in container diff --git a/src/Environments/DockerEnvironment.php b/src/Environments/DockerEnvironment.php index f01451b..030fcbf 100644 --- a/src/Environments/DockerEnvironment.php +++ b/src/Environments/DockerEnvironment.php @@ -110,6 +110,7 @@ protected function boot(InstallCommand $command): int } } + $this->setTaskfilePrefix($command); $command->nameProject(); if (! $this->generateAppKey($command)) { @@ -823,6 +824,28 @@ protected function setDockerEnvDefaults(InstallCommand $command): void } } + /** Core's Taskfile stub ships an empty APP prefix; under Docker, tasks run in the app container. */ + protected function setTaskfilePrefix(InstallCommand $command): void + { + $path = $command->path('Taskfile.yml'); + + if (! is_file($path)) { + return; + } + + $original = (string) file_get_contents($path); + $modified = $this->applyDockerTaskPrefix($original); + + if ($modified !== $original) { + file_put_contents($path, $modified); + } + } + + protected function applyDockerTaskPrefix(string $taskfile): string + { + return preg_replace("/^(\s*APP:\s*)''/m", "$1'docker compose exec app'", $taskfile, 1) ?? $taskfile; + } + /** @param array $ports Env key => port, forced over any existing value. */ protected function applyDockerEnvDefaults(string $env, bool $ssl = true, array $ports = []): string { diff --git a/tests/Feature/Environments/DockerEnvironmentTest.php b/tests/Feature/Environments/DockerEnvironmentTest.php index 068eec8..46de153 100644 --- a/tests/Feature/Environments/DockerEnvironmentTest.php +++ b/tests/Feature/Environments/DockerEnvironmentTest.php @@ -648,6 +648,24 @@ public function test_check_ports_does_not_offer_to_stop_docker_when_a_plain_proc $this->assertSame([], $env->exposedStoppableTargets(['a' => 6379, 'b' => 8025], $env->fakeOwners)); } + // ------------------------------------------------------------------------- + // applyDockerTaskPrefix + // ------------------------------------------------------------------------- + + public function test_sets_the_empty_taskfile_prefix_to_the_app_container(): void + { + $result = $this->applyTaskPrefix("vars:\n # Prefix\n APP: ''\n\ntasks:\n"); + + $this->assertSame("vars:\n # Prefix\n APP: 'docker compose exec app'\n\ntasks:\n", $result); + } + + public function test_keeps_a_taskfile_prefix_already_set(): void + { + $taskfile = "vars:\n APP: 'sail'\n"; + + $this->assertSame($taskfile, $this->applyTaskPrefix($taskfile)); + } + // ------------------------------------------------------------------------- // applyDockerEnvDefaults // ------------------------------------------------------------------------- @@ -1383,6 +1401,19 @@ public function useSsl(bool $ssl): void }; } + private function applyTaskPrefix(string $taskfile): string + { + $exposed = new class extends DockerEnvironment + { + public function applyDockerTaskPrefix(string $taskfile): string + { + return parent::applyDockerTaskPrefix($taskfile); + } + }; + + return $exposed->applyDockerTaskPrefix($taskfile); + } + private function applyDefaults(string $env, bool $ssl = true, array $ports = []): string { $exposed = new class extends DockerEnvironment @@ -1499,4 +1530,5 @@ public function line($string, $style = null, $verbosity = null): void {} public function info($string, $verbosity = null): void {} public function warn($string, $verbosity = null): void {} + } From be2358411b40a53932109540271bf503053f450f Mon Sep 17 00:00:00 2001 From: roble <3231587+roble@users.noreply.github.com> Date: Tue, 20 Oct 2026 08:25:21 +0000 Subject: [PATCH 2/2] PHP Linting (Pint) --- tests/Feature/Environments/DockerEnvironmentTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/Feature/Environments/DockerEnvironmentTest.php b/tests/Feature/Environments/DockerEnvironmentTest.php index 46de153..a04fd35 100644 --- a/tests/Feature/Environments/DockerEnvironmentTest.php +++ b/tests/Feature/Environments/DockerEnvironmentTest.php @@ -1530,5 +1530,4 @@ public function line($string, $style = null, $verbosity = null): void {} public function info($string, $verbosity = null): void {} public function warn($string, $verbosity = null): void {} - }