diff --git a/.env b/.env index cca7c460e7..3f02fc83c2 100644 --- a/.env +++ b/.env @@ -23,8 +23,8 @@ _APP_DB_SCHEMA=appwrite _APP_DB_USER=user _APP_DB_PASS=password _APP_DB_ROOT_PASS=rootsecretpassword -_APP_CONNECTIONS_DB_PROJECT=db_fra1_02=mysql://user:password@mariadb:3306/appwrite -_APP_CONNECTIONS_DB_CONSOLE=db_fra1_01=mysql://user:password@mariadb:3306/appwrite +_APP_CONNECTIONS_DB_PROJECT=db_fra1_02=mariadb://user:password@mariadb:3306/appwrite +_APP_CONNECTIONS_DB_CONSOLE=db_fra1_01=mariadb://user:password@mariadb:3306/appwrite _APP_CONNECTIONS_CACHE=redis_fra1_01=redis://redis:6379 _APP_CONNECTIONS_QUEUE=redis_fra1_01=redis://redis:6379 _APP_CONNECTIONS_PUBSUB=redis_fra1_01=redis://redis:6379 diff --git a/Dockerfile b/Dockerfile index f1997160d9..3d06bd1333 100755 --- a/Dockerfile +++ b/Dockerfile @@ -281,6 +281,7 @@ RUN \ && apk add --no-cache \ libstdc++ \ certbot \ + rsync \ brotli-dev \ yaml-dev \ imagemagick \ @@ -343,6 +344,7 @@ RUN mkdir -p /storage/uploads && \ # Executables RUN chmod +x /usr/local/bin/doctor && \ chmod +x /usr/local/bin/maintenance && \ + chmod +x /usr/local/bin/volume-sync && \ chmod +x /usr/local/bin/usage && \ chmod +x /usr/local/bin/install && \ chmod +x /usr/local/bin/migrate && \ diff --git a/app/cli.php b/app/cli.php index 248eec3353..b0ed55b52d 100644 --- a/app/cli.php +++ b/app/cli.php @@ -108,6 +108,7 @@ $cli = new CLI(); include 'tasks/doctor.php'; include 'tasks/maintenance.php'; +include 'tasks/volume-sync.php'; include 'tasks/install.php'; include 'tasks/migrate.php'; include 'tasks/sdks.php'; diff --git a/app/config/collections.php b/app/config/collections.php index 2a01acc8e5..b4fabf0e65 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -2325,7 +2325,7 @@ $collections = [ '$id' => ID::custom('entrypoint'), 'type' => Database::VAR_STRING, 'format' => '', - 'size' => 16384, + 'size' => 2048, 'signed' => true, 'required' => false, 'default' => null, @@ -2335,7 +2335,7 @@ $collections = [ '$id' => ID::custom('path'), 'type' => Database::VAR_STRING, 'format' => '', - 'size' => 16384, + 'size' => 2048, 'signed' => true, 'required' => false, 'default' => null, @@ -2907,7 +2907,7 @@ $collections = [ '$id' => 'compression', 'type' => Database::VAR_STRING, 'signed' => true, - 'size' => 128, + 'size' => 10, 'format' => '', 'filters' => [], 'required' => true, diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 8f5452d2be..2a56fe0183 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -20,7 +20,6 @@ use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\DateTime; use Utopia\Database\Query; -use Utopia\Database\Adapter\MySQL; use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Key; use Utopia\Database\Validator\Permissions; diff --git a/app/tasks/volume-sync.php b/app/tasks/volume-sync.php new file mode 100644 index 0000000000..8d5fec201b --- /dev/null +++ b/app/tasks/volume-sync.php @@ -0,0 +1,45 @@ +task('volume-sync') + ->desc('Runs rsync to sync certificates between the storage mount and traefik.') + ->param('source', null, new Text(255), 'Source path to sync from.', false) + ->param('destination', null, new Text(255), 'Destination path to sync to.', false) + ->param('interval', null, new Integer(true), 'Interval to run rsync', false) + ->action(function ($source, $destination, $interval) { + + Console::title('RSync V1'); + Console::success(APP_NAME . ' rsync process v1 has started'); + + if (!file_exists($source)) { + Console::error('Source directory does not exist. Exiting ... '); + Console::exit(0); + } + + Console::loop(function () use ($interval, $source, $destination) { + $time = DateTime::now(); + + Console::info("[{$time}] Executing rsync every {$interval} seconds"); + Console::info("Syncing between $source and $destination"); + + if (!file_exists($source)) { + Console::error('Source directory does not exist. Skipping ... '); + return; + } + + $stdin = ""; + $stdout = ""; + $stderr = ""; + + Console::execute("rsync -av $source $destination", $stdin, $stdout, $stderr); + Console::success($stdout); + Console::error($stderr); + }, $interval); + }); diff --git a/bin/volume-sync b/bin/volume-sync new file mode 100644 index 0000000000..5190750a24 --- /dev/null +++ b/bin/volume-sync @@ -0,0 +1,3 @@ +#!/bin/sh + +php /usr/src/code/app/cli.php volume-sync $@ \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index cdd76aa923..d9a7f1a897 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -645,6 +645,19 @@ services: - _APP_MAINTENANCE_RETENTION_AUDIT - _APP_MAINTENANCE_RETENTION_USAGE_HOURLY + appwrite-volume-sync: + entrypoint: volume-sync + <<: *x-logging + container_name: appwrite-volume-sync + image: appwrite-dev + command: + - --source=/data/src/ --destination=/data/dest/ --interval=10 + networks: + - appwrite + # volumes: # Mount the rsync source and destination directories + # - /nfs/config:/data/src + # - /storage/config:/data/dest + appwrite-usage: entrypoint: usage <<: *x-logging @@ -702,7 +715,7 @@ services: mariadb: image: mariadb:10.7 # fix issues when upgrading using: mysql_upgrade -u root -p - container_name: appwrite-mariadb + container_name: mariadb <<: *x-logging networks: - appwrite