added beluga-php/docker-php client and some basic updates to the base Container class

This commit is contained in:
Sergei Shitikov
2024-08-22 16:41:51 +02:00
parent 68a2d6d47c
commit c82e974ab9
8 changed files with 154 additions and 133 deletions
+6 -3
View File
@@ -4,21 +4,24 @@ declare(strict_types=1);
namespace Testcontainers\Wait;
use Docker\Docker;
use Symfony\Component\Process\Process;
use Testcontainers\Exception\ContainerNotReadyException;
class WaitForLog implements WaitInterface
{
protected Docker $dockerClient;
public function __construct(private string $message, private bool $enableRegex = false)
{
$this->dockerClient = Docker::create();
}
public function wait(string $id): void
{
$process = new Process(['docker', 'logs', $id]);
$process->mustRun();
$logs = $this->dockerClient->containerLogs($id);
$output = $process->getOutput() . PHP_EOL . $process->getErrorOutput();
$output = $logs->getBody()->getContents();
if ($this->enableRegex) {
if (!preg_match($this->message, $output)) {