feat(database): configure standalone health checks

Add configurable health check settings for standalone databases and apply them to generated Docker Compose services. Allow disabling health checks and cover the behavior with feature tests.
This commit is contained in:
Andras Bacsai committed 2026-05-31 21:50:10 +02:00
1 parent c9fcc0bc44
commit d423223d38
26 files changed
+448 -42

No files matched your search

+7 -4
View File
@@ -112,10 +112,10 @@ class StartPostgresql
'labels' => defaultDatabaseLabels($this->database)->toArray(),
'healthcheck' => [
'test' => ['CMD', 'psql', '-U', (string) $this->database->postgres_user, '-d', (string) $this->database->postgres_db, '-c', 'SELECT 1'],
'interval' => '5s',
'timeout' => '5s',
'retries' => 10,
'start_period' => '5s',
'interval' => "{$this->database->health_check_interval}s",
'timeout' => "{$this->database->health_check_timeout}s",
'retries' => $this->database->health_check_retries,
'start_period' => "{$this->database->health_check_start_period}s",
],
'mem_limit' => $this->database->limits_memory,
'memswap_limit' => $this->database->limits_memory_swap,
@@ -213,6 +213,9 @@ class StartPostgresql
$docker_compose['services'][$container_name]['command'] = $command;
}
if (! $this->database->isHealthcheckEnabled()) {
unset($docker_compose['services'][$container_name]['healthcheck']);
}
$docker_compose = Yaml::dump($docker_compose, 10);
$docker_compose_base64 = base64_encode($docker_compose);
$this->commands[] = "echo '{$docker_compose_base64}' | base64 -d | tee $this->configuration_dir/docker-compose.yml > /dev/null";