Skip to content
Snippets Groups Projects
Commit f4e30eee authored by Murtaza Sultani's avatar Murtaza Sultani Committed by Jan-Hendrik Willms
Browse files

Add db:port command

parent 15ba0a7e
No related branches found
No related tags found
1 merge request!4Add db:port command
......@@ -164,10 +164,12 @@ final class Compile extends Command
]);
// DB
$dbExposingPort = (int) (Config::getInstance()->get('db')['port'] ?? 3306);
$creator->addService('db', 'mariadb', [
'container_name' => 'db',
'command' => '--sql_mode="NO_ENGINE_SUBSTITUTION"',
'ports' => ['3306:3306'],
'ports' => [$dbExposingPort . ':3306'],
'restart' => 'unless-stopped',
'volumes' => ['db-data:/var/lib/mysql'],
'environment' => [
......
<?php
namespace Studip\Dockerized\Commands\DB;
use Studip\Dockerized\Config;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
final class Port extends Command
{
protected function configure()
{
$this->setName('db:port');
$this->setDescription('Change exposing port for Database (needs recompile)');
$this->addArgument(
'port',
InputArgument::REQUIRED,
'Port to use'
);
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$port = (int) $input->getArgument('port');
$config = Config::getInstance();
$io = new SymfonyStyle($input, $output);
$dbPort = $config->get('db');
$dbPort['port'] = $port;
$config->set('db', $dbPort);
$config->store();
$io->success("Exposing ports of DB were changed to {$port}");
return Command::SUCCESS;
}
}
......@@ -30,6 +30,8 @@ if (file_exists(CONFIG_FILE)) {
$application->add(new Commands\Docker\Stop());
$application->add(new Commands\Keys\Create());
$application->add(new Commands\DB\Port());
}
$application->run();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment