diff --git a/.env b/.env index fa22be4586..7d458a58fd 100644 --- a/.env +++ b/.env @@ -32,7 +32,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 774a72537d..d3cab3285b 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 @@ -70,11 +71,7 @@ $image = $this->getParam('image', ''); - appwrite-builds:/storage/builds:rw depends_on: - redis - getParam('_APP_DB_SCHEME', 'mariadb') === 'mariadb'): ?> - - mariadb - - - postgres - + - # - clamav environment: - _APP_ENV @@ -225,7 +222,7 @@ $image = $this->getParam('image', ''); - appwrite depends_on: - redis - - mariadb + - environment: - _APP_ENV - _APP_WORKER_PER_CORE @@ -254,7 +251,7 @@ $image = $this->getParam('image', ''); - appwrite depends_on: - redis - - mariadb + - environment: - _APP_ENV - _APP_WORKER_PER_CORE @@ -280,7 +277,7 @@ $image = $this->getParam('image', ''); - appwrite depends_on: - redis - - mariadb + - environment: - _APP_ENV - _APP_WORKER_PER_CORE @@ -308,7 +305,7 @@ $image = $this->getParam('image', ''); - appwrite depends_on: - redis - - mariadb + - volumes: - appwrite-uploads:/storage/uploads:rw - appwrite-cache:/storage/cache:rw @@ -371,7 +368,7 @@ $image = $this->getParam('image', ''); - appwrite depends_on: - redis - - mariadb + - environment: - _APP_ENV - _APP_WORKER_PER_CORE @@ -397,7 +394,7 @@ $image = $this->getParam('image', ''); - appwrite depends_on: - redis - - mariadb + - volumes: - appwrite-functions:/storage/functions:rw - appwrite-sites:/storage/sites:rw @@ -465,7 +462,7 @@ $image = $this->getParam('image', ''); - appwrite depends_on: - redis - - mariadb + - volumes: - appwrite-config:/storage/config:rw - appwrite-certificates:/storage/certificates:rw @@ -500,7 +497,7 @@ $image = $this->getParam('image', ''); - appwrite depends_on: - redis - - mariadb + - - openruntimes-executor environment: - _APP_ENV @@ -539,6 +536,7 @@ $image = $this->getParam('image', ''); - appwrite depends_on: - redis + - environment: - _APP_ENV - _APP_WORKER_PER_CORE @@ -575,6 +573,7 @@ $image = $this->getParam('image', ''); - appwrite-uploads:/storage/uploads:rw depends_on: - redis + - environment: - _APP_ENV - _APP_WORKER_PER_CORE @@ -625,7 +624,7 @@ $image = $this->getParam('image', ''); volumes: - appwrite-imports:/storage/imports:rw depends_on: - - mariadb + - environment: - _APP_ENV - _APP_WORKER_PER_CORE @@ -658,6 +657,7 @@ $image = $this->getParam('image', ''); - appwrite depends_on: - redis + - environment: - _APP_ENV - _APP_WORKER_PER_CORE @@ -695,7 +695,7 @@ $image = $this->getParam('image', ''); - appwrite depends_on: - redis - - mariadb + - environment: - _APP_ENV - _APP_WORKER_PER_CORE @@ -724,7 +724,7 @@ $image = $this->getParam('image', ''); - appwrite depends_on: - redis - - mariadb + - environment: - _APP_ENV - _APP_WORKER_PER_CORE @@ -752,7 +752,7 @@ $image = $this->getParam('image', ''); - appwrite depends_on: - redis - - mariadb + - environment: - _APP_ENV - _APP_WORKER_PER_CORE @@ -779,7 +779,7 @@ $image = $this->getParam('image', ''); networks: - appwrite depends_on: - - mariadb + - - redis environment: - _APP_ENV @@ -804,7 +804,7 @@ $image = $this->getParam('image', ''); networks: - appwrite depends_on: - - mariadb + - - redis environment: - _APP_ENV @@ -829,7 +829,7 @@ $image = $this->getParam('image', ''); networks: - appwrite depends_on: - - mariadb + - - redis environment: - _APP_ENV @@ -932,15 +932,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} @@ -989,4 +989,4 @@ volumes: appwrite-sites: 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