Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions src/Environments/DockerEnvironment.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ protected function boot(InstallCommand $command): int
}
}

$this->setTaskfilePrefix($command);
$command->nameProject();

if (! $this->generateAppKey($command)) {
Expand Down Expand Up @@ -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<string, int> $ports Env key => port, forced over any existing value. */
protected function applyDockerEnvDefaults(string $env, bool $ssl = true, array $ports = []): string
{
Expand Down
31 changes: 31 additions & 0 deletions tests/Feature/Environments/DockerEnvironmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
// -------------------------------------------------------------------------
Expand Down Expand Up @@ -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
Expand Down
Loading