feat: Add postgres container

This commit is contained in:
Steffen Beisenherz
2022-10-23 14:56:44 +02:00
parent b90e75aa3d
commit 45f0e11f69
7 changed files with 61 additions and 5 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ class Container
*/
private array $mounts = [];
public function __construct(private string $image)
protected function __construct(private string $image)
{
$this->wait = new WaitForNothing();
}
+1 -1
View File
@@ -8,7 +8,7 @@ use Testcontainer\Wait\WaitForExec;
class MariaDBContainer extends Container
{
public function __construct(string $version = 'latest', string $mysqlRootPassword = 'root')
private function __construct(string $version, string $mysqlRootPassword)
{
parent::__construct('mariadb:' . $version);
$this->withEnvironment('MARIADB_ROOT_PASSWORD', $mysqlRootPassword);
+1 -1
View File
@@ -8,7 +8,7 @@ use Testcontainer\Wait\WaitForExec;
class MySQLContainer extends Container
{
public function __construct(string $version = 'latest', string $mysqlRootPassword = 'root')
private function __construct(string $version, string $mysqlRootPassword)
{
parent::__construct('mysql:' . $version);
$this->withEnvironment('MYSQL_ROOT_PASSWORD', $mysqlRootPassword);
+1 -1
View File
@@ -8,7 +8,7 @@ use Testcontainer\Wait\WaitForHttp;
class OpenSearchContainer extends Container
{
public function __construct(string $version = 'latest')
private function __construct(string $version)
{
parent::__construct('opensearchproject/opensearch:' . $version);
$this->withEnvironment('discovery.type', 'single-node');
+33
View File
@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace Testcontainer\Container;
class PostgresContainer extends Container
{
private function __construct(string $version, string $rootPassword)
{
parent::__construct('mariadb:' . $version);
$this->withEnvironment('POSTGRES_PASSWORD', $rootPassword);
}
public static function make(string $version = 'latest', string $mysqlRootPassword = 'root'): self
{
return new self($version, $mysqlRootPassword);
}
public function withPostgresUser(string $username): self
{
$this->withEnvironment('POSTGRES_USER', $username);
return $this;
}
public function withPostgresDatabase(string $database): self
{
$this->withEnvironment('POSTGRES_DB', $database);
return $this;
}
}
+1 -1
View File
@@ -8,7 +8,7 @@ use Testcontainer\Wait\WaitForLog;
class RedisContainer extends Container
{
public function __construct(string $version = 'latest')
private function __construct(string $version)
{
parent::__construct('redis:' . $version);
$this->withWait(new WaitForLog('Ready to accept connections'));