This commit is contained in:
2025-04-07 12:16:11 +01:00
parent ce8b201a1c
commit e15a80163b
62 changed files with 149 additions and 131 deletions

View File

@@ -9,15 +9,16 @@ use App\Drivers\DatabaseDriver;
class Postgres17Driver extends DatabaseDriver
{
public Plan $deploymentPlan;
public string $defaultUser = 'keystone';
public string $defaultDb = 'keystone';
public function __construct(
public ?string $containerName = null,
public ?string $containerId = null,
public ?string $defaultPassword = null,
)
{
) {
$this->deploymentPlan = new Plan(steps: [
new Step(
name: 'Run the docker image',
@@ -27,17 +28,17 @@ class Postgres17Driver extends DatabaseDriver
script: function () {
$script = collect();
if ($this->containerName) {
$script->push('docker stop ' . $this->containerName . ' || true');
} else if ($this->containerId) {
$script->push('docker stop ' . $this->containerId . ' || true');
$script->push('docker stop '.$this->containerName.' || true');
} elseif ($this->containerId) {
$script->push('docker stop '.$this->containerId.' || true');
}
$runCommand = "docker run -d";
$runCommand = 'docker run -d';
if ($this->containerName) {
$runCommand .= " --name {$this->containerName}";
}
if ($this->defaultPassword) {
$runCommand .= " -e POSTGRES_PASSWORD=[!defaultPassword!]";
$runCommand .= ' -e POSTGRES_PASSWORD=[!defaultPassword!]';
}
if ($this->defaultUser) {
$runCommand .= " -e POSTGRES_USER={$this->defaultUser}";
@@ -46,7 +47,7 @@ class Postgres17Driver extends DatabaseDriver
$runCommand .= " -e POSTGRES_DB={$this->defaultDb}";
}
$runCommand .= " -p 5432:5432 postgres:17";
$runCommand .= ' -p 5432:5432 postgres:17';
return $runCommand;
}
@@ -54,7 +55,7 @@ class Postgres17Driver extends DatabaseDriver
new Step(
name: 'Configure firewall',
script: 'ufw allow 5432/tcp || true',
)
),
]);
}
}
}