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
4 changes: 3 additions & 1 deletion src/Environments/DockerEnvironment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}

protected function printedArtisan(): string
Expand Down
41 changes: 41 additions & 0 deletions tests/Feature/Environments/DockerStorageLinkTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace Saucebase\Installer\Tests\Feature\Environments;

use Illuminate\Support\Facades\Process;
use Saucebase\Installer\Console\Commands\InstallCommand;
use Saucebase\Installer\Environments\DockerEnvironment;
use Saucebase\Installer\Tests\Feature\TestableInstallCommand;
use Saucebase\Installer\Tests\TestCase;

/**
* The link is made in the container, but the host serves the app too (the E2E server, `artisan
* serve`): an absolute link points at /var/www, which only the container has.
*/
class DockerStorageLinkTest extends TestCase
{
public function test_the_storage_link_is_relative_so_the_host_can_follow_it(): void
{
Process::fake();

$command = new class extends TestableInstallCommand
{
public function line($string, $style = null, $verbosity = null): void {}

public function info($string, $verbosity = null): void {}
};
$command->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']);
}
}