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.

change db proxy to use volume mount for config (#5981)

Darren Sissonb70a9a6d47a8
diff --git a/app/Actions/Database/StartDatabaseProxy.php b/app/Actions/Database/StartDatabaseProxy.php
index c4a40f020c..744bbaa50c 100644
--- a/app/Actions/Database/StartDatabaseProxy.php
+++ b/app/Actions/Database/StartDatabaseProxy.php
@@ -44,6 +44,9 @@ class StartDatabaseProxy
};
$configuration_dir = database_proxy_dir($database->uuid);
+ if (isDev()) {
+ $configuration_dir = '/var/lib/docker/volumes/coolify_dev_coolify_data/_data/databases/'.$database->uuid.'/proxy';
+ }
$nginxconf = <<<EOF
user nginx;
worker_processes auto;
@@ -59,19 +62,10 @@ class StartDatabaseProxy
proxy_pass $containerName:$internalPort;
}
}
- EOF;
- $dockerfile = <<< 'EOF'
- FROM nginx:stable-alpine
-
- COPY nginx.conf /etc/nginx/nginx.conf
EOF;
$docker_compose = [
'services' => [
$proxyContainerName => [
- 'build' => [
- 'context' => $configuration_dir,
- 'dockerfile' => 'Dockerfile',
- ],
'image' => 'nginx:stable-alpine',
'container_name' => $proxyContainerName,
'restart' => RESTART_MODE,
@@ -81,6 +75,13 @@ class StartDatabaseProxy
'networks' => [
$network,
],
+ 'volumes' => [
+ [
+ 'type' => 'bind',
+ 'source' => "$configuration_dir/nginx.conf",
+ 'target' => '/etc/nginx/nginx.conf',
+ ],
+ ],
'healthcheck' => [
'test' => [
'CMD-SHELL',
@@ -103,15 +104,13 @@ class StartDatabaseProxy
];
$dockercompose_base64 = base64_encode(Yaml::dump($docker_compose, 4, 2));
$nginxconf_base64 = base64_encode($nginxconf);
- $dockerfile_base64 = base64_encode($dockerfile);
instant_remote_process(["docker rm -f $proxyContainerName"], $server, false);
instant_remote_process([
"mkdir -p $configuration_dir",
- "echo '{$dockerfile_base64}' | base64 -d | tee $configuration_dir/Dockerfile > /dev/null",
"echo '{$nginxconf_base64}' | base64 -d | tee $configuration_dir/nginx.conf > /dev/null",
"echo '{$dockercompose_base64}' | base64 -d | tee $configuration_dir/docker-compose.yaml > /dev/null",
"docker compose --project-directory {$configuration_dir} pull",
- "docker compose --project-directory {$configuration_dir} up --build -d",
+ "docker compose --project-directory {$configuration_dir} up -d",
], $server);
}
}