refactor(database): remove volume_configuration_dir and streamline configuration directory usage in MongoDB and PostgreSQL handlers
This commit is contained in:
@@ -18,8 +18,6 @@ class StartMongodb
|
|||||||
|
|
||||||
public string $configuration_dir;
|
public string $configuration_dir;
|
||||||
|
|
||||||
public string $volume_configuration_dir;
|
|
||||||
|
|
||||||
private ?SslCertificate $ssl_certificate = null;
|
private ?SslCertificate $ssl_certificate = null;
|
||||||
|
|
||||||
public function handle(StandaloneMongodb $database)
|
public function handle(StandaloneMongodb $database)
|
||||||
@@ -29,10 +27,7 @@ class StartMongodb
|
|||||||
$startCommand = 'mongod';
|
$startCommand = 'mongod';
|
||||||
|
|
||||||
$container_name = $this->database->uuid;
|
$container_name = $this->database->uuid;
|
||||||
$this->volume_configuration_dir = $this->configuration_dir = database_configuration_dir().'/'.$container_name;
|
$this->configuration_dir = database_configuration_dir().'/'.$container_name;
|
||||||
if (isDev()) {
|
|
||||||
$this->volume_configuration_dir = '/var/lib/docker/volumes/coolify_dev_coolify_data/_data/databases/'.$container_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->commands = [
|
$this->commands = [
|
||||||
"echo 'Starting database.'",
|
"echo 'Starting database.'",
|
||||||
@@ -178,7 +173,7 @@ class StartMongodb
|
|||||||
$docker_compose['services'][$container_name]['volumes'] ?? [],
|
$docker_compose['services'][$container_name]['volumes'] ?? [],
|
||||||
[[
|
[[
|
||||||
'type' => 'bind',
|
'type' => 'bind',
|
||||||
'source' => $this->volume_configuration_dir.'/mongod.conf',
|
'source' => $this->configuration_dir.'/mongod.conf',
|
||||||
'target' => '/etc/mongo/mongod.conf',
|
'target' => '/etc/mongo/mongod.conf',
|
||||||
'read_only' => true,
|
'read_only' => true,
|
||||||
]]
|
]]
|
||||||
@@ -192,7 +187,7 @@ class StartMongodb
|
|||||||
$docker_compose['services'][$container_name]['volumes'] ?? [],
|
$docker_compose['services'][$container_name]['volumes'] ?? [],
|
||||||
[[
|
[[
|
||||||
'type' => 'bind',
|
'type' => 'bind',
|
||||||
'source' => $this->volume_configuration_dir.'/docker-entrypoint-initdb.d',
|
'source' => $this->configuration_dir.'/docker-entrypoint-initdb.d',
|
||||||
'target' => '/docker-entrypoint-initdb.d',
|
'target' => '/docker-entrypoint-initdb.d',
|
||||||
'read_only' => true,
|
'read_only' => true,
|
||||||
]]
|
]]
|
||||||
@@ -259,7 +254,7 @@ class StartMongodb
|
|||||||
$this->commands[] = [
|
$this->commands[] = [
|
||||||
'transfer_file' => [
|
'transfer_file' => [
|
||||||
'content' => $docker_compose,
|
'content' => $docker_compose,
|
||||||
'destination' => "$this->volume_configuration_dir/docker-compose.yml",
|
'destination' => "$this->configuration_dir/docker-compose.yml",
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
$readme = generate_readme_file($this->database->name, now());
|
$readme = generate_readme_file($this->database->name, now());
|
||||||
|
@@ -20,8 +20,6 @@ class StartPostgresql
|
|||||||
|
|
||||||
public string $configuration_dir;
|
public string $configuration_dir;
|
||||||
|
|
||||||
public string $volume_configuration_dir;
|
|
||||||
|
|
||||||
private ?SslCertificate $ssl_certificate = null;
|
private ?SslCertificate $ssl_certificate = null;
|
||||||
|
|
||||||
public function handle(StandalonePostgresql $database)
|
public function handle(StandalonePostgresql $database)
|
||||||
@@ -29,10 +27,6 @@ class StartPostgresql
|
|||||||
$this->database = $database;
|
$this->database = $database;
|
||||||
$container_name = $this->database->uuid;
|
$container_name = $this->database->uuid;
|
||||||
$this->configuration_dir = database_configuration_dir().'/'.$container_name;
|
$this->configuration_dir = database_configuration_dir().'/'.$container_name;
|
||||||
$this->volume_configuration_dir = $this->configuration_dir;
|
|
||||||
if (isDev()) {
|
|
||||||
$this->volume_configuration_dir = '/var/lib/docker/volumes/coolify_dev_coolify_data/_data/databases/'.$container_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->commands = [
|
$this->commands = [
|
||||||
"echo 'Starting database.'",
|
"echo 'Starting database.'",
|
||||||
@@ -195,7 +189,7 @@ class StartPostgresql
|
|||||||
$docker_compose['services'][$container_name]['volumes'],
|
$docker_compose['services'][$container_name]['volumes'],
|
||||||
[[
|
[[
|
||||||
'type' => 'bind',
|
'type' => 'bind',
|
||||||
'source' => $this->volume_configuration_dir.'/custom-postgres.conf',
|
'source' => $this->configuration_dir.'/custom-postgres.conf',
|
||||||
'target' => '/etc/postgresql/postgresql.conf',
|
'target' => '/etc/postgresql/postgresql.conf',
|
||||||
'read_only' => true,
|
'read_only' => true,
|
||||||
]]
|
]]
|
||||||
@@ -223,7 +217,7 @@ class StartPostgresql
|
|||||||
$this->commands[] = [
|
$this->commands[] = [
|
||||||
'transfer_file' => [
|
'transfer_file' => [
|
||||||
'content' => $docker_compose,
|
'content' => $docker_compose,
|
||||||
'destination' => "$this->volume_configuration_dir/docker-compose.yml",
|
'destination' => "$this->configuration_dir/docker-compose.yml",
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
$readme = generate_readme_file($this->database->name, now());
|
$readme = generate_readme_file($this->database->name, now());
|
||||||
@@ -236,6 +230,8 @@ class StartPostgresql
|
|||||||
}
|
}
|
||||||
$this->commands[] = "echo 'Database started.'";
|
$this->commands[] = "echo 'Database started.'";
|
||||||
|
|
||||||
|
ray($this->commands);
|
||||||
|
|
||||||
return remote_process($this->commands, $database->destination->server, callEventOnFinish: 'DatabaseStatusChanged');
|
return remote_process($this->commands, $database->destination->server, callEventOnFinish: 'DatabaseStatusChanged');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user