added conditonal for .env for mariadb and psotgres

This commit is contained in:
ArnabChatterjee20k
2025-05-16 17:01:18 +05:30
parent f846e417fc
commit 5f7afa25ce
+8 -12
View File
@@ -31,7 +31,7 @@ class Install extends Action
->param('image', 'appwrite', new Text(0), 'Main appwrite docker image', true)
->param('interactive', 'Y', new Text(1), 'Run an interactive session', true)
->param('no-start', false, new Boolean(true), 'Run an interactive session', true)
->param('database', '', new Text(0), 'Database to use (mariadb|postgresql)', true)
->param('database', 'mariadb', new Text(0), 'Database to use (mariadb|postgresql)', true)
->callback(fn ($httpPort, $httpsPort, $organization, $image, $interactive, $noStart, $database) => $this->action($httpPort, $httpsPort, $organization, $image, $interactive, $noStart, $database));
}
@@ -139,17 +139,6 @@ class Install extends Action
}
}
// if ($interactive == 'Y' && Console::isInteractive()) {
// $dbChoice = Console::confirm('Choose your database (mariadb|postgresql): (default: ' . $database . ')');
// if (!empty($dbChoice)) {
// $database = $dbChoice;
// if (!in_array($database, ['mariadb', 'postgresql'])) {
// Console::error('Invalid database choice. Please choose either mariadb or postgresql.');
// Console::exit(1);
// }
// }
// $vars['_APP_DB_SCHEME']['default'] = $database;
// }
if (empty($httpPort)) {
$httpPort = Console::confirm('Choose your server HTTP port: (default: ' . $defaultHTTPPort . ')');
@@ -202,6 +191,13 @@ class Install extends Action
}
}
$database = $input['_APP_DB_SCHEME'];
if ($database === 'postgresql') {
$input['_APP_DB_HOST'] = 'postgresql';
$input['_APP_DB_PORT'] = 5432;
} elseif ($database === 'mariadb') {
$input['_APP_DB_HOST'] = 'mariadb';
$input['_APP_DB_PORT'] = 3306;
}
$templateForCompose = new View(__DIR__ . '/../../../../app/views/install/compose.phtml');
$templateForEnv = new View(__DIR__ . '/../../../../app/views/install/env.phtml');