diff --git a/src/Environments/DockerEnvironment.php b/src/Environments/DockerEnvironment.php index 9d0579f..432fae3 100644 --- a/src/Environments/DockerEnvironment.php +++ b/src/Environments/DockerEnvironment.php @@ -822,7 +822,9 @@ protected function nextSteps(InstallCommand $command): array protected function createStorageLink(InstallCommand $command): void { $command->info('Creating storage link...'); - $this->execInContainer($command, ['php', 'artisan', 'storage:link']); + // Relative: made in the container, but the host serves the app too (E2E, `artisan serve`), + // and an absolute link points at /var/www, which only the container has. + $this->execInContainer($command, ['php', 'artisan', 'storage:link', '--relative']); } protected function printedArtisan(): string diff --git a/tests/Feature/Environments/DockerStorageLinkTest.php b/tests/Feature/Environments/DockerStorageLinkTest.php new file mode 100644 index 0000000..c3f521a --- /dev/null +++ b/tests/Feature/Environments/DockerStorageLinkTest.php @@ -0,0 +1,41 @@ +fakeOptions = ['path' => sys_get_temp_dir()]; + + $docker = new class extends DockerEnvironment + { + public function link(InstallCommand $command): void + { + $this->createStorageLink($command); + } + }; + + $docker->link($command); + + Process::assertRan(fn ($process) => $process->command === ['docker', 'compose', 'exec', '-T', 'app', 'php', 'artisan', 'storage:link', '--relative']); + } +}