From 78de031c74f2f0972ec9e4e3d9f534099eba090a Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Fri, 16 May 2025 21:07:47 +0530 Subject: [PATCH] added changes --- app/config/variables.php | 9 +++++++++ app/init/registers.php | 3 +-- app/views/install/compose.phtml | 18 +++++++++++++----- src/Appwrite/Platform/Tasks/Install.php | 9 ++++++++- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/app/config/variables.php b/app/config/variables.php index f79d4cb517..8afef87c46 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -294,6 +294,15 @@ return [ 'required' => false, 'question' => '', 'filter' => '' + ], + [ + 'name' => '_APP_DB_SCHEME', + 'description' => 'To switch between mariadb and postgresql', + 'introduction' => '1.6.0', + 'default' => 'mariadb', + 'required' => true, + 'question' => 'Choose your database (mariadb|postgresql)', + 'filter' => '' ] ], ], diff --git a/app/init/registers.php b/app/init/registers.php index a7632888c8..8c293628e3 100644 --- a/app/init/registers.php +++ b/app/init/registers.php @@ -99,10 +99,9 @@ $register->set('logger', function () { $register->set('pools', function () { $group = new Group(); - $dbScheme = System::getEnv('_APP_DB_SCHEME', 'mariadb'); $fallbackForDB = 'db_main=' . AppwriteURL::unparse([ - 'scheme' => $dbScheme, + 'scheme' => System::getEnv('_APP_DB_SCHEME', 'mariadb'), 'host' => System::getEnv('_APP_DB_HOST', 'mariadb'), 'port' => System::getEnv('_APP_DB_PORT', '3306'), 'user' => System::getEnv('_APP_DB_USER', ''), diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index bf27311df5..e8af80df3f 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -11,7 +11,7 @@ $httpsPort = $this->getParam('httpsPort', ''); $version = $this->getParam('version', ''); $organization = $this->getParam('organization', ''); $image = $this->getParam('image', ''); -$dbService = $this->getParam('database', 'mariadb') === 'mariadb' ? 'mariadb' : 'postgresql'; +$dbService = $this->getParam('database'); ?>services: traefik: image: traefik:2.11 @@ -885,10 +885,12 @@ $dbService = $this->getParam('database', 'mariadb') === 'mariadb' ? 'mariadb' : - OPR_EXECUTOR_STORAGE_WASABI_REGION=$_APP_STORAGE_WASABI_REGION - OPR_EXECUTOR_STORAGE_WASABI_BUCKET=$_APP_STORAGE_WASABI_BUCKET + + + mariadb: - image: mariadb:10.11 # fix issues when upgrading using: mysql_upgrade -u root -p + image: mariadb:10.11 container_name: appwrite-mariadb - <<: *x-logging restart: unless-stopped networks: - appwrite @@ -902,10 +904,11 @@ $dbService = $this->getParam('database', 'mariadb') === 'mariadb' ? 'mariadb' : - MARIADB_AUTO_UPGRADE=1 command: 'mysqld --innodb-flush-method=fsync' + + postgresql: image: postgres:15-alpine container_name: appwrite-postgresql - <<: *x-logging restart: unless-stopped networks: - appwrite @@ -916,6 +919,8 @@ $dbService = $this->getParam('database', 'mariadb') === 'mariadb' ? 'mariadb' : - POSTGRES_USER=${_APP_DB_USER} - POSTGRES_PASSWORD=${_APP_DB_PASS} + + redis: image: redis:7.2.4-alpine container_name: appwrite-redis @@ -949,7 +954,11 @@ networks: name: runtimes volumes: + appwrite-mariadb: + + appwrite-postgresql: + appwrite-redis: appwrite-cache: appwrite-uploads: @@ -957,4 +966,3 @@ volumes: appwrite-functions: appwrite-builds: appwrite-config: - appwrite-postgresql: diff --git a/src/Appwrite/Platform/Tasks/Install.php b/src/Appwrite/Platform/Tasks/Install.php index d18f6b7c88..7d13973003 100644 --- a/src/Appwrite/Platform/Tasks/Install.php +++ b/src/Appwrite/Platform/Tasks/Install.php @@ -32,7 +32,7 @@ class Install extends Action ->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', '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)); + ->callback($this->action(...)); } public function action(string $httpPort, string $httpsPort, string $organization, string $image, string $interactive, bool $noStart, string $database): void @@ -59,6 +59,13 @@ class Install extends Action Console::success('Starting Appwrite installation...'); + // Create directory with write permissions + if (!\file_exists(\dirname($this->path))) { + if (!@\mkdir(\dirname($this->path), 0755, true)) { + Console::error('Can\'t create directory ' . \dirname($this->path)); + Console::exit(1); + } + } $data = @file_get_contents($this->path . '/docker-compose.yml');