-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Sironheart/main
Add Postgres Container
- Loading branch information
Showing
9 changed files
with
88 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Testcontainer\Container; | ||
|
||
use Testcontainer\Wait\WaitForExec; | ||
|
||
class PostgresContainer extends Container | ||
{ | ||
private function __construct(string $version, string $rootPassword) | ||
{ | ||
parent::__construct('postgres:' . $version); | ||
$this->withEnvironment('POSTGRES_PASSWORD', $rootPassword); | ||
$this->withWait(new WaitForExec(["pg_isready", "-h", "127.0.0.1"])); | ||
} | ||
|
||
public static function make(string $version = 'latest', string $dbPassword = 'root'): self | ||
{ | ||
return new self($version, $dbPassword); | ||
} | ||
|
||
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters