From c9e5e6e22b26f86a77fa3c4e85099e306494b1b3 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 9 Jan 2023 17:32:14 +0100 Subject: [PATCH] cli: adjust container names --- cli.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cli.php b/cli.php index 91bc119..0a29fa7 100644 --- a/cli.php +++ b/cli.php @@ -42,7 +42,9 @@ if (!$context->isCLI()) { $database = $context->getConfig()->getDatabase(); if ($database !== null && $database->getProperty("isDocker", false) && !is_file("/.dockerenv")) { if (count($argv) < 3 || $argv[1] !== "db" || !in_array($argv[2], ["shell", "import", "export"])) { - $command = array_merge(["docker", "exec", "-it", "php", "php"], $argv); + $dockerYaml = yaml_parse(file_get_contents("./docker-compose.yml")); + $containerName = $dockerYaml["services"]["php"]["container_name"]; + $command = array_merge(["docker", "exec", "-it", $containerName, "php"], $argv); $proc = proc_open($command, [1 => STDOUT, 2 => STDERR], $pipes, "/application"); exit(proc_close($proc)); } @@ -172,7 +174,9 @@ function handleDatabase(array $argv) { $command = array_merge([$command_bin], $command_args); if ($config->getProperty("isDocker", false)) { - $command = array_merge(["docker", "exec", "-it", $config->getHost()], $command); + $dockerYaml = yaml_parse(file_get_contents("./docker-compose.yml")); + $containerName = $dockerYaml["services"]["db"]["container_name"]; + $command = array_merge(["docker", "exec", "-it", $containerName], $command); } $process = proc_open($command, $descriptorSpec, $pipes, null, $env);