diff --git a/src/Service/Docker.php b/src/Service/Docker.php index f4db5d9..f43926e 100644 --- a/src/Service/Docker.php +++ b/src/Service/Docker.php @@ -6,6 +6,7 @@ use App\Model\DockerContainer; use App\Model\DockerData; use App\Model\DockerNetwork; +use App\StaticVars; use App\Traits\ExecTrait; use splitbrain\phpcli\Exception; @@ -501,9 +502,12 @@ public function buildImageWithCompose(string $composeFile, DockerData $dockerDat $dockerBuildKit = $usesSsh ? 'DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 ' : ''; $composeCmd = $this->getComposeCommand(); $baseArgs = "--project-directory {$projectDirEscaped} -f {$composeFileEscaped} build"; + if (StaticVars::$ciMode) { + $baseArgs .= ' --no-cache'; + } $cmd = "{$dockerBuildKit}{$composeCmd} {$baseArgs}"; $errorMsg = "Failed to build image with docker compose"; - $this->exec($cmd, $errorMsg); + $this->execPassthru($cmd, $errorMsg); // Get the built image name from compose and tag it with our custom name // This is a bit tricky - we need to inspect what compose built and rename it diff --git a/src/Tests/DockerComposeBuildCommandTest.php b/src/Tests/DockerComposeBuildCommandTest.php index 1334d1d..677003b 100644 --- a/src/Tests/DockerComposeBuildCommandTest.php +++ b/src/Tests/DockerComposeBuildCommandTest.php @@ -22,6 +22,10 @@ protected function exec(string $cmd, ?string $errorMsg = null, ?bool $silent = f $this->commands[] = $cmd; return ''; } + + protected function execPassthru(string $cmd, ?string $errorMsg = null): void { + $this->commands[] = $cmd; + } }; $configurator = $this->getMockBuilder(Configurator::class) @@ -60,11 +64,15 @@ public function __construct() { } protected function exec(string $cmd, ?string $errorMsg = null, ?bool $silent = false): string { + $this->commands[] = $cmd; + return ''; + } + + protected function execPassthru(string $cmd, ?string $errorMsg = null): void { $this->commands[] = $cmd; if (str_contains($cmd, ' build')) { throw new ExecFailed('build fails', 0, $cmd); } - return ''; } };