From 0864d38bd89642a8e0fd8ab57c9aa9e13e1f0498 Mon Sep 17 00:00:00 2001 From: Aydin Hassan Date: Tue, 27 Oct 2026 20:45:13 +0100 Subject: [PATCH 1/5] Keep composer's vendor folder in a volume on the docker host DockerSandbox puts vendor in a volume for each folder composer installs into. Later runs in that folder mount it read-only, and cleanup() removes the volumes when the verify or run finishes. Workshop images need /solution/vendor, like /composer, so the volume is writable. --- app/config.php | 8 +++++ src/Process/DockerSandbox.php | 25 ++++++++++++++- src/Process/HostSandbox.php | 2 ++ src/Process/Sandbox.php | 5 +++ src/ReferencePackages.php | 2 ++ test/ExerciseRunner/CliRunnerTest.php | 2 ++ test/Process/DockerSandboxTest.php | 45 +++++++++++++++++++++++++-- 7 files changed, 86 insertions(+), 3 deletions(-) diff --git a/app/config.php b/app/config.php index 41e140cd..8a13f4e2 100644 --- a/app/config.php +++ b/app/config.php @@ -498,6 +498,14 @@ function (CgiResult $result) use ($c) { containerListener(PrepareSolutionListener::class), ], ], + 'sandbox-cleanup' => [ + 'verify.finish' => [ + containerListener(Sandbox::class, 'cleanup'), + ], + 'run.finish' => [ + containerListener(Sandbox::class, 'cleanup'), + ], + ], //before the code patcher and the checks touch the student's files on the host 'remove-student-symlinks' => [ 'verify.post.execute' => [ diff --git a/src/Process/DockerSandbox.php b/src/Process/DockerSandbox.php index f81353e6..719ff4bc 100644 --- a/src/Process/DockerSandbox.php +++ b/src/Process/DockerSandbox.php @@ -24,6 +24,13 @@ final class DockerSandbox implements Sandbox private string $portsNetwork; private string $portsHost; + /** + * Folders composer has installed into, and the volume holding their vendor folder, eg. ['/tmp/abc' => 'php-school-vendor-1a2b3c'] + * + * @var array + */ + private array $vendorVolumes = []; + public function __construct( string $basePath, string $projectName, @@ -65,18 +72,34 @@ public function getHost(): SandboxHost return new SandboxHost($this->portsHost); } + public function cleanup(): void + { + foreach ($this->vendorVolumes as $volume) { + (new Process([$this->findDocker(), 'volume', 'rm', '-f', $volume]))->run(); + } + + $this->vendorVolumes = []; + } + public function create(ProcessInput $processInput): DockerExecution { $isComposer = $processInput->getExecutable() === 'composer'; $args = $processInput->getArgs(); - $mounts = [$processInput->getWorkingDirectory() . ':/solution']; + $directory = $processInput->getWorkingDirectory(); + $mounts = [$directory . ':/solution']; $env = ['COMPOSER_HOME' => '/composer']; if ($isComposer) { //we need to mount a volume for composer cache, and never run package plugins or scripts $mounts[] = self::COMPOSER_CACHE_VOLUME . ':/composer'; $args = [...$args, '--no-plugins', '--no-scripts']; + + //vendor stays on the docker host until cleanup(), so it is never copied around + $this->vendorVolumes[$directory] ??= 'php-school-vendor-' . bin2hex(random_bytes(6)); + $mounts[] = $this->vendorVolumes[$directory] . ':/solution/vendor'; + } elseif (isset($this->vendorVolumes[$directory])) { + $mounts[] = $this->vendorVolumes[$directory] . ':/solution/vendor:ro'; } $network = ['--network', 'none']; diff --git a/src/Process/HostSandbox.php b/src/Process/HostSandbox.php index fce86247..b760faf7 100644 --- a/src/Process/HostSandbox.php +++ b/src/Process/HostSandbox.php @@ -27,6 +27,8 @@ public function getHost(): SandboxHost return new SandboxHost(); } + public function cleanup(): void {} + public function create(ProcessInput $processInput): HostExecution { $executablePath = $this->executableFinder->find($processInput->getExecutable()); diff --git a/src/Process/Sandbox.php b/src/Process/Sandbox.php index b2c054bc..92135eec 100644 --- a/src/Process/Sandbox.php +++ b/src/Process/Sandbox.php @@ -9,4 +9,9 @@ interface Sandbox public function create(ProcessInput $processInput): SandboxExecution; public function getHost(): SandboxHost; + + /** + * Removes anything kept between runs, eg. vendor volumes. Called when a verify or run finishes. + */ + public function cleanup(): void; } diff --git a/src/ReferencePackages.php b/src/ReferencePackages.php index 85c0a00a..ad966e83 100644 --- a/src/ReferencePackages.php +++ b/src/ReferencePackages.php @@ -49,5 +49,7 @@ public function warm(): void //verifies install from the cache, this copy is never used $this->filesystem->remove($directory . '/vendor'); } + + $this->sandbox->cleanup(); } } diff --git a/test/ExerciseRunner/CliRunnerTest.php b/test/ExerciseRunner/CliRunnerTest.php index 46ff49d5..7cc031db 100644 --- a/test/ExerciseRunner/CliRunnerTest.php +++ b/test/ExerciseRunner/CliRunnerTest.php @@ -189,6 +189,8 @@ public function getHost(): SandboxHost { return new SandboxHost(); } + + public function cleanup(): void {} }; $runner = new CliRunner($this->exercise, $this->eventDispatcher, $sandbox, new EnvironmentManager(new Filesystem(), $this->eventDispatcher)); diff --git a/test/Process/DockerSandboxTest.php b/test/Process/DockerSandboxTest.php index 455d693d..658804bd 100644 --- a/test/Process/DockerSandboxTest.php +++ b/test/Process/DockerSandboxTest.php @@ -78,10 +78,51 @@ public function testComposerGetsNetworkCacheAndNoPluginsOrScripts(): void $expected = $this->expectedCommand( ['--network', 'bridge'], - ['-e', 'COMPOSER_HOME=/composer', '-v', __DIR__ . ':/solution', '-v', 'php-school-composer-cache:/composer'], + [ + '-e', 'COMPOSER_HOME=/composer', '-v', __DIR__ . ':/solution', '-v', 'php-school-composer-cache:/composer', + '-v', 'VENDOR_VOLUME:/solution/vendor', + ], ['composer', 'install', '--no-plugins', '--no-scripts'], ); - static::assertSame($expected, $process->getCommandLine()); + static::assertMatchesRegularExpression( + '/^' . str_replace('VENDOR_VOLUME', 'php-school-vendor-[0-9a-f]{12}', preg_quote($expected, '/')) . '$/', + $process->getCommandLine(), + ); + } + + public function testRunsAfterComposerGetsItsVendorVolumeReadOnly(): void + { + $sandbox = new DockerSandbox('/docker-dir', 'php8appreciate', $this->anyFinder()); + + $composer = $sandbox->create(new ProcessInput('composer', ['install'], __DIR__, [], []))->process->getCommandLine(); + preg_match('/php-school-vendor-[0-9a-f]{12}/', $composer, $volume); + + $php = $sandbox->create(new ProcessInput('php', ['solution.php'], __DIR__, [], []))->process->getCommandLine(); + static::assertStringContainsString("'-v' '" . $volume[0] . ":/solution/vendor:ro'", $php); + + //another folder, eg. a student's own vendor on the cli, is left alone + $other = $sandbox->create(new ProcessInput('php', ['solution.php'], '/elsewhere', [], []))->process->getCommandLine(); + static::assertStringNotContainsString('php-school-vendor-', $other); + } + + public function testCleanupForgetsTheVendorVolumes(): void + { + $sandbox = new DockerSandbox('/docker-dir', 'php8appreciate', $this->anyFinder()); + $sandbox->create(new ProcessInput('composer', ['install'], __DIR__, [], [])); + + $sandbox->cleanup(); + + $php = $sandbox->create(new ProcessInput('php', ['solution.php'], __DIR__, [], []))->process->getCommandLine(); + static::assertStringNotContainsString('php-school-vendor-', $php); + } + + private function anyFinder(): ExecutableFinder + { + $finder = $this->createMock(ExecutableFinder::class); + //docker volume rm of a missing volume is harmless, -f ignores it + $finder->method('find')->with('docker')->willReturn('docker'); + + return $finder; } public function testExposedPortsArePublishedOnLoopbackOnly(): void From 09eff11ec2b1d131079fa06d2c4bceddadec619f Mon Sep 17 00:00:00 2001 From: Aydin Hassan Date: Sat, 31 Oct 2026 21:23:54 +0100 Subject: [PATCH 2/5] Take vendor volumes as a DockerSandbox constructor argument The caller lists which folders keep vendor in which volume, so it can stay between verifies. Drops the random volumes and Sandbox::cleanup(). --- app/config.php | 8 ----- src/Process/DockerSandbox.php | 46 +++++++++++++++------------ src/Process/HostSandbox.php | 2 -- src/Process/Sandbox.php | 5 --- src/ReferencePackages.php | 2 -- test/ExerciseRunner/CliRunnerTest.php | 2 -- test/Process/DockerSandboxTest.php | 43 ++++++++++--------------- 7 files changed, 42 insertions(+), 66 deletions(-) diff --git a/app/config.php b/app/config.php index 8a13f4e2..41e140cd 100644 --- a/app/config.php +++ b/app/config.php @@ -498,14 +498,6 @@ function (CgiResult $result) use ($c) { containerListener(PrepareSolutionListener::class), ], ], - 'sandbox-cleanup' => [ - 'verify.finish' => [ - containerListener(Sandbox::class, 'cleanup'), - ], - 'run.finish' => [ - containerListener(Sandbox::class, 'cleanup'), - ], - ], //before the code patcher and the checks touch the student's files on the host 'remove-student-symlinks' => [ 'verify.post.execute' => [ diff --git a/src/Process/DockerSandbox.php b/src/Process/DockerSandbox.php index 719ff4bc..31e5ddca 100644 --- a/src/Process/DockerSandbox.php +++ b/src/Process/DockerSandbox.php @@ -25,18 +25,21 @@ final class DockerSandbox implements Sandbox private string $portsHost; /** - * Folders composer has installed into, and the volume holding their vendor folder, eg. ['/tmp/abc' => 'php-school-vendor-1a2b3c'] - * * @var array */ - private array $vendorVolumes = []; + private array $vendorVolumes; + /** + * @param array $vendorVolumes folder => volume, for runs in that folder or below it, so vendor stays + * on the docker host between runs, eg. ['/tmp/php-school/' => 'php-school-vendor--'] + */ public function __construct( string $basePath, string $projectName, ?ExecutableFinder $executableFinder = null, string $portsNetwork = 'bridge', string $portsHost = '127.0.0.1', + array $vendorVolumes = [], ) { $this->executableFinder = $executableFinder ?? new ExecutableFinder(); $this->basePath = $basePath; @@ -46,6 +49,7 @@ public function __construct( $this->portsNetwork = $portsNetwork; //the address ports are published on, the docker host's private address when it is remote $this->portsHost = $portsHost; + $this->vendorVolumes = $vendorVolumes; } public function getImageName(): string @@ -72,34 +76,25 @@ public function getHost(): SandboxHost return new SandboxHost($this->portsHost); } - public function cleanup(): void - { - foreach ($this->vendorVolumes as $volume) { - (new Process([$this->findDocker(), 'volume', 'rm', '-f', $volume]))->run(); - } - - $this->vendorVolumes = []; - } - public function create(ProcessInput $processInput): DockerExecution { $isComposer = $processInput->getExecutable() === 'composer'; $args = $processInput->getArgs(); - $directory = $processInput->getWorkingDirectory(); - $mounts = [$directory . ':/solution']; + $mounts = [$processInput->getWorkingDirectory() . ':/solution']; + + $vendorVolume = $this->findVendorVolume($processInput->getWorkingDirectory()); + if ($vendorVolume !== null) { + //only composer writes to it + $mounts[] = $vendorVolume . ':/solution/vendor' . ($isComposer ? '' : ':ro'); + } + $env = ['COMPOSER_HOME' => '/composer']; if ($isComposer) { //we need to mount a volume for composer cache, and never run package plugins or scripts $mounts[] = self::COMPOSER_CACHE_VOLUME . ':/composer'; $args = [...$args, '--no-plugins', '--no-scripts']; - - //vendor stays on the docker host until cleanup(), so it is never copied around - $this->vendorVolumes[$directory] ??= 'php-school-vendor-' . bin2hex(random_bytes(6)); - $mounts[] = $this->vendorVolumes[$directory] . ':/solution/vendor'; - } elseif (isset($this->vendorVolumes[$directory])) { - $mounts[] = $this->vendorVolumes[$directory] . ':/solution/vendor:ro'; } $network = ['--network', 'none']; @@ -166,6 +161,17 @@ public function create(ProcessInput $processInput): DockerExecution )); } + private function findVendorVolume(string $directory): ?string + { + foreach ($this->vendorVolumes as $folder => $volume) { + if (str_starts_with($directory . '/', rtrim($folder, '/') . '/')) { + return $volume; + } + } + + return null; + } + private function findDocker(): string { $dockerPath = $this->executableFinder->find('docker'); diff --git a/src/Process/HostSandbox.php b/src/Process/HostSandbox.php index b760faf7..fce86247 100644 --- a/src/Process/HostSandbox.php +++ b/src/Process/HostSandbox.php @@ -27,8 +27,6 @@ public function getHost(): SandboxHost return new SandboxHost(); } - public function cleanup(): void {} - public function create(ProcessInput $processInput): HostExecution { $executablePath = $this->executableFinder->find($processInput->getExecutable()); diff --git a/src/Process/Sandbox.php b/src/Process/Sandbox.php index 92135eec..b2c054bc 100644 --- a/src/Process/Sandbox.php +++ b/src/Process/Sandbox.php @@ -9,9 +9,4 @@ interface Sandbox public function create(ProcessInput $processInput): SandboxExecution; public function getHost(): SandboxHost; - - /** - * Removes anything kept between runs, eg. vendor volumes. Called when a verify or run finishes. - */ - public function cleanup(): void; } diff --git a/src/ReferencePackages.php b/src/ReferencePackages.php index ad966e83..85c0a00a 100644 --- a/src/ReferencePackages.php +++ b/src/ReferencePackages.php @@ -49,7 +49,5 @@ public function warm(): void //verifies install from the cache, this copy is never used $this->filesystem->remove($directory . '/vendor'); } - - $this->sandbox->cleanup(); } } diff --git a/test/ExerciseRunner/CliRunnerTest.php b/test/ExerciseRunner/CliRunnerTest.php index 7cc031db..46ff49d5 100644 --- a/test/ExerciseRunner/CliRunnerTest.php +++ b/test/ExerciseRunner/CliRunnerTest.php @@ -189,8 +189,6 @@ public function getHost(): SandboxHost { return new SandboxHost(); } - - public function cleanup(): void {} }; $runner = new CliRunner($this->exercise, $this->eventDispatcher, $sandbox, new EnvironmentManager(new Filesystem(), $this->eventDispatcher)); diff --git a/test/Process/DockerSandboxTest.php b/test/Process/DockerSandboxTest.php index 658804bd..ff278dcd 100644 --- a/test/Process/DockerSandboxTest.php +++ b/test/Process/DockerSandboxTest.php @@ -78,49 +78,38 @@ public function testComposerGetsNetworkCacheAndNoPluginsOrScripts(): void $expected = $this->expectedCommand( ['--network', 'bridge'], - [ - '-e', 'COMPOSER_HOME=/composer', '-v', __DIR__ . ':/solution', '-v', 'php-school-composer-cache:/composer', - '-v', 'VENDOR_VOLUME:/solution/vendor', - ], + ['-e', 'COMPOSER_HOME=/composer', '-v', __DIR__ . ':/solution', '-v', 'php-school-composer-cache:/composer'], ['composer', 'install', '--no-plugins', '--no-scripts'], ); - static::assertMatchesRegularExpression( - '/^' . str_replace('VENDOR_VOLUME', 'php-school-vendor-[0-9a-f]{12}', preg_quote($expected, '/')) . '$/', - $process->getCommandLine(), - ); + static::assertSame($expected, $process->getCommandLine()); } - public function testRunsAfterComposerGetsItsVendorVolumeReadOnly(): void + public function testVendorVolumeIsWritableForComposerOnly(): void { - $sandbox = new DockerSandbox('/docker-dir', 'php8appreciate', $this->anyFinder()); + $sandbox = new DockerSandbox('/docker-dir', 'php8appreciate', $this->anyFinder(), vendorVolumes: ['/tmp/student/' => 'vendor-student']); - $composer = $sandbox->create(new ProcessInput('composer', ['install'], __DIR__, [], []))->process->getCommandLine(); - preg_match('/php-school-vendor-[0-9a-f]{12}/', $composer, $volume); + $composer = $sandbox->create(new ProcessInput('composer', ['update'], '/tmp/student/abc', [], []))->process; + static::assertStringContainsString("'-v' 'vendor-student:/solution/vendor' ", $composer->getCommandLine()); - $php = $sandbox->create(new ProcessInput('php', ['solution.php'], __DIR__, [], []))->process->getCommandLine(); - static::assertStringContainsString("'-v' '" . $volume[0] . ":/solution/vendor:ro'", $php); - - //another folder, eg. a student's own vendor on the cli, is left alone - $other = $sandbox->create(new ProcessInput('php', ['solution.php'], '/elsewhere', [], []))->process->getCommandLine(); - static::assertStringNotContainsString('php-school-vendor-', $other); + $php = $sandbox->create(new ProcessInput('php', ['solution.php'], '/tmp/student/def', [], []))->process; + static::assertStringContainsString("'-v' 'vendor-student:/solution/vendor:ro' ", $php->getCommandLine()); } - public function testCleanupForgetsTheVendorVolumes(): void + public function testFoldersOutsideTheVendorVolumesKeepTheirOwnVendor(): void { - $sandbox = new DockerSandbox('/docker-dir', 'php8appreciate', $this->anyFinder()); - $sandbox->create(new ProcessInput('composer', ['install'], __DIR__, [], [])); - - $sandbox->cleanup(); + $sandbox = new DockerSandbox('/docker-dir', 'php8appreciate', $this->anyFinder(), vendorVolumes: ['/tmp/student' => 'vendor-student']); - $php = $sandbox->create(new ProcessInput('php', ['solution.php'], __DIR__, [], []))->process->getCommandLine(); - static::assertStringNotContainsString('php-school-vendor-', $php); + //eg. the reference solution, or a sibling folder whose name starts the same + foreach (['/tmp/reference', '/tmp/student-2'] as $directory) { + $process = $sandbox->create(new ProcessInput('composer', ['install'], $directory, [], []))->process; + static::assertStringNotContainsString('vendor-student', $process->getCommandLine()); + } } private function anyFinder(): ExecutableFinder { $finder = $this->createMock(ExecutableFinder::class); - //docker volume rm of a missing volume is harmless, -f ignores it - $finder->method('find')->with('docker')->willReturn('docker'); + $finder->method('find')->with('docker')->willReturn('/usr/local/bin/docker'); return $finder; } From 32306102bdb14c1902bdf2c869cb07c6a65e3b64 Mon Sep 17 00:00:00 2001 From: Aydin Hassan Date: Sat, 31 Oct 2026 21:29:00 +0100 Subject: [PATCH 3/5] Match vendor volume folders on the parent folder with Path::join --- src/Process/DockerSandbox.php | 7 ++++--- test/Process/DockerSandboxTest.php | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Process/DockerSandbox.php b/src/Process/DockerSandbox.php index 31e5ddca..3f1bb742 100644 --- a/src/Process/DockerSandbox.php +++ b/src/Process/DockerSandbox.php @@ -4,6 +4,7 @@ namespace PhpSchool\PhpWorkshop\Process; +use PhpSchool\PhpWorkshop\Utils\Path; use Symfony\Component\Process\ExecutableFinder; use Symfony\Component\Process\Process; @@ -30,8 +31,8 @@ final class DockerSandbox implements Sandbox private array $vendorVolumes; /** - * @param array $vendorVolumes folder => volume, for runs in that folder or below it, so vendor stays - * on the docker host between runs, eg. ['/tmp/php-school/' => 'php-school-vendor--'] + * @param array $vendorVolumes folder => volume, for runs in a folder directly inside it, so vendor + * stays on the docker host between runs, eg. ['/tmp/php-school/' => 'php-school-vendor--'] */ public function __construct( string $basePath, @@ -164,7 +165,7 @@ public function create(ProcessInput $processInput): DockerExecution private function findVendorVolume(string $directory): ?string { foreach ($this->vendorVolumes as $folder => $volume) { - if (str_starts_with($directory . '/', rtrim($folder, '/') . '/')) { + if (dirname($directory) === Path::join($folder)) { return $volume; } } diff --git a/test/Process/DockerSandboxTest.php b/test/Process/DockerSandboxTest.php index ff278dcd..0575ba10 100644 --- a/test/Process/DockerSandboxTest.php +++ b/test/Process/DockerSandboxTest.php @@ -99,8 +99,8 @@ public function testFoldersOutsideTheVendorVolumesKeepTheirOwnVendor(): void { $sandbox = new DockerSandbox('/docker-dir', 'php8appreciate', $this->anyFinder(), vendorVolumes: ['/tmp/student' => 'vendor-student']); - //eg. the reference solution, or a sibling folder whose name starts the same - foreach (['/tmp/reference', '/tmp/student-2'] as $directory) { + //eg. the reference solution, a sibling folder whose name starts the same, or the listed folder itself + foreach (['/tmp/reference/abc', '/tmp/student-2/abc', '/tmp/student'] as $directory) { $process = $sandbox->create(new ProcessInput('composer', ['install'], $directory, [], []))->process; static::assertStringNotContainsString('vendor-student', $process->getCommandLine()); } From b9accacf0457efe6a79581ab17210a46f7db03b7 Mon Sep 17 00:00:00 2001 From: Aydin Hassan Date: Sat, 31 Oct 2026 21:30:31 +0100 Subject: [PATCH 4/5] Compare vendor volume folders directly --- src/Process/DockerSandbox.php | 3 +-- test/Process/DockerSandboxTest.php | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Process/DockerSandbox.php b/src/Process/DockerSandbox.php index 3f1bb742..8c465e10 100644 --- a/src/Process/DockerSandbox.php +++ b/src/Process/DockerSandbox.php @@ -4,7 +4,6 @@ namespace PhpSchool\PhpWorkshop\Process; -use PhpSchool\PhpWorkshop\Utils\Path; use Symfony\Component\Process\ExecutableFinder; use Symfony\Component\Process\Process; @@ -165,7 +164,7 @@ public function create(ProcessInput $processInput): DockerExecution private function findVendorVolume(string $directory): ?string { foreach ($this->vendorVolumes as $folder => $volume) { - if (dirname($directory) === Path::join($folder)) { + if (dirname($directory) === $folder) { return $volume; } } diff --git a/test/Process/DockerSandboxTest.php b/test/Process/DockerSandboxTest.php index 0575ba10..399f27ab 100644 --- a/test/Process/DockerSandboxTest.php +++ b/test/Process/DockerSandboxTest.php @@ -86,7 +86,7 @@ public function testComposerGetsNetworkCacheAndNoPluginsOrScripts(): void public function testVendorVolumeIsWritableForComposerOnly(): void { - $sandbox = new DockerSandbox('/docker-dir', 'php8appreciate', $this->anyFinder(), vendorVolumes: ['/tmp/student/' => 'vendor-student']); + $sandbox = new DockerSandbox('/docker-dir', 'php8appreciate', $this->anyFinder(), vendorVolumes: ['/tmp/student' => 'vendor-student']); $composer = $sandbox->create(new ProcessInput('composer', ['update'], '/tmp/student/abc', [], []))->process; static::assertStringContainsString("'-v' 'vendor-student:/solution/vendor' ", $composer->getCommandLine()); From 7e8c104bde3c3e0f7cec7030a9c09c4d928b511c Mon Sep 17 00:00:00 2001 From: Aydin Hassan Date: Sat, 31 Oct 2026 21:31:02 +0100 Subject: [PATCH 5/5] Look vendor volumes up by parent folder --- src/Process/DockerSandbox.php | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/Process/DockerSandbox.php b/src/Process/DockerSandbox.php index 8c465e10..c4b9d9bf 100644 --- a/src/Process/DockerSandbox.php +++ b/src/Process/DockerSandbox.php @@ -83,7 +83,7 @@ public function create(ProcessInput $processInput): DockerExecution $args = $processInput->getArgs(); $mounts = [$processInput->getWorkingDirectory() . ':/solution']; - $vendorVolume = $this->findVendorVolume($processInput->getWorkingDirectory()); + $vendorVolume = $this->vendorVolumes[dirname($processInput->getWorkingDirectory())] ?? null; if ($vendorVolume !== null) { //only composer writes to it $mounts[] = $vendorVolume . ':/solution/vendor' . ($isComposer ? '' : ':ro'); @@ -161,17 +161,6 @@ public function create(ProcessInput $processInput): DockerExecution )); } - private function findVendorVolume(string $directory): ?string - { - foreach ($this->vendorVolumes as $folder => $volume) { - if (dirname($directory) === $folder) { - return $volume; - } - } - - return null; - } - private function findDocker(): string { $dockerPath = $this->executableFinder->find('docker');