diff --git a/.env b/.env index 8aa4e80ccb..df725cc8df 100644 --- a/.env +++ b/.env @@ -36,6 +36,9 @@ _APP_CONSOLE_COUNTRIES_DENYLIST=AQ _APP_CONSOLE_WHITELIST_EMAILS= _APP_CONSOLE_WHITELIST_IPS= _APP_CONSOLE_WHITELIST_ROOT=disabled +# MariaDB and MongoDB only start when their profile is listed here; PostgreSQL always +# runs because VectorsDB requires it. MongoDB is on by default for DocumentsDB. +COMPOSE_PROFILES=mongodb _APP_DB_ADAPTER=postgresql _APP_DB_HOST=postgresql _APP_DB_PORT=5432 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a3949e832f..d8b6be61b9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -196,7 +196,7 @@ jobs: { name: 'Account', runner: runner4, functional: true, processes: null }, { name: 'Avatars', runner: runner4, functional: true, processes: null }, { name: 'Console', runner: runner4, functional: true, processes: null }, - { name: 'Databases', runner: runner8, functional: false, processes: 3 }, + { name: 'Databases', runner: runner8, functional: false, processes: 3, documentsdb: true }, { name: 'TablesDB', runner: runner8, functional: false, processes: 3 }, { name: 'Functions', runner: runner4, functional: false, processes: null }, { name: 'FunctionsSchedule', runner: runner4, functional: true, processes: null }, @@ -204,8 +204,8 @@ jobs: { name: 'Health', runner: runner4, functional: true, processes: null }, { name: 'Advisor', runner: runner4, functional: true, processes: null }, { name: 'Locale', runner: runner4, functional: true, processes: null }, - { name: 'Projects', runner: runner4, functional: true, processes: null }, - { name: 'Realtime', runner: runner4, functional: false, processes: null }, + { name: 'Projects', runner: runner4, functional: true, processes: null, documentsdb: true }, + { name: 'Realtime', runner: runner4, functional: false, processes: null, documentsdb: true }, { name: 'Sites', runner: runner4, functional: true, processes: null }, { name: 'Proxy', runner: runner4, functional: true, processes: null }, { name: 'Storage', runner: runner4, functional: true, processes: null }, @@ -218,7 +218,7 @@ jobs: { name: 'VCSGitea', runner: runner4, functional: false, processes: null }, { name: 'Messaging', runner: runner4, functional: true, processes: null }, { name: 'Notifications', runner: runner4, functional: true, processes: null }, - { name: 'Migrations', runner: runner4, functional: true, processes: 1 }, + { name: 'Migrations', runner: runner4, functional: true, processes: 1, documentsdb: true }, { name: 'Project', runner: runner4, functional: true, processes: null }, { name: 'Presences', runner: runner4, functional: true, processes: null }, ]; @@ -298,6 +298,8 @@ jobs: permissions: contents: read packages: read + env: + COMPOSE_PROFILES: '' steps: - name: checkout uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 @@ -354,6 +356,8 @@ jobs: permissions: contents: read packages: read + env: + COMPOSE_PROFILES: '' steps: - name: checkout uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 @@ -452,6 +456,13 @@ jobs: echo "_APP_DB_PORT=5432" >> $GITHUB_ENV fi + # DocumentsDB is MongoDB-only, so Mongo runs alongside another primary just for + # the suites that use it, and in shared tables mode where boot connects every pool. + if [ "${{ matrix.database }}" != "MongoDB" ] \ + && { [ "${{ matrix.service.documentsdb }}" = "true" ] || [ "${{ matrix.mode }}" = "shared" ]; }; then + COMPOSE_PROFILES="${COMPOSE_PROFILES},mongodb" + fi + # Gitea runs alongside Appwrite only where VCS tests need it. if [ "${{ matrix.service.name }}" = "VCSGitea" ]; then COMPOSE_PROFILES="${COMPOSE_PROFILES},gitea" @@ -580,7 +591,8 @@ jobs: compose_profiles: antivirus wait: clamav env: - COMPOSE_PROFILES: ${{ matrix.config.compose_profiles }} + # Shared tables mode connects every pool at boot, including the MongoDB-only DocumentsDB. + COMPOSE_PROFILES: ${{ matrix.mode == 'shared' && format('mongodb,{0}', matrix.config.compose_profiles) || matrix.config.compose_profiles }} steps: - name: Checkout repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 @@ -692,6 +704,11 @@ jobs: issues: write pull-requests: write packages: read + env: + # The before stack is a worktree at an arbitrary older SHA, so its compose file + # may not gate databases at all. Start the superset on both sides, otherwise the + # two runs measure different amounts of idle container load rather than the diff. + COMPOSE_PROFILES: mariadb,mongodb steps: - name: Checkout repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 5049c71a7a..25719a7096 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -400,10 +400,11 @@ services: - gateway environment: - ADMINER_DESIGN=pepa-linha - - ADMINER_DEFAULT_SERVER=mariadb - - ADMINER_DEFAULT_USERNAME=root - - ADMINER_DEFAULT_PASSWORD=rootsecretpassword - - ADMINER_DEFAULT_DB=appwrite + - ADMINER_DEFAULT_SERVER=${_APP_DB_HOST:-postgresql} + - ADMINER_DEFAULT_DRIVER=${_APP_DB_ADAPTER:-postgresql} + - ADMINER_DEFAULT_USERNAME=${_APP_DB_USER} + - ADMINER_DEFAULT_PASSWORD=${_APP_DB_PASS} + - ADMINER_DEFAULT_DB=${_APP_DB_SCHEMA} configs: - source: adminer-index.php target: /var/www/html/index.php @@ -484,9 +485,13 @@ services: aliases: - appwrite.test mariadb: + profiles: + - mariadb ports: - "9510:3306" mongodb: + profiles: + - mongodb ports: - "9511:27017" postgresql: @@ -552,7 +557,8 @@ configs: if(!count($$_GET)) { $$_POST['auth'] = [ 'server' => $$_ENV['ADMINER_DEFAULT_SERVER'], - 'driver' => 'server', /* seems to autodetect the driver from server settings */ + /* Adminer calls the MySQL/MariaDB driver "server". */ + 'driver' => $$_ENV['ADMINER_DEFAULT_DRIVER'] === 'postgresql' ? 'pgsql' : 'server', 'username' => $$_ENV['ADMINER_DEFAULT_USERNAME'], 'password' => $$_ENV['ADMINER_DEFAULT_PASSWORD'], 'db' => $$_ENV['ADMINER_DEFAULT_DB'], diff --git a/docker-compose.yml b/docker-compose.yml index 55dc9b0c0e..e78d013fcc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -751,7 +751,7 @@ services: - appwrite depends_on: - redis - - ${_APP_DB_HOST:-mariadb} + - ${_APP_DB_HOST:-postgresql} environment: - _APP_ENV - _APP_WORKERS_NUM=1 @@ -796,7 +796,7 @@ services: - appwrite depends_on: - redis - - ${_APP_DB_HOST:-mariadb} + - ${_APP_DB_HOST:-postgresql} environment: - _APP_ENV - _APP_WORKER_PER_CORE diff --git a/src/Appwrite/Docker/Compose/Generator.php b/src/Appwrite/Docker/Compose/Generator.php index 2baed3f2f6..1f53ea42f1 100644 --- a/src/Appwrite/Docker/Compose/Generator.php +++ b/src/Appwrite/Docker/Compose/Generator.php @@ -56,8 +56,6 @@ class Generator ], 'placeholders' => [ '${_APP_DB_HOST:-postgresql}', - '${_APP_DB_HOST:-mongodb}', - '${_APP_DB_HOST:-mariadb}', ], ], ];