Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

refactor(database): remove volume_configuration_dir and streamline configuration directory usage in MongoDB and PostgreSQL handlers

Andras Bacsai1c08d32b858d
diff --git a/app/Actions/Database/StartMongodb.php b/app/Actions/Database/StartMongodb.php
index 0372cd64f5..7135f1c704 100644
--- a/app/Actions/Database/StartMongodb.php
+++ b/app/Actions/Database/StartMongodb.php
@@ -18,8 +18,6 @@ class StartMongodb
public string $configuration_dir;
- public string $volume_configuration_dir;
-
private ?SslCertificate $ssl_certificate = null;
public function handle(StandaloneMongodb $database)
@@ -29,10 +27,7 @@ class StartMongodb
$startCommand = 'mongod';
$container_name = $this->database->uuid;
- $this->volume_configuration_dir = $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->configuration_dir = database_configuration_dir().'/'.$container_name;
$this->commands = [
"echo 'Starting database.'",
@@ -178,7 +173,7 @@ class StartMongodb
$docker_compose['services'][$container_name]['volumes'] ?? [],
[[
'type' => 'bind',
- 'source' => $this->volume_configuration_dir.'/mongod.conf',
+ 'source' => $this->configuration_dir.'/mongod.conf',
'target' => '/etc/mongo/mongod.conf',
'read_only' => true,
]]
@@ -192,7 +187,7 @@ class StartMongodb
$docker_compose['services'][$container_name]['volumes'] ?? [],
[[
'type' => 'bind',
- 'source' => $this->volume_configuration_dir.'/docker-entrypoint-initdb.d',
+ 'source' => $this->configuration_dir.'/docker-entrypoint-initdb.d',
'target' => '/docker-entrypoint-initdb.d',
'read_only' => true,
]]
@@ -259,7 +254,7 @@ class StartMongodb
$this->commands[] = [
'transfer_file' => [
'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());
diff --git a/app/Actions/Database/StartPostgresql.php b/app/Actions/Database/StartPostgresql.php
index 80860bda23..75ca8ef10b 100644
--- a/app/Actions/Database/StartPostgresql.php
+++ b/app/Actions/Database/StartPostgresql.php
@@ -20,8 +20,6 @@ class StartPostgresql
public string $configuration_dir;
- public string $volume_configuration_dir;
-
private ?SslCertificate $ssl_certificate = null;
public function handle(StandalonePostgresql $database)
@@ -29,10 +27,6 @@ class StartPostgresql
$this->database = $database;
$container_name = $this->database->uuid;
$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 = [
"echo 'Starting database.'",
@@ -195,7 +189,7 @@ class StartPostgresql
$docker_compose['services'][$container_name]['volumes'],
[[
'type' => 'bind',
- 'source' => $this->volume_configuration_dir.'/custom-postgres.conf',
+ 'source' => $this->configuration_dir.'/custom-postgres.conf',
'target' => '/etc/postgresql/postgresql.conf',
'read_only' => true,
]]
@@ -223,7 +217,7 @@ class StartPostgresql
$this->commands[] = [
'transfer_file' => [
'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());
@@ -236,6 +230,8 @@ class StartPostgresql
}
$this->commands[] = "echo 'Database started.'";
+ ray($this->commands);
+
return remote_process($this->commands, $database->destination->server, callEventOnFinish: 'DatabaseStatusChanged');
}