From 083e490cc20759f7d33c04d167d91d455ad0a811 Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Fri, 16 May 2025 16:19:20 +0530 Subject: [PATCH] updated compose file and installation script --- .env | 2 +- app/views/install/compose.phtml | 48 ++++++++++++------------- src/Appwrite/Platform/Tasks/Install.php | 44 ++++++++++------------- 3 files changed, 43 insertions(+), 51 deletions(-) diff --git a/.env b/.env index 35ad688f4a..e79f745ddc 100644 --- a/.env +++ b/.env @@ -29,7 +29,7 @@ _APP_REDIS_HOST=redis _APP_REDIS_PORT=6379 _APP_REDIS_PASS= _APP_REDIS_USER= -_APP_DB_SCHEME=postgresql +_APP_DB_SCHEME=mariadb _APP_DB_HOST=mariadb _APP_DB_PORT=3306 _APP_DB_SCHEMA=appwrite diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index 88cffdcc8b..bf27311df5 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -11,6 +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'; ?>services: traefik: image: traefik:2.11 @@ -67,11 +68,7 @@ $image = $this->getParam('image', ''); - appwrite-functions:/storage/functions:rw depends_on: - redis - getParam('_APP_DB_SCHEME', 'mariadb') === 'mariadb'): ?> - - mariadb - - - postgres - + - # - clamav environment: - _APP_ENV @@ -217,7 +214,7 @@ $image = $this->getParam('image', ''); - appwrite depends_on: - redis - - mariadb + - environment: - _APP_ENV - _APP_WORKER_PER_CORE @@ -246,7 +243,7 @@ $image = $this->getParam('image', ''); - appwrite depends_on: - redis - - mariadb + - environment: - _APP_ENV - _APP_WORKER_PER_CORE @@ -272,7 +269,7 @@ $image = $this->getParam('image', ''); - appwrite depends_on: - redis - - mariadb + - environment: - _APP_ENV - _APP_WORKER_PER_CORE @@ -300,7 +297,7 @@ $image = $this->getParam('image', ''); - appwrite depends_on: - redis - - mariadb + - volumes: - appwrite-uploads:/storage/uploads:rw - appwrite-cache:/storage/cache:rw @@ -362,7 +359,7 @@ $image = $this->getParam('image', ''); - appwrite depends_on: - redis - - mariadb + - environment: - _APP_ENV - _APP_WORKER_PER_CORE @@ -388,7 +385,7 @@ $image = $this->getParam('image', ''); - appwrite depends_on: - redis - - mariadb + - volumes: - appwrite-functions:/storage/functions:rw - appwrite-builds:/storage/builds:rw @@ -452,7 +449,7 @@ $image = $this->getParam('image', ''); - appwrite depends_on: - redis - - mariadb + - volumes: - appwrite-config:/storage/config:rw - appwrite-certificates:/storage/certificates:rw @@ -485,7 +482,7 @@ $image = $this->getParam('image', ''); - appwrite depends_on: - redis - - mariadb + - - openruntimes-executor environment: - _APP_ENV @@ -523,6 +520,7 @@ $image = $this->getParam('image', ''); - appwrite depends_on: - redis + - environment: - _APP_ENV - _APP_WORKER_PER_CORE @@ -559,6 +557,7 @@ $image = $this->getParam('image', ''); - appwrite-uploads:/storage/uploads:rw depends_on: - redis + - environment: - _APP_ENV - _APP_WORKER_PER_CORE @@ -607,7 +606,7 @@ $image = $this->getParam('image', ''); networks: - appwrite depends_on: - - mariadb + - environment: - _APP_ENV - _APP_WORKER_PER_CORE @@ -638,6 +637,7 @@ $image = $this->getParam('image', ''); - appwrite depends_on: - redis + - environment: - _APP_ENV - _APP_WORKER_PER_CORE @@ -675,7 +675,7 @@ $image = $this->getParam('image', ''); - ./src:/usr/src/code/src depends_on: - redis - - mariadb + - environment: - _APP_ENV - _APP_WORKER_PER_CORE @@ -704,7 +704,7 @@ $image = $this->getParam('image', ''); - appwrite depends_on: - redis - - mariadb + - environment: - _APP_ENV - _APP_WORKER_PER_CORE @@ -732,7 +732,7 @@ $image = $this->getParam('image', ''); - appwrite depends_on: - redis - - mariadb + - environment: - _APP_ENV - _APP_WORKER_PER_CORE @@ -759,7 +759,7 @@ $image = $this->getParam('image', ''); networks: - appwrite depends_on: - - mariadb + - - redis environment: - _APP_ENV @@ -784,7 +784,7 @@ $image = $this->getParam('image', ''); networks: - appwrite depends_on: - - mariadb + - - redis environment: - _APP_ENV @@ -809,7 +809,7 @@ $image = $this->getParam('image', ''); networks: - appwrite depends_on: - - mariadb + - - redis environment: - _APP_ENV @@ -902,15 +902,15 @@ $image = $this->getParam('image', ''); - MARIADB_AUTO_UPGRADE=1 command: 'mysqld --innodb-flush-method=fsync' - postgres: + postgresql: image: postgres:15-alpine - container_name: appwrite-postgres + container_name: appwrite-postgresql <<: *x-logging restart: unless-stopped networks: - appwrite volumes: - - appwrite-postgres:/var/lib/postgresql/data:rw + - appwrite-postgresql:/var/lib/postgresql/data:rw environment: - POSTGRES_DB=${_APP_DB_SCHEMA} - POSTGRES_USER=${_APP_DB_USER} @@ -957,4 +957,4 @@ volumes: appwrite-functions: appwrite-builds: appwrite-config: - appwrite-postgres: + appwrite-postgresql: diff --git a/src/Appwrite/Platform/Tasks/Install.php b/src/Appwrite/Platform/Tasks/Install.php index c157374893..bc1ee40362 100644 --- a/src/Appwrite/Platform/Tasks/Install.php +++ b/src/Appwrite/Platform/Tasks/Install.php @@ -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', 'mariadb', new Text(0), 'Database to use (mariadb|postgresql)', true) + ->param('database', '', 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)); } @@ -45,7 +45,7 @@ class Install extends Action $vars['_APP_DB_SCHEME'] = [ 'name' => '_APP_DB_SCHEME', 'default' => $database, - 'required' => false, + 'required' => true, 'filter' => '', 'overwrite' => true, 'question' => 'Choose your database (mariadb|postgresql)', @@ -59,13 +59,6 @@ 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'); @@ -146,6 +139,18 @@ 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 . ')'); $httpPort = ($httpPort) ? $httpPort : $defaultHTTPPort; @@ -180,19 +185,6 @@ class Install extends Action continue; } - if ($var['name'] === '_APP_DB_SCHEME') { - $input[$var['name']] = Console::confirm('Choose your database (mariadb|postgresql): (default: ' . $var['default'] . ')'); - if (empty($input[$var['name']])) { - $input[$var['name']] = $var['default']; - } - if (!in_array($input[$var['name']], ['mariadb', 'postgresql'])) { - Console::error('Invalid database choice. Please choose either mariadb or postgresql.'); - Console::exit(1); - } - $database = $input[$var['name']]; - continue; - } - $input[$var['name']] = Console::confirm($var['question'] . ' (default: \'' . $var['default'] . '\')'); if (empty($input[$var['name']])) { @@ -209,18 +201,18 @@ class Install extends Action } } } + $database = $input['_APP_DB_SCHEME']; $templateForCompose = new View(__DIR__ . '/../../../../app/views/install/compose.phtml'); $templateForEnv = new View(__DIR__ . '/../../../../app/views/install/env.phtml'); - $templateForCompose ->setParam('httpPort', $httpPort) ->setParam('httpsPort', $httpsPort) ->setParam('version', APP_VERSION_STABLE) ->setParam('organization', $organization) ->setParam('image', $image) - ->setParam('database',$database); - $input['_APP_DB_SCHEME'] = $database; + ->setParam('database', $database); + $templateForEnv->setParam('vars', $input); if (!file_put_contents($this->path . '/docker-compose.yml', $templateForCompose->render(false))) { @@ -261,4 +253,4 @@ class Install extends Action Console::success($message); } } -} +} \ No newline at end of file