From 46c3da70a979441152d589d0f226e95bf761832a Mon Sep 17 00:00:00 2001 From: Everly Precia Suresh Date: Fri, 18 Mar 2022 16:03:04 +0000 Subject: [PATCH 01/38] add support for linode --- CHANGES.md | 5 +++++ Dockerfile | 4 ++++ app/config/variables.php | 32 ++++++++++++++++++++++++++++++++ app/executor.php | 8 ++++++++ app/init.php | 8 ++++++++ app/views/install/compose.phtml | 12 ++++++++++++ app/workers/deletes.php | 8 ++++++++ composer.lock | 14 +++++++------- docker-compose.yml | 12 ++++++++++++ src/Appwrite/Resque/Worker.php | 8 ++++++++ 10 files changed, 104 insertions(+), 7 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 2ac2f910bc..7b09391f49 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,8 @@ +# Latest +## Features +### Storage +- Support for Linode object storage + # Version 0.13.3 ## Bugs - Fixed search for terms that inlcude `@` characters diff --git a/Dockerfile b/Dockerfile index 023e88a205..204490f4d0 100755 --- a/Dockerfile +++ b/Dockerfile @@ -162,6 +162,10 @@ ENV _APP_SERVER=swoole \ _APP_STORAGE_DO_SPACES_SECRET= \ _APP_STORAGE_DO_SPACES_REGION= \ _APP_STORAGE_DO_SPACES_BUCKET= \ + _APP_STORAGE_LINODE_ACCESS_KEY= \ + _APP_STORAGE_LINODE_SECRET= \ + _APP_STORAGE_LINODE_REGION= \ + _APP_STORAGE_LINODE_BUCKET= \ _APP_REDIS_HOST=redis \ _APP_REDIS_PORT=6379 \ _APP_DB_HOST=mariadb \ diff --git a/app/config/variables.php b/app/config/variables.php index 5cae4aa564..4d0f2ae117 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -501,6 +501,38 @@ return [ 'required' => false, 'question' => '', ], + [ + 'name' => '_APP_STORAGE_LINODE_ACCESS_KEY', + 'description' => 'Linode object storage access key. Required when the storage adapter is set to Linode. You can get your access key from your Linode console.', + 'introduction' => '0.13.0', + 'default' => '', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_STORAGE_LINODE_SECRET', + 'description' => 'Linode object storage secret key. Required when the storage adapter is set to Linode. You can get your secret key from your Linode console.', + 'introduction' => '0.13.0', + 'default' => '', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_STORAGE_LINODE_REGION', + 'description' => 'Linode object storage region. Required when storage adapter is set to Linode. You can find your region info for your space from Linode console.', + 'introduction' => '0.13.0', + 'default' => 'us-eas-1', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_STORAGE_LINODE_BUCKET', + 'description' => 'Linode object storage bucket. Required when storage adapter is set to Linode. You can create buckets in your Linode console.', + 'introduction' => '0.13.0', + 'default' => '', + 'required' => false, + 'question' => '', + ], ], ], [ diff --git a/app/executor.php b/app/executor.php index 1fa32599ab..a5a4da64cf 100644 --- a/app/executor.php +++ b/app/executor.php @@ -18,6 +18,7 @@ use Utopia\Orchestration\Orchestration; use Utopia\Storage\Device; use Utopia\Storage\Device\Local; use Utopia\Storage\Device\DOSpaces; +use Utopia\Storage\Device\Linode; use Utopia\Storage\Device\S3; use Utopia\Storage\Storage; use Utopia\Swoole\Request; @@ -129,6 +130,13 @@ function getStorageDevice($root): Device { $doSpacesBucket = App::getEnv('_APP_STORAGE_DO_SPACES_BUCKET', ''); $doSpacesAcl = 'private'; return new DOSpaces($root, $doSpacesAccessKey, $doSpacesSecretKey, $doSpacesBucket, $doSpacesRegion, $doSpacesAcl); + case Storage::DEVICE_LINODE: + $linodeAccessKey = App::getEnv('_APP_STORAGE_LINODE_ACCESS_KEY', ''); + $linodeSecretKey = App::getEnv('_APP_STORAGE_LINODE_SECRET', ''); + $linodeRegion = App::getEnv('_APP_STORAGE_LINODE_REGION', ''); + $linodeBucket = App::getEnv('_APP_STORAGE_LINODE_BUCKET', ''); + $linodeAcl = 'private'; + return new Linode($root, $linodeAccessKey, $linodeSecretKey, $linodeBucket, $linodeRegion, $linodeAcl); } } diff --git a/app/init.php b/app/init.php index 9a73a7da10..0d9c1441c8 100644 --- a/app/init.php +++ b/app/init.php @@ -55,6 +55,7 @@ use Utopia\Storage\Storage; use Utopia\Storage\Device\Local; use Utopia\Storage\Device\S3; use Utopia\Storage\Device\DOSpaces; +use Utopia\Storage\Device\Linode; const APP_NAME = 'Appwrite'; const APP_DOMAIN = 'appwrite.io'; @@ -836,6 +837,13 @@ function getDevice($root): Device { $doSpacesBucket = App::getEnv('_APP_STORAGE_DO_SPACES_BUCKET', ''); $doSpacesAcl = 'private'; return new DOSpaces($root, $doSpacesAccessKey, $doSpacesSecretKey, $doSpacesBucket, $doSpacesRegion, $doSpacesAcl); + case Storage::DEVICE_LINODE: + $linodeAccessKey = App::getEnv('_APP_STORAGE_LINODE_ACCESS_KEY', ''); + $linodeSecretKey = App::getEnv('_APP_STORAGE_LINODE_SECRET', ''); + $linodeRegion = App::getEnv('_APP_STORAGE_LINODE_REGION', ''); + $linodeBucket = App::getEnv('_APP_STORAGE_LINODE_BUCKET', ''); + $linodeAcl = 'private'; + return new Linode($root, $linodeAccessKey, $linodeSecretKey, $linodeBucket, $linodeRegion, $linodeAcl); } } diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index 22b95fd2dd..6604737bef 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -110,6 +110,10 @@ services: - _APP_STORAGE_DO_SPACES_SECRET - _APP_STORAGE_DO_SPACES_REGION - _APP_STORAGE_DO_SPACES_BUCKET + - _APP_STORAGE_LINODE_ACCESS_KEY + - _APP_STORAGE_LINODE_SECRET + - _APP_STORAGE_LINODE_REGION + - _APP_STORAGE_LINODE_BUCKET - _APP_FUNCTIONS_SIZE_LIMIT - _APP_FUNCTIONS_TIMEOUT - _APP_FUNCTIONS_BUILD_TIMEOUT @@ -202,6 +206,10 @@ services: - _APP_STORAGE_DO_SPACES_SECRET - _APP_STORAGE_DO_SPACES_REGION - _APP_STORAGE_DO_SPACES_BUCKET + - _APP_STORAGE_LINODE_ACCESS_KEY + - _APP_STORAGE_LINODE_SECRET + - _APP_STORAGE_LINODE_REGION + - _APP_STORAGE_LINODE_BUCKET - _APP_FUNCTIONS_CPUS - _APP_FUNCTIONS_MEMORY - _APP_FUNCTIONS_MEMORY_SWAP @@ -343,6 +351,10 @@ services: - _APP_STORAGE_DO_SPACES_SECRET - _APP_STORAGE_DO_SPACES_REGION - _APP_STORAGE_DO_SPACES_BUCKET + - _APP_STORAGE_LINODE_ACCESS_KEY + - _APP_STORAGE_LINODE_SECRET + - _APP_STORAGE_LINODE_REGION + - _APP_STORAGE_LINODE_BUCKET - _APP_LOGGING_PROVIDER - _APP_LOGGING_CONFIG - _APP_EXECUTOR_SECRET diff --git a/app/workers/deletes.php b/app/workers/deletes.php index 963488a00a..605c307ced 100644 --- a/app/workers/deletes.php +++ b/app/workers/deletes.php @@ -10,6 +10,7 @@ use Executor\Executor; use Utopia\Storage\Device\Local; use Utopia\Storage\Device\S3; use Utopia\Storage\Device\DOSpaces; +use Utopia\Storage\Device\Linode; use Utopia\Storage\Storage; use Utopia\Abuse\Abuse; use Utopia\Abuse\Adapters\TimeLimit; @@ -563,6 +564,13 @@ class DeletesV1 extends Worker $doSpacesAcl = 'private'; $device = new DOSpaces(APP_STORAGE_UPLOADS . '/app-' . $projectId, $doSpacesAccessKey, $doSpacesSecretKey, $doSpacesBucket, $doSpacesRegion, $doSpacesAcl); break; + case Storage::DEVICE_LINODE: + $linodeAccessKey = App::getEnv('_APP_STORAGE_LINODE_ACCESS_KEY', ''); + $linodeSecretKey = App::getEnv('_APP_STORAGE_LINODE_SECRET', ''); + $linodeRegion = App::getEnv('_APP_STORAGE_LINODE_REGION', ''); + $linodeBucket = App::getEnv('_APP_STORAGE_LINODE_BUCKET', ''); + $linodeAcl = 'private'; + return new Linode($root, $linodeAccessKey, $linodeSecretKey, $linodeBucket, $linodeRegion, $linodeAcl); } $device->deletePath($document->getId()); diff --git a/composer.lock b/composer.lock index 42df642923..8ca96a1f56 100644 --- a/composer.lock +++ b/composer.lock @@ -3192,16 +3192,16 @@ }, { "name": "composer/semver", - "version": "3.3.0", + "version": "3.3.1", "source": { "type": "git", "url": "https://github.com/composer/semver.git", - "reference": "f79c90ad4e9b41ac4dfc5d77bf398cf61fbd718b" + "reference": "5d8e574bb0e69188786b8ef77d43341222a41a71" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/f79c90ad4e9b41ac4dfc5d77bf398cf61fbd718b", - "reference": "f79c90ad4e9b41ac4dfc5d77bf398cf61fbd718b", + "url": "https://api.github.com/repos/composer/semver/zipball/5d8e574bb0e69188786b8ef77d43341222a41a71", + "reference": "5d8e574bb0e69188786b8ef77d43341222a41a71", "shasum": "" }, "require": { @@ -3253,7 +3253,7 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/semver/issues", - "source": "https://github.com/composer/semver/tree/3.3.0" + "source": "https://github.com/composer/semver/tree/3.3.1" }, "funding": [ { @@ -3269,7 +3269,7 @@ "type": "tidelift" } ], - "time": "2022-03-15T08:35:57+00:00" + "time": "2022-03-16T11:22:07+00:00" }, { "name": "composer/xdebug-handler", @@ -6580,5 +6580,5 @@ "platform-overrides": { "php": "8.0" }, - "plugin-api-version": "2.1.0" + "plugin-api-version": "2.2.0" } diff --git a/docker-compose.yml b/docker-compose.yml index ec77a2ece5..3c703e57cb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -123,6 +123,10 @@ services: - _APP_STORAGE_DO_SPACES_SECRET - _APP_STORAGE_DO_SPACES_REGION - _APP_STORAGE_DO_SPACES_BUCKET + - _APP_STORAGE_LINODE_ACCESS_KEY + - _APP_STORAGE_LINODE_SECRET + - _APP_STORAGE_LINODE_REGION + - _APP_STORAGE_LINODE_BUCKET - _APP_SMTP_HOST - _APP_SMTP_PORT - _APP_SMTP_SECURE @@ -279,6 +283,10 @@ services: - _APP_STORAGE_DO_SPACES_SECRET - _APP_STORAGE_DO_SPACES_REGION - _APP_STORAGE_DO_SPACES_BUCKET + - _APP_STORAGE_LINODE_ACCESS_KEY + - _APP_STORAGE_LINODE_SECRET + - _APP_STORAGE_LINODE_REGION + - _APP_STORAGE_LINODE_BUCKET - _APP_LOGGING_PROVIDER - _APP_LOGGING_CONFIG - _APP_EXECUTOR_SECRET @@ -446,6 +454,10 @@ services: - _APP_STORAGE_DO_SPACES_SECRET - _APP_STORAGE_DO_SPACES_REGION - _APP_STORAGE_DO_SPACES_BUCKET + - _APP_STORAGE_LINODE_ACCESS_KEY + - _APP_STORAGE_LINODE_SECRET + - _APP_STORAGE_LINODE_REGION + - _APP_STORAGE_LINODE_BUCKET - DOCKERHUB_PULL_USERNAME - DOCKERHUB_PULL_PASSWORD diff --git a/src/Appwrite/Resque/Worker.php b/src/Appwrite/Resque/Worker.php index 9682688736..6c3263c188 100644 --- a/src/Appwrite/Resque/Worker.php +++ b/src/Appwrite/Resque/Worker.php @@ -12,6 +12,7 @@ use Utopia\Storage\Device; use Utopia\Storage\Storage; use Utopia\Storage\Device\Local; use Utopia\Storage\Device\DOSpaces; +use Utopia\Storage\Device\Linode; use Utopia\Storage\Device\S3; use Exception; @@ -278,6 +279,13 @@ abstract class Worker $doSpacesBucket = App::getEnv('_APP_STORAGE_DO_SPACES_BUCKET', ''); $doSpacesAcl = 'private'; return new DOSpaces($root, $doSpacesAccessKey, $doSpacesSecretKey, $doSpacesBucket, $doSpacesRegion, $doSpacesAcl); + case Storage::DEVICE_LINODE: + $linodeAccessKey = App::getEnv('_APP_STORAGE_LINODE_ACCESS_KEY', ''); + $linodeSecretKey = App::getEnv('_APP_STORAGE_LINODE_SECRET', ''); + $linodeRegion = App::getEnv('_APP_STORAGE_LINODE_REGION', ''); + $linodeBucket = App::getEnv('_APP_STORAGE_LINODE_BUCKET', ''); + $linodeAcl = 'private'; + return new Linode($root, $linodeAccessKey, $linodeSecretKey, $linodeBucket, $linodeRegion, $linodeAcl); } } } From 51ea3b2cbc1765cf5968b998132bbb15f24e62ff Mon Sep 17 00:00:00 2001 From: Everly Precia Suresh <77877486+everly-gif@users.noreply.github.com> Date: Fri, 18 Mar 2022 22:17:09 +0530 Subject: [PATCH 02/38] Update deletes.php --- app/workers/deletes.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/workers/deletes.php b/app/workers/deletes.php index 605c307ced..b3641c58d4 100644 --- a/app/workers/deletes.php +++ b/app/workers/deletes.php @@ -571,6 +571,7 @@ class DeletesV1 extends Worker $linodeBucket = App::getEnv('_APP_STORAGE_LINODE_BUCKET', ''); $linodeAcl = 'private'; return new Linode($root, $linodeAccessKey, $linodeSecretKey, $linodeBucket, $linodeRegion, $linodeAcl); + break; } $device->deletePath($document->getId()); From fc8397de79fcf4c36ad7618ac5da5cf3659927e9 Mon Sep 17 00:00:00 2001 From: Everly Precia Suresh <77877486+everly-gif@users.noreply.github.com> Date: Fri, 18 Mar 2022 22:41:30 +0530 Subject: [PATCH 03/38] Update variables.php --- app/config/variables.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/config/variables.php b/app/config/variables.php index 4d0f2ae117..36be9c9fc0 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -519,7 +519,7 @@ return [ ], [ 'name' => '_APP_STORAGE_LINODE_REGION', - 'description' => 'Linode object storage region. Required when storage adapter is set to Linode. You can find your region info for your space from Linode console.', + 'description' => 'Linode object storage region. Required when storage adapter is set to Linode. You can find your region info from your Linode console.', 'introduction' => '0.13.0', 'default' => 'us-eas-1', 'required' => false, From f03a68fbfece1f98df1302fe97e6a599667970a7 Mon Sep 17 00:00:00 2001 From: Everly Precia Suresh Date: Fri, 18 Mar 2022 17:17:43 +0000 Subject: [PATCH 04/38] add storage support for wasabi --- CHANGES.md | 2 +- Dockerfile | 4 ++++ app/config/variables.php | 32 ++++++++++++++++++++++++++++++++ app/executor.php | 8 ++++++++ app/init.php | 8 ++++++++ app/views/install/compose.phtml | 12 ++++++++++++ app/workers/deletes.php | 9 +++++++++ docker-compose.yml | 12 ++++++++++++ src/Appwrite/Resque/Worker.php | 8 ++++++++ 9 files changed, 94 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 7b09391f49..4521093100 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,7 +1,7 @@ # Latest ## Features ### Storage -- Support for Linode object storage +- Support for Linode object storage and Wasabi # Version 0.13.3 ## Bugs diff --git a/Dockerfile b/Dockerfile index 204490f4d0..c776f42fac 100755 --- a/Dockerfile +++ b/Dockerfile @@ -166,6 +166,10 @@ ENV _APP_SERVER=swoole \ _APP_STORAGE_LINODE_SECRET= \ _APP_STORAGE_LINODE_REGION= \ _APP_STORAGE_LINODE_BUCKET= \ + _APP_STORAGE_WASABI_ACCESS_KEY= \ + _APP_STORAGE_WASABI_SECRET= \ + _APP_STORAGE_WASABI_REGION= \ + _APP_STORAGE_WASABI_BUCKET= \ _APP_REDIS_HOST=redis \ _APP_REDIS_PORT=6379 \ _APP_DB_HOST=mariadb \ diff --git a/app/config/variables.php b/app/config/variables.php index 4d0f2ae117..4270ef68c1 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -533,6 +533,38 @@ return [ 'required' => false, 'question' => '', ], + [ + 'name' => '_APP_STORAGE_WASABI_ACCESS_KEY', + 'description' => 'Wasabi access key. Required when the storage adapter is set to Wasabi. You can get your access key from your Wasabi console.', + 'introduction' => '0.13.0', + 'default' => '', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_STORAGE_WASABI_SECRET', + 'description' => 'Wasabi secret key. Required when the storage adapter is set to Wasabi. You can get your secret key from your Wasabi console.', + 'introduction' => '0.13.0', + 'default' => '', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_STORAGE_WASABI_REGION', + 'description' => 'Wasabi region. Required when storage adapter is set to Wasabi. You can find your region info from your Wasabi console.', + 'introduction' => '0.13.0', + 'default' => 'us-eas-1', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_STORAGE_WASABI_BUCKET', + 'description' => 'Wasabi bucket. Required when storage adapter is set to Wasabi. You can create buckets in your Wasabi console.', + 'introduction' => '0.13.0', + 'default' => '', + 'required' => false, + 'question' => '', + ], ], ], [ diff --git a/app/executor.php b/app/executor.php index a5a4da64cf..c23d57d758 100644 --- a/app/executor.php +++ b/app/executor.php @@ -19,6 +19,7 @@ use Utopia\Storage\Device; use Utopia\Storage\Device\Local; use Utopia\Storage\Device\DOSpaces; use Utopia\Storage\Device\Linode; +use Utopia\Storage\Device\Wasabi; use Utopia\Storage\Device\S3; use Utopia\Storage\Storage; use Utopia\Swoole\Request; @@ -137,6 +138,13 @@ function getStorageDevice($root): Device { $linodeBucket = App::getEnv('_APP_STORAGE_LINODE_BUCKET', ''); $linodeAcl = 'private'; return new Linode($root, $linodeAccessKey, $linodeSecretKey, $linodeBucket, $linodeRegion, $linodeAcl); + case Storage::DEVICE_WASABI: + $wasabiAccessKey = App::getEnv('_APP_STORAGE_WASABI_ACCESS_KEY', ''); + $wasabiSecretKey = App::getEnv('_APP_STORAGE_WASABI_SECRET', ''); + $wasabiRegion = App::getEnv('_APP_STORAGE_WASABI_REGION', ''); + $wasabiBucket = App::getEnv('_APP_STORAGE_WASABI_BUCKET', ''); + $wasabiAcl = 'private'; + return new Wasabi($root, $wasabiAccessKey, $wasabiSecretKey, $wasabiBucket, $wasabiRegion, $wasabiAcl); } } diff --git a/app/init.php b/app/init.php index 0d9c1441c8..7dbd12a502 100644 --- a/app/init.php +++ b/app/init.php @@ -56,6 +56,7 @@ use Utopia\Storage\Device\Local; use Utopia\Storage\Device\S3; use Utopia\Storage\Device\DOSpaces; use Utopia\Storage\Device\Linode; +use Utopia\Storage\Device\Wasabi; const APP_NAME = 'Appwrite'; const APP_DOMAIN = 'appwrite.io'; @@ -844,6 +845,13 @@ function getDevice($root): Device { $linodeBucket = App::getEnv('_APP_STORAGE_LINODE_BUCKET', ''); $linodeAcl = 'private'; return new Linode($root, $linodeAccessKey, $linodeSecretKey, $linodeBucket, $linodeRegion, $linodeAcl); + case Storage::DEVICE_WASABI: + $wasabiAccessKey = App::getEnv('_APP_STORAGE_WASABI_ACCESS_KEY', ''); + $wasabiSecretKey = App::getEnv('_APP_STORAGE_WASABI_SECRET', ''); + $wasabiRegion = App::getEnv('_APP_STORAGE_WASABI_REGION', ''); + $wasabiBucket = App::getEnv('_APP_STORAGE_WASABI_BUCKET', ''); + $wasabiAcl = 'private'; + return new Wasabi($root, $wasabiAccessKey, $wasabiSecretKey, $wasabiBucket, $wasabiRegion, $wasabiAcl); } } diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index 6604737bef..338df71f7c 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -114,6 +114,10 @@ services: - _APP_STORAGE_LINODE_SECRET - _APP_STORAGE_LINODE_REGION - _APP_STORAGE_LINODE_BUCKET + - _APP_STORAGE_WASABI_ACCESS_KEY + - _APP_STORAGE_WASABI_SECRET + - _APP_STORAGE_WASABI_REGION + - _APP_STORAGE_WASABI_BUCKET - _APP_FUNCTIONS_SIZE_LIMIT - _APP_FUNCTIONS_TIMEOUT - _APP_FUNCTIONS_BUILD_TIMEOUT @@ -210,6 +214,10 @@ services: - _APP_STORAGE_LINODE_SECRET - _APP_STORAGE_LINODE_REGION - _APP_STORAGE_LINODE_BUCKET + - _APP_STORAGE_WASABI_ACCESS_KEY + - _APP_STORAGE_WASABI_SECRET + - _APP_STORAGE_WASABI_REGION + - _APP_STORAGE_WASABI_BUCKET - _APP_FUNCTIONS_CPUS - _APP_FUNCTIONS_MEMORY - _APP_FUNCTIONS_MEMORY_SWAP @@ -355,6 +363,10 @@ services: - _APP_STORAGE_LINODE_SECRET - _APP_STORAGE_LINODE_REGION - _APP_STORAGE_LINODE_BUCKET + - _APP_STORAGE_WASABI_ACCESS_KEY + - _APP_STORAGE_WASABI_SECRET + - _APP_STORAGE_WASABI_REGION + - _APP_STORAGE_WASABI_BUCKET - _APP_LOGGING_PROVIDER - _APP_LOGGING_CONFIG - _APP_EXECUTOR_SECRET diff --git a/app/workers/deletes.php b/app/workers/deletes.php index 605c307ced..8370d09e7e 100644 --- a/app/workers/deletes.php +++ b/app/workers/deletes.php @@ -11,6 +11,7 @@ use Utopia\Storage\Device\Local; use Utopia\Storage\Device\S3; use Utopia\Storage\Device\DOSpaces; use Utopia\Storage\Device\Linode; +use Utopia\Storage\Device\Wasabi; use Utopia\Storage\Storage; use Utopia\Abuse\Abuse; use Utopia\Abuse\Adapters\TimeLimit; @@ -571,6 +572,14 @@ class DeletesV1 extends Worker $linodeBucket = App::getEnv('_APP_STORAGE_LINODE_BUCKET', ''); $linodeAcl = 'private'; return new Linode($root, $linodeAccessKey, $linodeSecretKey, $linodeBucket, $linodeRegion, $linodeAcl); + case Storage::DEVICE_WASABI: + $wasabiAccessKey = App::getEnv('_APP_STORAGE_WASABI_ACCESS_KEY', ''); + $wasabiSecretKey = App::getEnv('_APP_STORAGE_WASABI_SECRET', ''); + $wasabiRegion = App::getEnv('_APP_STORAGE_WASABI_REGION', ''); + $wasabiBucket = App::getEnv('_APP_STORAGE_WASABI_BUCKET', ''); + $wasabiAcl = 'private'; + return new Wasabi($root, $wasabiAccessKey, $wasabiSecretKey, $wasabiBucket, $wasabiRegion, $wasabiAcl); + break; } $device->deletePath($document->getId()); diff --git a/docker-compose.yml b/docker-compose.yml index 3c703e57cb..647f727ac7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -127,6 +127,10 @@ services: - _APP_STORAGE_LINODE_SECRET - _APP_STORAGE_LINODE_REGION - _APP_STORAGE_LINODE_BUCKET + - _APP_STORAGE_WASABI_ACCESS_KEY + - _APP_STORAGE_WASABI_SECRET + - _APP_STORAGE_WASABI_REGION + - _APP_STORAGE_WASABI_BUCKET - _APP_SMTP_HOST - _APP_SMTP_PORT - _APP_SMTP_SECURE @@ -287,6 +291,10 @@ services: - _APP_STORAGE_LINODE_SECRET - _APP_STORAGE_LINODE_REGION - _APP_STORAGE_LINODE_BUCKET + - _APP_STORAGE_WASABI_ACCESS_KEY + - _APP_STORAGE_WASABI_SECRET + - _APP_STORAGE_WASABI_REGION + - _APP_STORAGE_WASABI_BUCKET - _APP_LOGGING_PROVIDER - _APP_LOGGING_CONFIG - _APP_EXECUTOR_SECRET @@ -458,6 +466,10 @@ services: - _APP_STORAGE_LINODE_SECRET - _APP_STORAGE_LINODE_REGION - _APP_STORAGE_LINODE_BUCKET + - _APP_STORAGE_WASABI_ACCESS_KEY + - _APP_STORAGE_WASABI_SECRET + - _APP_STORAGE_WASABI_REGION + - _APP_STORAGE_WASABI_BUCKET - DOCKERHUB_PULL_USERNAME - DOCKERHUB_PULL_PASSWORD diff --git a/src/Appwrite/Resque/Worker.php b/src/Appwrite/Resque/Worker.php index 6c3263c188..93f437fbf1 100644 --- a/src/Appwrite/Resque/Worker.php +++ b/src/Appwrite/Resque/Worker.php @@ -13,6 +13,7 @@ use Utopia\Storage\Storage; use Utopia\Storage\Device\Local; use Utopia\Storage\Device\DOSpaces; use Utopia\Storage\Device\Linode; +use Utopia\Storage\Device\Wasabi; use Utopia\Storage\Device\S3; use Exception; @@ -286,6 +287,13 @@ abstract class Worker $linodeBucket = App::getEnv('_APP_STORAGE_LINODE_BUCKET', ''); $linodeAcl = 'private'; return new Linode($root, $linodeAccessKey, $linodeSecretKey, $linodeBucket, $linodeRegion, $linodeAcl); + case Storage::DEVICE_WASABI: + $wasabiAccessKey = App::getEnv('_APP_STORAGE_WASABI_ACCESS_KEY', ''); + $wasabiSecretKey = App::getEnv('_APP_STORAGE_WASABI_SECRET', ''); + $wasabiRegion = App::getEnv('_APP_STORAGE_WASABI_REGION', ''); + $wasabiBucket = App::getEnv('_APP_STORAGE_WASABI_BUCKET', ''); + $wasabiAcl = 'private'; + return new Wasabi($root, $wasabiAccessKey, $wasabiSecretKey, $wasabiBucket, $wasabiRegion, $wasabiAcl); } } } From 66d3f03f35a6a2dcb4244a9fc20f7283e8db8e9f Mon Sep 17 00:00:00 2001 From: Everly Precia Suresh Date: Fri, 18 Mar 2022 17:25:09 +0000 Subject: [PATCH 05/38] update deletes.php --- app/workers/deletes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/workers/deletes.php b/app/workers/deletes.php index b221ecec54..b5a69d6c8b 100644 --- a/app/workers/deletes.php +++ b/app/workers/deletes.php @@ -579,7 +579,7 @@ class DeletesV1 extends Worker $wasabiRegion = App::getEnv('_APP_STORAGE_WASABI_REGION', ''); $wasabiBucket = App::getEnv('_APP_STORAGE_WASABI_BUCKET', ''); $wasabiAcl = 'private'; - return new Wasabi($root, $wasabiAccessKey, $wasabiSecretKey, $wasabiBucket, $wasabiRegion, $wasabiAcl); + $device = new Wasabi($root, $wasabiAccessKey, $wasabiSecretKey, $wasabiBucket, $wasabiRegion, $wasabiAcl); break; } From c407c836159558477e635a3c0a0535a3f8c25bdc Mon Sep 17 00:00:00 2001 From: Everly Precia Suresh <77877486+everly-gif@users.noreply.github.com> Date: Fri, 18 Mar 2022 22:56:12 +0530 Subject: [PATCH 06/38] Update deletes.php --- app/workers/deletes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/workers/deletes.php b/app/workers/deletes.php index b3641c58d4..eb80a5fc90 100644 --- a/app/workers/deletes.php +++ b/app/workers/deletes.php @@ -570,7 +570,7 @@ class DeletesV1 extends Worker $linodeRegion = App::getEnv('_APP_STORAGE_LINODE_REGION', ''); $linodeBucket = App::getEnv('_APP_STORAGE_LINODE_BUCKET', ''); $linodeAcl = 'private'; - return new Linode($root, $linodeAccessKey, $linodeSecretKey, $linodeBucket, $linodeRegion, $linodeAcl); + $device= new Linode($root, $linodeAccessKey, $linodeSecretKey, $linodeBucket, $linodeRegion, $linodeAcl); break; } From 7eb59c5290c788ff002ea9955313a12e7c39ebf5 Mon Sep 17 00:00:00 2001 From: Everly Precia Suresh <77877486+everly-gif@users.noreply.github.com> Date: Fri, 18 Mar 2022 22:58:28 +0530 Subject: [PATCH 07/38] Update deletes.php --- app/workers/deletes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/workers/deletes.php b/app/workers/deletes.php index b5a69d6c8b..47f503ddf8 100644 --- a/app/workers/deletes.php +++ b/app/workers/deletes.php @@ -571,7 +571,7 @@ class DeletesV1 extends Worker $linodeRegion = App::getEnv('_APP_STORAGE_LINODE_REGION', ''); $linodeBucket = App::getEnv('_APP_STORAGE_LINODE_BUCKET', ''); $linodeAcl = 'private'; - return new Linode($root, $linodeAccessKey, $linodeSecretKey, $linodeBucket, $linodeRegion, $linodeAcl); + $device = new Linode($root, $linodeAccessKey, $linodeSecretKey, $linodeBucket, $linodeRegion, $linodeAcl); break; case Storage::DEVICE_WASABI: $wasabiAccessKey = App::getEnv('_APP_STORAGE_WASABI_ACCESS_KEY', ''); From e9196bfce4c34a7cd16f88a1a69d6c3b7e89a434 Mon Sep 17 00:00:00 2001 From: Everly Precia Suresh Date: Wed, 4 May 2022 11:20:16 +0000 Subject: [PATCH 08/38] feat add backblaze support --- CHANGES.md | 1 + Dockerfile | 4 ++++ app/config/variables.php | 34 ++++++++++++++++++++++++++++++++- app/executor.php | 8 ++++++++ app/init.php | 8 ++++++++ app/views/install/compose.phtml | 12 ++++++++++++ app/workers/deletes.php | 9 +++++++++ docker-compose.yml | 12 ++++++++++++ src/Appwrite/Resque/Worker.php | 8 ++++++++ 9 files changed, 95 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 7580ccb114..a90226173b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,6 @@ # Unreleased Version - Renamed `providers` to `authProviders` in project collection **Breaking Change** +- Support for Backblaze adapter in Storage # Version 0.13.4 diff --git a/Dockerfile b/Dockerfile index c464885054..8df9166480 100755 --- a/Dockerfile +++ b/Dockerfile @@ -162,6 +162,10 @@ ENV _APP_SERVER=swoole \ _APP_STORAGE_DO_SPACES_SECRET= \ _APP_STORAGE_DO_SPACES_REGION= \ _APP_STORAGE_DO_SPACES_BUCKET= \ + _APP_STORAGE_BACKBLAZE_ACCESS_KEY= \ + _APP_STORAGE_BACKBLAZE_SECRET= \ + _APP_STORAGE_BACKBLAZE_REGION= \ + _APP_STORAGE_BACKBLAZE_BUCKET= \ _APP_REDIS_HOST=redis \ _APP_REDIS_PORT=6379 \ _APP_DB_HOST=mariadb \ diff --git a/app/config/variables.php b/app/config/variables.php index 2bed472758..0326b97903 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -440,7 +440,7 @@ return [ ], [ 'name' => '_APP_STORAGE_DEVICE', - 'description' => 'Select default storage device. The default value is \'Local\'. List of supported adapters are \'Local\', \'S3\' and \'DOSpaces\'.', + 'description' => 'Select default storage device. The default value is \'Local\'. List of supported adapters are \'Local\', \'S3\', \'DOSpaces\' and \'Backblaze\'.', 'introduction' => '0.13.0', 'default' => 'Local', 'required' => false, @@ -510,6 +510,38 @@ return [ 'required' => false, 'question' => '', ], + [ + 'name' => '_APP_STORAGE_BACKBLAZE_ACCESS_KEY', + 'description' => 'Backblaze access key. Required when the storage adapter is set to BackBlaze. Your Backblaze keyID will be your access key. You can get your keyID from your Backblaze console.', + 'introduction' => '0.13.0', + 'default' => '', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_STORAGE_BACKBLAZE_SECRET', + 'description' => 'Backblaze secret key. Required when the storage adapter is set to BackBlaze. Your Backblaze applicationKey will be your secret key. You can get your applicationKey from your Backblaze console.', + 'introduction' => '0.13.0', + 'default' => '', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_STORAGE_BACKBLAZE_REGION', + 'description' => 'Backblaze region. Required when storage adapter is set to BackBlaze. You can find your region info from your Backblaze console.', + 'introduction' => '0.13.0', + 'default' => 'us-west-004', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_STORAGE_BACKBLAZE_BUCKET', + 'description' => 'Backblaze bucket. Required when storage adapter is set to BackBlaze. You can create your bucket from your Backblaze console.', + 'introduction' => '0.13.0', + 'default' => '', + 'required' => false, + 'question' => '', + ], ], ], [ diff --git a/app/executor.php b/app/executor.php index e9f4c21391..1fd09c1ffe 100644 --- a/app/executor.php +++ b/app/executor.php @@ -17,6 +17,7 @@ use Utopia\Orchestration\Adapter\DockerCLI; use Utopia\Orchestration\Orchestration; use Utopia\Storage\Device; use Utopia\Storage\Device\Local; +use Utopia\Storage\Device\BackBlaze; use Utopia\Storage\Device\DOSpaces; use Utopia\Storage\Device\S3; use Utopia\Storage\Storage; @@ -130,6 +131,13 @@ function getStorageDevice($root): Device { $doSpacesBucket = App::getEnv('_APP_STORAGE_DO_SPACES_BUCKET', ''); $doSpacesAcl = 'private'; return new DOSpaces($root, $doSpacesAccessKey, $doSpacesSecretKey, $doSpacesBucket, $doSpacesRegion, $doSpacesAcl); + case Storage::DEVICE_BACKBLAZE: + $backblazeAccessKey = App::getEnv('_APP_STORAGE_BACKBLAZE_ACCESS_KEY', ''); + $backblazeSecretKey = App::getEnv('_APP_STORAGE_BACKBLAZE_SECRET', ''); + $backblazeRegion = App::getEnv('_APP_STORAGE_BACKBLAZE_REGION', ''); + $backblazeBucket = App::getEnv('_APP_STORAGE_BACKBLAZE_BUCKET', ''); + $backblazeAcl = 'private'; + return new BackBlaze($root, $backblazeAccessKey, $backblazeSecretKey, $backblazeBucket, $backblazeRegion, $backblazeAcl); } } diff --git a/app/init.php b/app/init.php index fd509297f6..259eae7bb8 100644 --- a/app/init.php +++ b/app/init.php @@ -53,6 +53,7 @@ use Utopia\Database\Query; use Utopia\Storage\Device; use Utopia\Storage\Storage; use Utopia\Storage\Device\Local; +use Utopia\Storage\Device\BackBlaze; use Utopia\Storage\Device\S3; use Utopia\Storage\Device\DOSpaces; @@ -835,6 +836,13 @@ function getDevice($root): Device { $doSpacesBucket = App::getEnv('_APP_STORAGE_DO_SPACES_BUCKET', ''); $doSpacesAcl = 'private'; return new DOSpaces($root, $doSpacesAccessKey, $doSpacesSecretKey, $doSpacesBucket, $doSpacesRegion, $doSpacesAcl); + case Storage::DEVICE_BACKBLAZE: + $backblazeAccessKey = App::getEnv('_APP_STORAGE_BACKBLAZE_ACCESS_KEY', ''); + $backblazeSecretKey = App::getEnv('_APP_STORAGE_BACKBLAZE_SECRET', ''); + $backblazeRegion = App::getEnv('_APP_STORAGE_BACKBLAZE_REGION', ''); + $backblazeBucket = App::getEnv('_APP_STORAGE_BACKBLAZE_BUCKET', ''); + $backblazeAcl = 'private'; + return new BackBlaze($root, $backblazeAccessKey, $backblazeSecretKey, $backblazeBucket, $backblazeRegion, $backblazeAcl); } } diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index 4c3406ffed..3c9c7f50a2 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -119,6 +119,10 @@ services: - _APP_STORAGE_DO_SPACES_SECRET - _APP_STORAGE_DO_SPACES_REGION - _APP_STORAGE_DO_SPACES_BUCKET + - _APP_STORAGE_BACKBLAZE_ACCESS_KEY + - _APP_STORAGE_BACKBLAZE_SECRET + - _APP_STORAGE_BACKBLAZE_REGION + - _APP_STORAGE_BACKBLAZE_BUCKET - _APP_FUNCTIONS_SIZE_LIMIT - _APP_FUNCTIONS_TIMEOUT - _APP_FUNCTIONS_BUILD_TIMEOUT @@ -266,6 +270,10 @@ services: - _APP_STORAGE_DO_SPACES_SECRET - _APP_STORAGE_DO_SPACES_REGION - _APP_STORAGE_DO_SPACES_BUCKET + - _APP_STORAGE_BACKBLAZE_ACCESS_KEY + - _APP_STORAGE_BACKBLAZE_SECRET + - _APP_STORAGE_BACKBLAZE_REGION + - _APP_STORAGE_BACKBLAZE_BUCKET - _APP_LOGGING_PROVIDER - _APP_LOGGING_CONFIG - _APP_EXECUTOR_SECRET @@ -430,6 +438,10 @@ services: - _APP_STORAGE_DO_SPACES_SECRET - _APP_STORAGE_DO_SPACES_REGION - _APP_STORAGE_DO_SPACES_BUCKET + - _APP_STORAGE_BACKBLAZE_ACCESS_KEY + - _APP_STORAGE_BACKBLAZE_SECRET + - _APP_STORAGE_BACKBLAZE_REGION + - _APP_STORAGE_BACKBLAZE_BUCKET - DOCKERHUB_PULL_USERNAME - DOCKERHUB_PULL_PASSWORD diff --git a/app/workers/deletes.php b/app/workers/deletes.php index b8a44ebb82..fe383036c5 100644 --- a/app/workers/deletes.php +++ b/app/workers/deletes.php @@ -10,6 +10,7 @@ use Executor\Executor; use Utopia\Storage\Device\Local; use Utopia\Storage\Device\S3; use Utopia\Storage\Device\DOSpaces; +use Utopia\Storage\Device\BackBlaze; use Utopia\Storage\Storage; use Utopia\Abuse\Abuse; use Utopia\Abuse\Adapters\TimeLimit; @@ -563,6 +564,14 @@ class DeletesV1 extends Worker $doSpacesAcl = 'private'; $device = new DOSpaces(APP_STORAGE_UPLOADS . '/app-' . $projectId, $doSpacesAccessKey, $doSpacesSecretKey, $doSpacesBucket, $doSpacesRegion, $doSpacesAcl); break; + case Storage::DEVICE_BACKBLAZE: + $backblazeAccessKey = App::getEnv('_APP_STORAGE_BACKBLAZE_ACCESS_KEY', ''); + $backblazeSecretKey = App::getEnv('_APP_STORAGE_BACKBLAZE_SECRET', ''); + $backblazeRegion = App::getEnv('_APP_STORAGE_BACKBLAZE_REGION', ''); + $backblazeBucket = App::getEnv('_APP_STORAGE_BACKBLAZE_BUCKET', ''); + $backblazeAcl = 'private'; + $device= new BackBlaze(APP_STORAGE_UPLOADS . '/app-' . $projectId, $backblazeAccessKey, $backblazeSecretKey, $backblazeBucket, $backblazeRegion, $backblazeAcl); + break; } $device->deletePath($document->getId()); diff --git a/docker-compose.yml b/docker-compose.yml index 9f567b4233..8b1aa0c00d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -141,6 +141,10 @@ services: - _APP_STORAGE_DO_SPACES_SECRET - _APP_STORAGE_DO_SPACES_REGION - _APP_STORAGE_DO_SPACES_BUCKET + - _APP_STORAGE_BACKBLAZE_ACCESS_KEY + - _APP_STORAGE_BACKBLAZE_SECRET + - _APP_STORAGE_BACKBLAZE_REGION + - _APP_STORAGE_BACKBLAZE_BUCKET - _APP_FUNCTIONS_SIZE_LIMIT - _APP_FUNCTIONS_TIMEOUT - _APP_FUNCTIONS_BUILD_TIMEOUT @@ -304,6 +308,10 @@ services: - _APP_STORAGE_DO_SPACES_SECRET - _APP_STORAGE_DO_SPACES_REGION - _APP_STORAGE_DO_SPACES_BUCKET + - _APP_STORAGE_BACKBLAZE_ACCESS_KEY + - _APP_STORAGE_BACKBLAZE_SECRET + - _APP_STORAGE_BACKBLAZE_REGION + - _APP_STORAGE_BACKBLAZE_BUCKET - _APP_LOGGING_PROVIDER - _APP_LOGGING_CONFIG - _APP_EXECUTOR_SECRET @@ -488,6 +496,10 @@ services: - _APP_STORAGE_DO_SPACES_SECRET - _APP_STORAGE_DO_SPACES_REGION - _APP_STORAGE_DO_SPACES_BUCKET + - _APP_STORAGE_BACKBLAZE_ACCESS_KEY + - _APP_STORAGE_BACKBLAZE_SECRET + - _APP_STORAGE_BACKBLAZE_REGION + - _APP_STORAGE_BACKBLAZE_BUCKET - DOCKERHUB_PULL_USERNAME - DOCKERHUB_PULL_PASSWORD diff --git a/src/Appwrite/Resque/Worker.php b/src/Appwrite/Resque/Worker.php index 9682688736..531d1a8007 100644 --- a/src/Appwrite/Resque/Worker.php +++ b/src/Appwrite/Resque/Worker.php @@ -12,6 +12,7 @@ use Utopia\Storage\Device; use Utopia\Storage\Storage; use Utopia\Storage\Device\Local; use Utopia\Storage\Device\DOSpaces; +use Utopia\Storage\Device\BackBlaze; use Utopia\Storage\Device\S3; use Exception; @@ -278,6 +279,13 @@ abstract class Worker $doSpacesBucket = App::getEnv('_APP_STORAGE_DO_SPACES_BUCKET', ''); $doSpacesAcl = 'private'; return new DOSpaces($root, $doSpacesAccessKey, $doSpacesSecretKey, $doSpacesBucket, $doSpacesRegion, $doSpacesAcl); + case Storage::DEVICE_BACKBLAZE: + $backblazeAccessKey = App::getEnv('_APP_STORAGE_BACKBLAZE_ACCESS_KEY', ''); + $backblazeSecretKey = App::getEnv('_APP_STORAGE_BACKBLAZE_SECRET', ''); + $backblazeRegion = App::getEnv('_APP_STORAGE_BACKBLAZE_REGION', ''); + $backblazeBucket = App::getEnv('_APP_STORAGE_BACKBLAZE_BUCKET', ''); + $backblazeAcl = 'private'; + return new BackBlaze($root, $backblazeAccessKey, $backblazeSecretKey, $backblazeBucket, $backblazeRegion, $backblazeAcl); } } } From 5e14ee478ebb2e2693be80d7c29c00f1f039341e Mon Sep 17 00:00:00 2001 From: Everly Precia Suresh Date: Tue, 10 May 2022 11:15:56 +0000 Subject: [PATCH 09/38] change BackBlaze to Backblaze --- .env | 4 ++++ app/config/variables.php | 8 ++++---- app/controllers/shared/api.php | 1 + app/executor.php | 4 ++-- app/init.php | 4 ++-- app/workers/deletes.php | 4 ++-- src/Appwrite/Resque/Worker.php | 4 ++-- 7 files changed, 17 insertions(+), 12 deletions(-) diff --git a/.env b/.env index 1b35cca898..f250c3b1fa 100644 --- a/.env +++ b/.env @@ -32,6 +32,10 @@ _APP_STORAGE_DO_SPACES_ACCESS_KEY= _APP_STORAGE_DO_SPACES_SECRET= _APP_STORAGE_DO_SPACES_REGION=us-eas-1 _APP_STORAGE_DO_SPACES_BUCKET= +_APP_STORAGE_BACKBLAZE_ACCESS_KEY= +_APP_STORAGE_BACKBLAZE_SECRET= +_APP_STORAGE_BACKBLAZE_REGION=us-eas-1 +_APP_STORAGE_BACKBLAZE_BUCKET= _APP_STORAGE_ANTIVIRUS=disabled _APP_STORAGE_ANTIVIRUS_HOST=clamav _APP_STORAGE_ANTIVIRUS_PORT=3310 diff --git a/app/config/variables.php b/app/config/variables.php index 0326b97903..6b926a25e1 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -512,7 +512,7 @@ return [ ], [ 'name' => '_APP_STORAGE_BACKBLAZE_ACCESS_KEY', - 'description' => 'Backblaze access key. Required when the storage adapter is set to BackBlaze. Your Backblaze keyID will be your access key. You can get your keyID from your Backblaze console.', + 'description' => 'Backblaze access key. Required when the storage adapter is set to Backblaze. Your Backblaze keyID will be your access key. You can get your keyID from your Backblaze console.', 'introduction' => '0.13.0', 'default' => '', 'required' => false, @@ -520,7 +520,7 @@ return [ ], [ 'name' => '_APP_STORAGE_BACKBLAZE_SECRET', - 'description' => 'Backblaze secret key. Required when the storage adapter is set to BackBlaze. Your Backblaze applicationKey will be your secret key. You can get your applicationKey from your Backblaze console.', + 'description' => 'Backblaze secret key. Required when the storage adapter is set to Backblaze. Your Backblaze applicationKey will be your secret key. You can get your applicationKey from your Backblaze console.', 'introduction' => '0.13.0', 'default' => '', 'required' => false, @@ -528,7 +528,7 @@ return [ ], [ 'name' => '_APP_STORAGE_BACKBLAZE_REGION', - 'description' => 'Backblaze region. Required when storage adapter is set to BackBlaze. You can find your region info from your Backblaze console.', + 'description' => 'Backblaze region. Required when storage adapter is set to Backblaze. You can find your region info from your Backblaze console.', 'introduction' => '0.13.0', 'default' => 'us-west-004', 'required' => false, @@ -536,7 +536,7 @@ return [ ], [ 'name' => '_APP_STORAGE_BACKBLAZE_BUCKET', - 'description' => 'Backblaze bucket. Required when storage adapter is set to BackBlaze. You can create your bucket from your Backblaze console.', + 'description' => 'Backblaze bucket. Required when storage adapter is set to Backblaze. You can create your bucket from your Backblaze console.', 'introduction' => '0.13.0', 'default' => '', 'required' => false, diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index c5c6da6167..218a2e339c 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -8,6 +8,7 @@ use Utopia\Abuse\Abuse; use Utopia\Abuse\Adapters\TimeLimit; use Utopia\Database\Document; use Utopia\Storage\Device\DOSpaces; +use Utopia\Storage\Device\Backblaze; use Utopia\Database\Validator\Authorization; use Utopia\Storage\Device\Local; use Utopia\Storage\Device\S3; diff --git a/app/executor.php b/app/executor.php index 1fd09c1ffe..3d827f0a24 100644 --- a/app/executor.php +++ b/app/executor.php @@ -17,7 +17,7 @@ use Utopia\Orchestration\Adapter\DockerCLI; use Utopia\Orchestration\Orchestration; use Utopia\Storage\Device; use Utopia\Storage\Device\Local; -use Utopia\Storage\Device\BackBlaze; +use Utopia\Storage\Device\Backblaze; use Utopia\Storage\Device\DOSpaces; use Utopia\Storage\Device\S3; use Utopia\Storage\Storage; @@ -137,7 +137,7 @@ function getStorageDevice($root): Device { $backblazeRegion = App::getEnv('_APP_STORAGE_BACKBLAZE_REGION', ''); $backblazeBucket = App::getEnv('_APP_STORAGE_BACKBLAZE_BUCKET', ''); $backblazeAcl = 'private'; - return new BackBlaze($root, $backblazeAccessKey, $backblazeSecretKey, $backblazeBucket, $backblazeRegion, $backblazeAcl); + return new Backblaze($root, $backblazeAccessKey, $backblazeSecretKey, $backblazeBucket, $backblazeRegion, $backblazeAcl); } } diff --git a/app/init.php b/app/init.php index 259eae7bb8..a87f3ee3fc 100644 --- a/app/init.php +++ b/app/init.php @@ -53,7 +53,7 @@ use Utopia\Database\Query; use Utopia\Storage\Device; use Utopia\Storage\Storage; use Utopia\Storage\Device\Local; -use Utopia\Storage\Device\BackBlaze; +use Utopia\Storage\Device\Backblaze; use Utopia\Storage\Device\S3; use Utopia\Storage\Device\DOSpaces; @@ -842,7 +842,7 @@ function getDevice($root): Device { $backblazeRegion = App::getEnv('_APP_STORAGE_BACKBLAZE_REGION', ''); $backblazeBucket = App::getEnv('_APP_STORAGE_BACKBLAZE_BUCKET', ''); $backblazeAcl = 'private'; - return new BackBlaze($root, $backblazeAccessKey, $backblazeSecretKey, $backblazeBucket, $backblazeRegion, $backblazeAcl); + return new Backblaze($root, $backblazeAccessKey, $backblazeSecretKey, $backblazeBucket, $backblazeRegion, $backblazeAcl); } } diff --git a/app/workers/deletes.php b/app/workers/deletes.php index fe383036c5..441aebf728 100644 --- a/app/workers/deletes.php +++ b/app/workers/deletes.php @@ -10,7 +10,7 @@ use Executor\Executor; use Utopia\Storage\Device\Local; use Utopia\Storage\Device\S3; use Utopia\Storage\Device\DOSpaces; -use Utopia\Storage\Device\BackBlaze; +use Utopia\Storage\Device\Backblaze; use Utopia\Storage\Storage; use Utopia\Abuse\Abuse; use Utopia\Abuse\Adapters\TimeLimit; @@ -570,7 +570,7 @@ class DeletesV1 extends Worker $backblazeRegion = App::getEnv('_APP_STORAGE_BACKBLAZE_REGION', ''); $backblazeBucket = App::getEnv('_APP_STORAGE_BACKBLAZE_BUCKET', ''); $backblazeAcl = 'private'; - $device= new BackBlaze(APP_STORAGE_UPLOADS . '/app-' . $projectId, $backblazeAccessKey, $backblazeSecretKey, $backblazeBucket, $backblazeRegion, $backblazeAcl); + $device= new Backblaze(APP_STORAGE_UPLOADS . '/app-' . $projectId, $backblazeAccessKey, $backblazeSecretKey, $backblazeBucket, $backblazeRegion, $backblazeAcl); break; } diff --git a/src/Appwrite/Resque/Worker.php b/src/Appwrite/Resque/Worker.php index 531d1a8007..34a37dbc5e 100644 --- a/src/Appwrite/Resque/Worker.php +++ b/src/Appwrite/Resque/Worker.php @@ -12,7 +12,7 @@ use Utopia\Storage\Device; use Utopia\Storage\Storage; use Utopia\Storage\Device\Local; use Utopia\Storage\Device\DOSpaces; -use Utopia\Storage\Device\BackBlaze; +use Utopia\Storage\Device\Backblaze; use Utopia\Storage\Device\S3; use Exception; @@ -285,7 +285,7 @@ abstract class Worker $backblazeRegion = App::getEnv('_APP_STORAGE_BACKBLAZE_REGION', ''); $backblazeBucket = App::getEnv('_APP_STORAGE_BACKBLAZE_BUCKET', ''); $backblazeAcl = 'private'; - return new BackBlaze($root, $backblazeAccessKey, $backblazeSecretKey, $backblazeBucket, $backblazeRegion, $backblazeAcl); + return new Backblaze($root, $backblazeAccessKey, $backblazeSecretKey, $backblazeBucket, $backblazeRegion, $backblazeAcl); } } } From 9d43ad32b4996c54c2fb11bff29720deb15ad458 Mon Sep 17 00:00:00 2001 From: Everly Precia Suresh Date: Tue, 10 May 2022 11:19:58 +0000 Subject: [PATCH 10/38] change default env value --- .env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env b/.env index f250c3b1fa..1a4d64d8d1 100644 --- a/.env +++ b/.env @@ -34,7 +34,7 @@ _APP_STORAGE_DO_SPACES_REGION=us-eas-1 _APP_STORAGE_DO_SPACES_BUCKET= _APP_STORAGE_BACKBLAZE_ACCESS_KEY= _APP_STORAGE_BACKBLAZE_SECRET= -_APP_STORAGE_BACKBLAZE_REGION=us-eas-1 +_APP_STORAGE_BACKBLAZE_REGION=us-west-004 _APP_STORAGE_BACKBLAZE_BUCKET= _APP_STORAGE_ANTIVIRUS=disabled _APP_STORAGE_ANTIVIRUS_HOST=clamav From 8cbb28fb989236c7aa4851cb96be2737e78f65ce Mon Sep 17 00:00:00 2001 From: Everly Precia Suresh Date: Tue, 10 May 2022 15:22:58 +0000 Subject: [PATCH 11/38] use anchors and aliases to clean up compose file --- app/views/install/compose.phtml | 57 +++++++++++---------------------- docker-compose.yml | 57 +++++++++++---------------------- 2 files changed, 36 insertions(+), 78 deletions(-) diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index 3c9c7f50a2..fd8bb2086b 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -5,6 +5,21 @@ x-logging: &x-logging max-file: 5 max-size: 10m +x-env-storage: &x-env-storage |- + _APP_STORAGE_DEVICE + _APP_STORAGE_S3_ACCESS_KEY + _APP_STORAGE_S3_SECRET + _APP_STORAGE_S3_REGION + _APP_STORAGE_S3_BUCKET + _APP_STORAGE_DO_SPACES_ACCESS_KEY + _APP_STORAGE_DO_SPACES_SECRET + _APP_STORAGE_DO_SPACES_REGION + _APP_STORAGE_DO_SPACES_BUCKET + _APP_STORAGE_BACKBLAZE_ACCESS_KEY + _APP_STORAGE_BACKBLAZE_SECRET + _APP_STORAGE_BACKBLAZE_REGION + _APP_STORAGE_BACKBLAZE_BUCKET + getParam('httpPort', ''); @@ -110,19 +125,7 @@ services: - _APP_STORAGE_ANTIVIRUS - _APP_STORAGE_ANTIVIRUS_HOST - _APP_STORAGE_ANTIVIRUS_PORT - - _APP_STORAGE_DEVICE - - _APP_STORAGE_S3_ACCESS_KEY - - _APP_STORAGE_S3_SECRET - - _APP_STORAGE_S3_REGION - - _APP_STORAGE_S3_BUCKET - - _APP_STORAGE_DO_SPACES_ACCESS_KEY - - _APP_STORAGE_DO_SPACES_SECRET - - _APP_STORAGE_DO_SPACES_REGION - - _APP_STORAGE_DO_SPACES_BUCKET - - _APP_STORAGE_BACKBLAZE_ACCESS_KEY - - _APP_STORAGE_BACKBLAZE_SECRET - - _APP_STORAGE_BACKBLAZE_REGION - - _APP_STORAGE_BACKBLAZE_BUCKET + - *x-env-storage - _APP_FUNCTIONS_SIZE_LIMIT - _APP_FUNCTIONS_TIMEOUT - _APP_FUNCTIONS_BUILD_TIMEOUT @@ -261,19 +264,7 @@ services: - _APP_DB_SCHEMA - _APP_DB_USER - _APP_DB_PASS - - _APP_STORAGE_DEVICE - - _APP_STORAGE_S3_ACCESS_KEY - - _APP_STORAGE_S3_SECRET - - _APP_STORAGE_S3_REGION - - _APP_STORAGE_S3_BUCKET - - _APP_STORAGE_DO_SPACES_ACCESS_KEY - - _APP_STORAGE_DO_SPACES_SECRET - - _APP_STORAGE_DO_SPACES_REGION - - _APP_STORAGE_DO_SPACES_BUCKET - - _APP_STORAGE_BACKBLAZE_ACCESS_KEY - - _APP_STORAGE_BACKBLAZE_SECRET - - _APP_STORAGE_BACKBLAZE_REGION - - _APP_STORAGE_BACKBLAZE_BUCKET + - *x-env-storage - _APP_LOGGING_PROVIDER - _APP_LOGGING_CONFIG - _APP_EXECUTOR_SECRET @@ -429,19 +420,7 @@ services: - OPEN_RUNTIMES_NETWORK - _APP_LOGGING_PROVIDER - _APP_LOGGING_CONFIG - - _APP_STORAGE_DEVICE - - _APP_STORAGE_S3_ACCESS_KEY - - _APP_STORAGE_S3_SECRET - - _APP_STORAGE_S3_REGION - - _APP_STORAGE_S3_BUCKET - - _APP_STORAGE_DO_SPACES_ACCESS_KEY - - _APP_STORAGE_DO_SPACES_SECRET - - _APP_STORAGE_DO_SPACES_REGION - - _APP_STORAGE_DO_SPACES_BUCKET - - _APP_STORAGE_BACKBLAZE_ACCESS_KEY - - _APP_STORAGE_BACKBLAZE_SECRET - - _APP_STORAGE_BACKBLAZE_REGION - - _APP_STORAGE_BACKBLAZE_BUCKET + - *x-env-storage - DOCKERHUB_PULL_USERNAME - DOCKERHUB_PULL_PASSWORD diff --git a/docker-compose.yml b/docker-compose.yml index 8b1aa0c00d..377adb8402 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,6 +10,21 @@ x-logging: &x-logging max-file: '5' max-size: '10m' +x-env-storage: &x-env-storage |- + _APP_STORAGE_DEVICE + _APP_STORAGE_S3_ACCESS_KEY + _APP_STORAGE_S3_SECRET + _APP_STORAGE_S3_REGION + _APP_STORAGE_S3_BUCKET + _APP_STORAGE_DO_SPACES_ACCESS_KEY + _APP_STORAGE_DO_SPACES_SECRET + _APP_STORAGE_DO_SPACES_REGION + _APP_STORAGE_DO_SPACES_BUCKET + _APP_STORAGE_BACKBLAZE_ACCESS_KEY + _APP_STORAGE_BACKBLAZE_SECRET + _APP_STORAGE_BACKBLAZE_REGION + _APP_STORAGE_BACKBLAZE_BUCKET + version: '3' services: @@ -132,19 +147,7 @@ services: - _APP_STORAGE_ANTIVIRUS - _APP_STORAGE_ANTIVIRUS_HOST - _APP_STORAGE_ANTIVIRUS_PORT - - _APP_STORAGE_DEVICE - - _APP_STORAGE_S3_ACCESS_KEY - - _APP_STORAGE_S3_SECRET - - _APP_STORAGE_S3_REGION - - _APP_STORAGE_S3_BUCKET - - _APP_STORAGE_DO_SPACES_ACCESS_KEY - - _APP_STORAGE_DO_SPACES_SECRET - - _APP_STORAGE_DO_SPACES_REGION - - _APP_STORAGE_DO_SPACES_BUCKET - - _APP_STORAGE_BACKBLAZE_ACCESS_KEY - - _APP_STORAGE_BACKBLAZE_SECRET - - _APP_STORAGE_BACKBLAZE_REGION - - _APP_STORAGE_BACKBLAZE_BUCKET + - *x-env-storage - _APP_FUNCTIONS_SIZE_LIMIT - _APP_FUNCTIONS_TIMEOUT - _APP_FUNCTIONS_BUILD_TIMEOUT @@ -299,19 +302,7 @@ services: - _APP_DB_SCHEMA - _APP_DB_USER - _APP_DB_PASS - - _APP_STORAGE_DEVICE - - _APP_STORAGE_S3_ACCESS_KEY - - _APP_STORAGE_S3_SECRET - - _APP_STORAGE_S3_REGION - - _APP_STORAGE_S3_BUCKET - - _APP_STORAGE_DO_SPACES_ACCESS_KEY - - _APP_STORAGE_DO_SPACES_SECRET - - _APP_STORAGE_DO_SPACES_REGION - - _APP_STORAGE_DO_SPACES_BUCKET - - _APP_STORAGE_BACKBLAZE_ACCESS_KEY - - _APP_STORAGE_BACKBLAZE_SECRET - - _APP_STORAGE_BACKBLAZE_REGION - - _APP_STORAGE_BACKBLAZE_BUCKET + - *x-env-storage - _APP_LOGGING_PROVIDER - _APP_LOGGING_CONFIG - _APP_EXECUTOR_SECRET @@ -487,19 +478,7 @@ services: - OPEN_RUNTIMES_NETWORK - _APP_LOGGING_PROVIDER - _APP_LOGGING_CONFIG - - _APP_STORAGE_DEVICE - - _APP_STORAGE_S3_ACCESS_KEY - - _APP_STORAGE_S3_SECRET - - _APP_STORAGE_S3_REGION - - _APP_STORAGE_S3_BUCKET - - _APP_STORAGE_DO_SPACES_ACCESS_KEY - - _APP_STORAGE_DO_SPACES_SECRET - - _APP_STORAGE_DO_SPACES_REGION - - _APP_STORAGE_DO_SPACES_BUCKET - - _APP_STORAGE_BACKBLAZE_ACCESS_KEY - - _APP_STORAGE_BACKBLAZE_SECRET - - _APP_STORAGE_BACKBLAZE_REGION - - _APP_STORAGE_BACKBLAZE_BUCKET + - *x-env-storage - DOCKERHUB_PULL_USERNAME - DOCKERHUB_PULL_PASSWORD From 7350d4e4470b2b55158bf4f109a97a634ce86eac Mon Sep 17 00:00:00 2001 From: Everly Precia Suresh Date: Thu, 12 May 2022 14:22:41 +0000 Subject: [PATCH 12/38] better way to initialize storage libs --- app/executor.php | 37 ++++++--------------------------- app/init.php | 38 +++++++--------------------------- app/workers/deletes.php | 30 ++------------------------- src/Appwrite/Resque/Worker.php | 2 +- 4 files changed, 16 insertions(+), 91 deletions(-) diff --git a/app/executor.php b/app/executor.php index 3d827f0a24..6fc1aaf691 100644 --- a/app/executor.php +++ b/app/executor.php @@ -2,6 +2,7 @@ require_once __DIR__ . '/../vendor/autoload.php'; use Appwrite\Runtimes\Runtimes; +use Appwrite\Resque\Worker; use Swoole\ConnectionPool; use Swoole\Http\Request as SwooleRequest; use Swoole\Http\Response as SwooleResponse; @@ -113,34 +114,6 @@ function logError(Throwable $error, string $action, Utopia\Route $route = null) Console::error('[Error] Line: ' . $error->getLine()); }; -function getStorageDevice($root): Device { - switch (App::getEnv('_APP_STORAGE_DEVICE', Storage::DEVICE_LOCAL)) { - case Storage::DEVICE_LOCAL:default: - return new Local($root); - case Storage::DEVICE_S3: - $s3AccessKey = App::getEnv('_APP_STORAGE_S3_ACCESS_KEY', ''); - $s3SecretKey = App::getEnv('_APP_STORAGE_S3_SECRET', ''); - $s3Region = App::getEnv('_APP_STORAGE_S3_REGION', ''); - $s3Bucket = App::getEnv('_APP_STORAGE_S3_BUCKET', ''); - $s3Acl = 'private'; - return new S3($root, $s3AccessKey, $s3SecretKey, $s3Bucket, $s3Region, $s3Acl); - case Storage::DEVICE_DO_SPACES: - $doSpacesAccessKey = App::getEnv('_APP_STORAGE_DO_SPACES_ACCESS_KEY', ''); - $doSpacesSecretKey = App::getEnv('_APP_STORAGE_DO_SPACES_SECRET', ''); - $doSpacesRegion = App::getEnv('_APP_STORAGE_DO_SPACES_REGION', ''); - $doSpacesBucket = App::getEnv('_APP_STORAGE_DO_SPACES_BUCKET', ''); - $doSpacesAcl = 'private'; - return new DOSpaces($root, $doSpacesAccessKey, $doSpacesSecretKey, $doSpacesBucket, $doSpacesRegion, $doSpacesAcl); - case Storage::DEVICE_BACKBLAZE: - $backblazeAccessKey = App::getEnv('_APP_STORAGE_BACKBLAZE_ACCESS_KEY', ''); - $backblazeSecretKey = App::getEnv('_APP_STORAGE_BACKBLAZE_SECRET', ''); - $backblazeRegion = App::getEnv('_APP_STORAGE_BACKBLAZE_REGION', ''); - $backblazeBucket = App::getEnv('_APP_STORAGE_BACKBLAZE_BUCKET', ''); - $backblazeAcl = 'private'; - return new Backblaze($root, $backblazeAccessKey, $backblazeSecretKey, $backblazeBucket, $backblazeRegion, $backblazeAcl); - } -} - App::post('/v1/runtimes') ->desc("Create a new runtime server") ->param('runtimeId', '', new Text(64), 'Unique runtime ID.') @@ -181,7 +154,8 @@ App::post('/v1/runtimes') /** * Copy code files from source to a temporary location on the executor */ - $sourceDevice = getStorageDevice("/"); + $worker=new Worker(); + $sourceDevice = $worker->getDevice("/"); $localDevice = new Local(); $buffer = $sourceDevice->read($source); if(!$localDevice->write($tmpSource, $buffer)) { @@ -268,8 +242,9 @@ App::post('/v1/runtimes') if (!\file_exists($tmpBuild)) { throw new Exception('Something went wrong during the build process', 500); } - - $destinationDevice = getStorageDevice($destination); + + $worker=new Worker(); + $destinationDevice = $worker->getDevice($destination); $outputPath = $destinationDevice->getPath(\uniqid() . '.' . \pathinfo('code.tar.gz', PATHINFO_EXTENSION)); $buffer = $localDevice->read($tmpBuild); diff --git a/app/init.php b/app/init.php index a87f3ee3fc..e3b364b0e6 100644 --- a/app/init.php +++ b/app/init.php @@ -27,6 +27,7 @@ use Appwrite\Network\Validator\Email; use Appwrite\Network\Validator\IP; use Appwrite\Network\Validator\URL; use Appwrite\OpenSSL\OpenSSL; +use Appwrite\Resque\Worker; use Appwrite\Stats\Stats; use Appwrite\Utopia\View; use Utopia\App; @@ -807,45 +808,20 @@ App::setResource('deviceLocal', function() { }); App::setResource('deviceFiles', function($project) { - return getDevice(APP_STORAGE_UPLOADS . '/app-' . $project->getId()); + $worker=new Worker(); + return $worker->getDevice(APP_STORAGE_UPLOADS . '/app-' . $project->getId()); }, ['project']); App::setResource('deviceFunctions', function($project) { - return getDevice(APP_STORAGE_FUNCTIONS . '/app-' . $project->getId()); + $worker=new Worker(); + return $worker->getDevice(APP_STORAGE_FUNCTIONS . '/app-' . $project->getId()); }, ['project']); App::setResource('deviceBuilds', function($project) { - return getDevice(APP_STORAGE_BUILDS . '/app-' . $project->getId()); + $worker=new Worker(); + return $worker->getDevice(APP_STORAGE_BUILDS . '/app-' . $project->getId()); }, ['project']); -function getDevice($root): Device { - switch (App::getEnv('_APP_STORAGE_DEVICE', Storage::DEVICE_LOCAL)) { - case Storage::DEVICE_LOCAL:default: - return new Local($root); - case Storage::DEVICE_S3: - $s3AccessKey = App::getEnv('_APP_STORAGE_S3_ACCESS_KEY', ''); - $s3SecretKey = App::getEnv('_APP_STORAGE_S3_SECRET', ''); - $s3Region = App::getEnv('_APP_STORAGE_S3_REGION', ''); - $s3Bucket = App::getEnv('_APP_STORAGE_S3_BUCKET', ''); - $s3Acl = 'private'; - return new S3($root, $s3AccessKey, $s3SecretKey, $s3Bucket, $s3Region, $s3Acl); - case Storage::DEVICE_DO_SPACES: - $doSpacesAccessKey = App::getEnv('_APP_STORAGE_DO_SPACES_ACCESS_KEY', ''); - $doSpacesSecretKey = App::getEnv('_APP_STORAGE_DO_SPACES_SECRET', ''); - $doSpacesRegion = App::getEnv('_APP_STORAGE_DO_SPACES_REGION', ''); - $doSpacesBucket = App::getEnv('_APP_STORAGE_DO_SPACES_BUCKET', ''); - $doSpacesAcl = 'private'; - return new DOSpaces($root, $doSpacesAccessKey, $doSpacesSecretKey, $doSpacesBucket, $doSpacesRegion, $doSpacesAcl); - case Storage::DEVICE_BACKBLAZE: - $backblazeAccessKey = App::getEnv('_APP_STORAGE_BACKBLAZE_ACCESS_KEY', ''); - $backblazeSecretKey = App::getEnv('_APP_STORAGE_BACKBLAZE_SECRET', ''); - $backblazeRegion = App::getEnv('_APP_STORAGE_BACKBLAZE_REGION', ''); - $backblazeBucket = App::getEnv('_APP_STORAGE_BACKBLAZE_BUCKET', ''); - $backblazeAcl = 'private'; - return new Backblaze($root, $backblazeAccessKey, $backblazeSecretKey, $backblazeBucket, $backblazeRegion, $backblazeAcl); - } -} - App::setResource('mode', function($request) { /** @var Appwrite\Utopia\Request $request */ diff --git a/app/workers/deletes.php b/app/workers/deletes.php index 441aebf728..b365adea81 100644 --- a/app/workers/deletes.php +++ b/app/workers/deletes.php @@ -545,34 +545,8 @@ class DeletesV1 extends Worker $dbForProject = $this->getProjectDB($projectId); $dbForProject->deleteCollection('bucket_' . $document->getInternalId()); - $device = new Local(APP_STORAGE_UPLOADS.'/app-'.$projectId); - - switch (App::getEnv('_APP_STORAGE_DEVICE', Storage::DEVICE_LOCAL)) { - case Storage::DEVICE_S3: - $s3AccessKey = App::getEnv('_APP_STORAGE_S3_ACCESS_KEY', ''); - $s3SecretKey = App::getEnv('_APP_STORAGE_S3_SECRET', ''); - $s3Region = App::getEnv('_APP_STORAGE_S3_REGION', ''); - $s3Bucket = App::getEnv('_APP_STORAGE_S3_BUCKET', ''); - $s3Acl = 'private'; - $device = new S3(APP_STORAGE_UPLOADS . '/app-' . $projectId, $s3AccessKey, $s3SecretKey, $s3Bucket, $s3Region, $s3Acl); - break; - case Storage::DEVICE_DO_SPACES: - $doSpacesAccessKey = App::getEnv('_APP_STORAGE_DO_SPACES_ACCESS_KEY', ''); - $doSpacesSecretKey = App::getEnv('_APP_STORAGE_DO_SPACES_SECRET', ''); - $doSpacesRegion = App::getEnv('_APP_STORAGE_DO_SPACES_REGION', ''); - $doSpacesBucket = App::getEnv('_APP_STORAGE_DO_SPACES_BUCKET', ''); - $doSpacesAcl = 'private'; - $device = new DOSpaces(APP_STORAGE_UPLOADS . '/app-' . $projectId, $doSpacesAccessKey, $doSpacesSecretKey, $doSpacesBucket, $doSpacesRegion, $doSpacesAcl); - break; - case Storage::DEVICE_BACKBLAZE: - $backblazeAccessKey = App::getEnv('_APP_STORAGE_BACKBLAZE_ACCESS_KEY', ''); - $backblazeSecretKey = App::getEnv('_APP_STORAGE_BACKBLAZE_SECRET', ''); - $backblazeRegion = App::getEnv('_APP_STORAGE_BACKBLAZE_REGION', ''); - $backblazeBucket = App::getEnv('_APP_STORAGE_BACKBLAZE_BUCKET', ''); - $backblazeAcl = 'private'; - $device= new Backblaze(APP_STORAGE_UPLOADS . '/app-' . $projectId, $backblazeAccessKey, $backblazeSecretKey, $backblazeBucket, $backblazeRegion, $backblazeAcl); - break; - } + $worker=new Worker(); + $device=$worker->getDevice(APP_STORAGE_UPLOADS.'/app-'.$projectId); $device->deletePath($document->getId()); } diff --git a/src/Appwrite/Resque/Worker.php b/src/Appwrite/Resque/Worker.php index 34a37dbc5e..40fad72102 100644 --- a/src/Appwrite/Resque/Worker.php +++ b/src/Appwrite/Resque/Worker.php @@ -260,7 +260,7 @@ abstract class Worker * @param string $root path of the device * @return Device */ - private function getDevice($root): Device + public function getDevice($root): Device { switch (App::getEnv('_APP_STORAGE_DEVICE', Storage::DEVICE_LOCAL)) { case Storage::DEVICE_LOCAL:default: From a45fab4e43e8eef91230d50af1e4da0ae2692382 Mon Sep 17 00:00:00 2001 From: Everly Precia Suresh Date: Thu, 12 May 2022 22:01:53 +0000 Subject: [PATCH 13/38] better way to initialize storage libs --- app/executor.php | 37 ++++++++++++++++++++++++++++------ app/init.php | 44 +++++++++++++++++++++++++++++++---------- app/workers/deletes.php | 3 +-- 3 files changed, 66 insertions(+), 18 deletions(-) diff --git a/app/executor.php b/app/executor.php index 6fc1aaf691..3d827f0a24 100644 --- a/app/executor.php +++ b/app/executor.php @@ -2,7 +2,6 @@ require_once __DIR__ . '/../vendor/autoload.php'; use Appwrite\Runtimes\Runtimes; -use Appwrite\Resque\Worker; use Swoole\ConnectionPool; use Swoole\Http\Request as SwooleRequest; use Swoole\Http\Response as SwooleResponse; @@ -114,6 +113,34 @@ function logError(Throwable $error, string $action, Utopia\Route $route = null) Console::error('[Error] Line: ' . $error->getLine()); }; +function getStorageDevice($root): Device { + switch (App::getEnv('_APP_STORAGE_DEVICE', Storage::DEVICE_LOCAL)) { + case Storage::DEVICE_LOCAL:default: + return new Local($root); + case Storage::DEVICE_S3: + $s3AccessKey = App::getEnv('_APP_STORAGE_S3_ACCESS_KEY', ''); + $s3SecretKey = App::getEnv('_APP_STORAGE_S3_SECRET', ''); + $s3Region = App::getEnv('_APP_STORAGE_S3_REGION', ''); + $s3Bucket = App::getEnv('_APP_STORAGE_S3_BUCKET', ''); + $s3Acl = 'private'; + return new S3($root, $s3AccessKey, $s3SecretKey, $s3Bucket, $s3Region, $s3Acl); + case Storage::DEVICE_DO_SPACES: + $doSpacesAccessKey = App::getEnv('_APP_STORAGE_DO_SPACES_ACCESS_KEY', ''); + $doSpacesSecretKey = App::getEnv('_APP_STORAGE_DO_SPACES_SECRET', ''); + $doSpacesRegion = App::getEnv('_APP_STORAGE_DO_SPACES_REGION', ''); + $doSpacesBucket = App::getEnv('_APP_STORAGE_DO_SPACES_BUCKET', ''); + $doSpacesAcl = 'private'; + return new DOSpaces($root, $doSpacesAccessKey, $doSpacesSecretKey, $doSpacesBucket, $doSpacesRegion, $doSpacesAcl); + case Storage::DEVICE_BACKBLAZE: + $backblazeAccessKey = App::getEnv('_APP_STORAGE_BACKBLAZE_ACCESS_KEY', ''); + $backblazeSecretKey = App::getEnv('_APP_STORAGE_BACKBLAZE_SECRET', ''); + $backblazeRegion = App::getEnv('_APP_STORAGE_BACKBLAZE_REGION', ''); + $backblazeBucket = App::getEnv('_APP_STORAGE_BACKBLAZE_BUCKET', ''); + $backblazeAcl = 'private'; + return new Backblaze($root, $backblazeAccessKey, $backblazeSecretKey, $backblazeBucket, $backblazeRegion, $backblazeAcl); + } +} + App::post('/v1/runtimes') ->desc("Create a new runtime server") ->param('runtimeId', '', new Text(64), 'Unique runtime ID.') @@ -154,8 +181,7 @@ App::post('/v1/runtimes') /** * Copy code files from source to a temporary location on the executor */ - $worker=new Worker(); - $sourceDevice = $worker->getDevice("/"); + $sourceDevice = getStorageDevice("/"); $localDevice = new Local(); $buffer = $sourceDevice->read($source); if(!$localDevice->write($tmpSource, $buffer)) { @@ -242,9 +268,8 @@ App::post('/v1/runtimes') if (!\file_exists($tmpBuild)) { throw new Exception('Something went wrong during the build process', 500); } - - $worker=new Worker(); - $destinationDevice = $worker->getDevice($destination); + + $destinationDevice = getStorageDevice($destination); $outputPath = $destinationDevice->getPath(\uniqid() . '.' . \pathinfo('code.tar.gz', PATHINFO_EXTENSION)); $buffer = $localDevice->read($tmpBuild); diff --git a/app/init.php b/app/init.php index e3b364b0e6..170542effa 100644 --- a/app/init.php +++ b/app/init.php @@ -27,7 +27,6 @@ use Appwrite\Network\Validator\Email; use Appwrite\Network\Validator\IP; use Appwrite\Network\Validator\URL; use Appwrite\OpenSSL\OpenSSL; -use Appwrite\Resque\Worker; use Appwrite\Stats\Stats; use Appwrite\Utopia\View; use Utopia\App; @@ -53,10 +52,10 @@ use Swoole\Database\RedisPool; use Utopia\Database\Query; use Utopia\Storage\Device; use Utopia\Storage\Storage; -use Utopia\Storage\Device\Local; use Utopia\Storage\Device\Backblaze; -use Utopia\Storage\Device\S3; use Utopia\Storage\Device\DOSpaces; +use Utopia\Storage\Device\Local; +use Utopia\Storage\Device\S3; const APP_NAME = 'Appwrite'; const APP_DOMAIN = 'appwrite.io'; @@ -808,20 +807,45 @@ App::setResource('deviceLocal', function() { }); App::setResource('deviceFiles', function($project) { - $worker=new Worker(); - return $worker->getDevice(APP_STORAGE_UPLOADS . '/app-' . $project->getId()); + return getDevice(APP_STORAGE_UPLOADS . '/app-' . $project->getId()); }, ['project']); App::setResource('deviceFunctions', function($project) { - $worker=new Worker(); - return $worker->getDevice(APP_STORAGE_FUNCTIONS . '/app-' . $project->getId()); + return getDevice(APP_STORAGE_FUNCTIONS . '/app-' . $project->getId()); }, ['project']); App::setResource('deviceBuilds', function($project) { - $worker=new Worker(); - return $worker->getDevice(APP_STORAGE_BUILDS . '/app-' . $project->getId()); + return getDevice(APP_STORAGE_BUILDS . '/app-' . $project->getId()); }, ['project']); +function getDevice($root): Device { + switch (App::getEnv('_APP_STORAGE_DEVICE', Storage::DEVICE_LOCAL)) { + case Storage::DEVICE_LOCAL:default: + return new Local($root); + case Storage::DEVICE_S3: + $s3AccessKey = App::getEnv('_APP_STORAGE_S3_ACCESS_KEY', ''); + $s3SecretKey = App::getEnv('_APP_STORAGE_S3_SECRET', ''); + $s3Region = App::getEnv('_APP_STORAGE_S3_REGION', ''); + $s3Bucket = App::getEnv('_APP_STORAGE_S3_BUCKET', ''); + $s3Acl = 'private'; + return new S3($root, $s3AccessKey, $s3SecretKey, $s3Bucket, $s3Region, $s3Acl); + case Storage::DEVICE_DO_SPACES: + $doSpacesAccessKey = App::getEnv('_APP_STORAGE_DO_SPACES_ACCESS_KEY', ''); + $doSpacesSecretKey = App::getEnv('_APP_STORAGE_DO_SPACES_SECRET', ''); + $doSpacesRegion = App::getEnv('_APP_STORAGE_DO_SPACES_REGION', ''); + $doSpacesBucket = App::getEnv('_APP_STORAGE_DO_SPACES_BUCKET', ''); + $doSpacesAcl = 'private'; + return new DOSpaces($root, $doSpacesAccessKey, $doSpacesSecretKey, $doSpacesBucket, $doSpacesRegion, $doSpacesAcl); + case Storage::DEVICE_BACKBLAZE: + $backblazeAccessKey = App::getEnv('_APP_STORAGE_BACKBLAZE_ACCESS_KEY', ''); + $backblazeSecretKey = App::getEnv('_APP_STORAGE_BACKBLAZE_SECRET', ''); + $backblazeRegion = App::getEnv('_APP_STORAGE_BACKBLAZE_REGION', ''); + $backblazeBucket = App::getEnv('_APP_STORAGE_BACKBLAZE_BUCKET', ''); + $backblazeAcl = 'private'; + return new Backblaze($root, $backblazeAccessKey, $backblazeSecretKey, $backblazeBucket, $backblazeRegion, $backblazeAcl); + } +} + App::setResource('mode', function($request) { /** @var Appwrite\Utopia\Request $request */ @@ -836,4 +860,4 @@ App::setResource('mode', function($request) { App::setResource('geodb', function($register) { /** @var Utopia\Registry\Registry $register */ return $register->get('geodb'); -}, ['register']); +}, ['register']); \ No newline at end of file diff --git a/app/workers/deletes.php b/app/workers/deletes.php index b365adea81..f6d2a94960 100644 --- a/app/workers/deletes.php +++ b/app/workers/deletes.php @@ -545,8 +545,7 @@ class DeletesV1 extends Worker $dbForProject = $this->getProjectDB($projectId); $dbForProject->deleteCollection('bucket_' . $document->getInternalId()); - $worker=new Worker(); - $device=$worker->getDevice(APP_STORAGE_UPLOADS.'/app-'.$projectId); + $device=$this->getDevice(APP_STORAGE_UPLOADS.'/app-'.$projectId); $device->deletePath($document->getId()); } From f9da67ec3ea2d23c6b52f10b6dd14db5f58b328b Mon Sep 17 00:00:00 2001 From: Everly Precia Suresh Date: Thu, 12 May 2022 22:33:08 +0000 Subject: [PATCH 14/38] format code --- app/init.php | 2 +- app/workers/deletes.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/init.php b/app/init.php index 170542effa..adbcab4aec 100644 --- a/app/init.php +++ b/app/init.php @@ -860,4 +860,4 @@ App::setResource('mode', function($request) { App::setResource('geodb', function($register) { /** @var Utopia\Registry\Registry $register */ return $register->get('geodb'); -}, ['register']); \ No newline at end of file +}, ['register']); diff --git a/app/workers/deletes.php b/app/workers/deletes.php index f6d2a94960..caac401f4e 100644 --- a/app/workers/deletes.php +++ b/app/workers/deletes.php @@ -545,7 +545,7 @@ class DeletesV1 extends Worker $dbForProject = $this->getProjectDB($projectId); $dbForProject->deleteCollection('bucket_' . $document->getInternalId()); - $device=$this->getDevice(APP_STORAGE_UPLOADS.'/app-'.$projectId); + $device = $this->getDevice(APP_STORAGE_UPLOADS.'/app-'.$projectId); $device->deletePath($document->getId()); } From 36873be7ea6f4cf3d03b6d5c4d1fbedf4c2578d8 Mon Sep 17 00:00:00 2001 From: Everly Precia Suresh Date: Mon, 16 May 2022 09:31:09 +0000 Subject: [PATCH 15/38] add default region value for linode --- app/config/variables.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/config/variables.php b/app/config/variables.php index 91be780fa2..961b4abd6f 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -562,7 +562,7 @@ return [ 'name' => '_APP_STORAGE_LINODE_REGION', 'description' => 'Linode object storage region. Required when storage adapter is set to Linode. You can find your region info from your Linode console.', 'introduction' => '0.13.0', - 'default' => 'us-eas-1', + 'default' => 'eu-central-1', 'required' => false, 'question' => '', ], From c329b487a9ed4c5c4d6616fc817ff085e90e2c3e Mon Sep 17 00:00:00 2001 From: Everly Precia Suresh Date: Mon, 16 May 2022 10:05:31 +0000 Subject: [PATCH 16/38] remove uneccessary use statement --- app/config/variables.php | 2 +- app/controllers/shared/api.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/config/variables.php b/app/config/variables.php index 396a120cd5..6df009c4fc 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -440,7 +440,7 @@ return [ ], [ 'name' => '_APP_STORAGE_DEVICE', - 'description' => 'Select default storage device. The default value is \'Local\'. List of supported adapters are \'Local\', \'S3\', \'DOSpaces\', \'Backblaze\' and \'Linode\'.', + 'description' => 'Select default storage device. The default value is \'Local\'. List of supported adapters are \'Local\', \'S3\', \'DOSpaces\', \'Backblaze\', \'Linode\' and \'Wasabi\'.', 'introduction' => '0.13.0', 'default' => 'Local', 'required' => false, diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 218a2e339c..c5c6da6167 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -8,7 +8,6 @@ use Utopia\Abuse\Abuse; use Utopia\Abuse\Adapters\TimeLimit; use Utopia\Database\Document; use Utopia\Storage\Device\DOSpaces; -use Utopia\Storage\Device\Backblaze; use Utopia\Database\Validator\Authorization; use Utopia\Storage\Device\Local; use Utopia\Storage\Device\S3; From 3dcf5704d2ce3c9af45919a2914497cf830cd567 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 18 May 2022 15:18:12 +0200 Subject: [PATCH 17/38] fix: installation overriding default env variables --- app/tasks/install.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/tasks/install.php b/app/tasks/install.php index 979e9b4697..77210a0c15 100644 --- a/app/tasks/install.php +++ b/app/tasks/install.php @@ -92,6 +92,7 @@ $cli $env = $service->getEnvironment()->list(); foreach ($env as $key => $value) { + if (is_null($value)) continue; foreach($vars as &$var) { if($var['name'] === $key) { $var['default'] = $value; @@ -108,6 +109,7 @@ $cli $env = new Env($data); foreach ($env->list() as $key => $value) { + if (is_null($value)) continue; foreach($vars as &$var) { if($var['name'] === $key) { $var['default'] = $value; From bef1a902ee4a91daaf6f637c79d8a271638c2715 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 18 May 2022 16:31:29 +0200 Subject: [PATCH 18/38] fix: scheduled functions execution --- app/workers/functions.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/workers/functions.php b/app/workers/functions.php index b621d95f43..daebd41cce 100644 --- a/app/workers/functions.php +++ b/app/workers/functions.php @@ -94,6 +94,7 @@ class FunctionsV1 extends Worker $user = new Document($this->args['user'] ?? []); $project = new Document($this->args['project'] ?? []); $execution = new Document($this->args['execution'] ?? []); + $function = new Document($this->args['function'] ?? []); switch ($type) { case 'http': @@ -117,8 +118,6 @@ class FunctionsV1 extends Worker case 'schedule': $scheduleOriginal = $execution->getAttribute('scheduleOriginal', ''); - $function = Authorization::skip(fn () => $database->getDocument('functions', $execution->getAttribute('functionId'))); - /* * 1. Get Original Task * 2. Check for updates @@ -133,6 +132,8 @@ class FunctionsV1 extends Worker */ // Reschedule + $function = Authorization::skip(fn () => $database->getDocument('functions', $function->getId())); + if (empty($function->getId())) { throw new Exception('Function not found (' . $function->getId() . ')'); } From eaecea05f97e313152f68ac093a1eed3f8964a34 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 18 May 2022 16:47:44 +0200 Subject: [PATCH 19/38] fix: leftovers --- app/workers/functions.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/workers/functions.php b/app/workers/functions.php index daebd41cce..aa19591e2b 100644 --- a/app/workers/functions.php +++ b/app/workers/functions.php @@ -193,6 +193,7 @@ class FunctionsV1 extends Worker string $jwt = null ) { + $user ??= new Document(); $functionId = $function->getId(); $deploymentId = $function->getAttribute('deployment', ''); @@ -228,12 +229,12 @@ class FunctionsV1 extends Worker /** Create execution or update execution status */ $execution = Authorization::skip(function () use ($dbForProject, &$executionId, $functionId, $deploymentId, $trigger, $user) { - $execution = $dbForProject->getDocument('executions', $executionId); + $execution = $dbForProject->getDocument('executions', $executionId ?? ''); if ($execution->isEmpty()) { $executionId = $dbForProject->getId(); $execution = $dbForProject->createDocument('executions', new Document([ '$id' => $executionId, - '$read' => $user->getId() ? ['user:' . $user->getId()] : [], + '$read' => $user->isEmpty() ? [] : ['user:' . $user->getId()], '$write' => [], 'dateCreated' => time(), 'functionId' => $functionId, @@ -282,7 +283,7 @@ class FunctionsV1 extends Worker path: $build->getAttribute('outputPath', ''), vars: $vars, entrypoint: $deployment->getAttribute('entrypoint', ''), - data: $vars['APPWRITE_FUNCTION_DATA'], + data: $vars['APPWRITE_FUNCTION_DATA'] ?? '', runtime: $function->getAttribute('runtime', ''), timeout: $function->getAttribute('timeout', 0), baseImage: $runtime['image'] From a44a951285e35196f7b51c30409ce94eaa328156 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 18 May 2022 17:09:06 +0200 Subject: [PATCH 20/38] chore: prepare 0.14.1 release --- CHANGES.md | 8 ++++++++ README-CN.md | 6 +++--- README.md | 6 +++--- app/init.php | 4 ++-- src/Appwrite/Migration/Migration.php | 1 + 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 55a2764393..07976140f3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,11 @@ +# Version 0.14.1 + +## Bugs +- Fixed scheduled Cloud Functions execution with cron-job by @TorstenDittmann in https://github.com/appwrite/appwrite/pull/3245 +- Fixed missing runtime icons by @TorstenDittmann in https://github.com/appwrite/appwrite/pull/3234 +- Fixed Google OAuth by @Meldiron in https://github.com/appwrite/appwrite/pull/3236 +- Fixed allowing `localhost` as the main domain by @Meldiron in https://github.com/appwrite/appwrite/pull/3237 +- Fixed Installation overriding default env variables by @TorstenDittmann in https://github.com/appwrite/appwrite/pull/3241 # Version 0.14.0 ## Features diff --git a/README-CN.md b/README-CN.md index 826163ee2b..f95bd12f93 100644 --- a/README-CN.md +++ b/README-CN.md @@ -59,7 +59,7 @@ docker run -it --rm \ --volume /var/run/docker.sock:/var/run/docker.sock \ --volume "$(pwd)"/appwrite:/usr/src/code/appwrite:rw \ --entrypoint="install" \ - appwrite/appwrite:0.14.0 + appwrite/appwrite:0.14.1 ``` ### Windows @@ -71,7 +71,7 @@ docker run -it --rm ^ --volume //var/run/docker.sock:/var/run/docker.sock ^ --volume "%cd%"/appwrite:/usr/src/code/appwrite:rw ^ --entrypoint="install" ^ - appwrite/appwrite:0.14.0 + appwrite/appwrite:0.14.1 ``` #### PowerShell @@ -81,7 +81,7 @@ docker run -it --rm , --volume /var/run/docker.sock:/var/run/docker.sock , --volume ${pwd}/appwrite:/usr/src/code/appwrite:rw , --entrypoint="install" , - appwrite/appwrite:0.14.0 + appwrite/appwrite:0.14.1 ``` 运行后,可以在浏览器上访问 http://localhost 找到 Appwrite 控制台。在非 Linux 的本机主机上完成安装后,服务器可能需要几分钟才能启动。 diff --git a/README.md b/README.md index 7ca23330ec..5254547afa 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ docker run -it --rm \ --volume /var/run/docker.sock:/var/run/docker.sock \ --volume "$(pwd)"/appwrite:/usr/src/code/appwrite:rw \ --entrypoint="install" \ - appwrite/appwrite:0.14.0 + appwrite/appwrite:0.14.1 ``` ### Windows @@ -74,7 +74,7 @@ docker run -it --rm ^ --volume //var/run/docker.sock:/var/run/docker.sock ^ --volume "%cd%"/appwrite:/usr/src/code/appwrite:rw ^ --entrypoint="install" ^ - appwrite/appwrite:0.14.0 + appwrite/appwrite:0.14.1 ``` #### PowerShell @@ -84,7 +84,7 @@ docker run -it --rm , --volume /var/run/docker.sock:/var/run/docker.sock , --volume ${pwd}/appwrite:/usr/src/code/appwrite:rw , --entrypoint="install" , - appwrite/appwrite:0.14.0 + appwrite/appwrite:0.14.1 ``` Once the Docker installation completes, go to http://localhost to access the Appwrite console from your browser. Please note that on non-Linux native hosts, the server might take a few minutes to start after installation completes. diff --git a/app/init.php b/app/init.php index 37dbf7d20b..7583897d0a 100644 --- a/app/init.php +++ b/app/init.php @@ -74,8 +74,8 @@ const APP_LIMIT_ANTIVIRUS = 20000000; //20MB const APP_LIMIT_ENCRYPTION = 20000000; //20MB const APP_LIMIT_COMPRESSION = 20000000; //20MB const APP_LIMIT_ARRAY_PARAMS_SIZE = 100; // Default maximum of how many elements can there be in API parameter that expects array value -const APP_CACHE_BUSTER = 304; -const APP_VERSION_STABLE = '0.14.0'; +const APP_CACHE_BUSTER = 305; +const APP_VERSION_STABLE = '0.14.1'; const APP_DATABASE_ATTRIBUTE_EMAIL = 'email'; const APP_DATABASE_ATTRIBUTE_ENUM = 'enum'; const APP_DATABASE_ATTRIBUTE_IP = 'ip'; diff --git a/src/Appwrite/Migration/Migration.php b/src/Appwrite/Migration/Migration.php index b5c32733ea..b479a42262 100644 --- a/src/Appwrite/Migration/Migration.php +++ b/src/Appwrite/Migration/Migration.php @@ -43,6 +43,7 @@ abstract class Migration '0.13.3' => 'V12', '0.13.4' => 'V12', '0.14.0' => 'V13', + '0.14.1' => 'V13', ]; /** From 637d999fff4189e43d5c28ddaab21b7029f8e4cd Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 18 May 2022 17:13:52 +0200 Subject: [PATCH 21/38] Update CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 07976140f3..bc0f0fa864 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ - Fixed Google OAuth by @Meldiron in https://github.com/appwrite/appwrite/pull/3236 - Fixed allowing `localhost` as the main domain by @Meldiron in https://github.com/appwrite/appwrite/pull/3237 - Fixed Installation overriding default env variables by @TorstenDittmann in https://github.com/appwrite/appwrite/pull/3241 + # Version 0.14.0 ## Features From cd5fd650cc53224b5052bc0d272ee34447cca062 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 18 May 2022 17:17:18 +0200 Subject: [PATCH 22/38] Update CHANGES.md --- CHANGES.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index bc0f0fa864..9aab3afb80 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,11 +1,11 @@ # Version 0.14.1 ## Bugs -- Fixed scheduled Cloud Functions execution with cron-job by @TorstenDittmann in https://github.com/appwrite/appwrite/pull/3245 -- Fixed missing runtime icons by @TorstenDittmann in https://github.com/appwrite/appwrite/pull/3234 -- Fixed Google OAuth by @Meldiron in https://github.com/appwrite/appwrite/pull/3236 -- Fixed allowing `localhost` as the main domain by @Meldiron in https://github.com/appwrite/appwrite/pull/3237 -- Fixed Installation overriding default env variables by @TorstenDittmann in https://github.com/appwrite/appwrite/pull/3241 +* Fixed scheduled Cloud Functions execution with cron-job by @TorstenDittmann in https://github.com/appwrite/appwrite/pull/3245 +* Fixed missing runtime icons by @TorstenDittmann in https://github.com/appwrite/appwrite/pull/3234 +* Fixed Google OAuth by @Meldiron in https://github.com/appwrite/appwrite/pull/3236 +* Fixed certificate generation when hostname was set to 'localhost' by @Meldiron in https://github.com/appwrite/appwrite/pull/3237 +* Fixed Installation overriding default env variables by @TorstenDittmann in https://github.com/appwrite/appwrite/pull/3241 # Version 0.14.0 From 27be739d5e4a41bfc6658efed7b087a0f57efc0b Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Thu, 19 May 2022 11:29:01 +0200 Subject: [PATCH 23/38] feat: improve migration speed --- src/Appwrite/Migration/Migration.php | 50 +++++++++------------------- 1 file changed, 15 insertions(+), 35 deletions(-) diff --git a/src/Appwrite/Migration/Migration.php b/src/Appwrite/Migration/Migration.php index b479a42262..844923993f 100644 --- a/src/Appwrite/Migration/Migration.php +++ b/src/Appwrite/Migration/Migration.php @@ -124,21 +124,7 @@ abstract class Migration $old = $document->getArrayCopy(); $new = call_user_func($callback, $document); - foreach ($document as &$attr) { - if ($attr instanceof Document) { - $attr = call_user_func($callback, $attr); - } - - if (\is_array($attr)) { - foreach ($attr as &$child) { - if ($child instanceof Document) { - $child = call_user_func($callback, $child); - } - } - } - } - - if (!$this->check_diff_multi($new->getArrayCopy(), $old)) { + if (!$this->hasDifference($new->getArrayCopy(), $old)) { return; } @@ -170,32 +156,26 @@ abstract class Migration * * @param array $array1 * @param array $array2 - * @return array + * @return bool */ - public function check_diff_multi(array $array1, array $array2): array + public function hasDifference(array $array1, array $array2): bool { - $result = array(); - - foreach ($array1 as $key => $val) { - if (is_array($val) && isset($array2[$key])) { - $tmp = $this->check_diff_multi($val, $array2[$key]); - if ($tmp) { - $result[$key] = $tmp; + foreach ($array1 as $key => $value) { + if (is_array($value)) { + if (!isset($array2[$key]) || !is_array($array2[$key])) { + return true; + } else { + $new_diff = $this->hasDifference($value, $array2[$key]); + if ($new_diff) { + return true; + } } - } elseif (!isset($array2[$key])) { - $result[$key] = null; - } elseif ($val !== $array2[$key]) { - $result[$key] = $array2[$key]; - } - - if (isset($array2[$key])) { - unset($array2[$key]); + } elseif (!array_key_exists($key, $array2) || $array2[$key] !== $value) { + return true; } } - $result = array_merge($result, $array2); - - return $result; + return false; } /** From 4cbf3b1e12079fec4c4a723234ceb63e8dec0f28 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Thu, 19 May 2022 11:49:48 +0200 Subject: [PATCH 24/38] push debug logs --- src/Appwrite/Migration/Migration.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/Migration/Migration.php b/src/Appwrite/Migration/Migration.php index 844923993f..14e931c316 100644 --- a/src/Appwrite/Migration/Migration.php +++ b/src/Appwrite/Migration/Migration.php @@ -16,7 +16,7 @@ abstract class Migration /** * @var int */ - protected int $limit = 100; + protected int $limit = 250; /** * @var Document @@ -108,7 +108,9 @@ abstract class Migration Console::log('Migrating Collection ' . $collection['$id'] . ':'); do { + $start = microtime(true); $documents = $this->projectDB->find($collection['$id'], limit: $this->limit, cursor: $nextDocument); + var_dump("Fetching documents took " . microtime(true) - $start); $count = count($documents); $sum += $count; @@ -121,10 +123,17 @@ abstract class Migration return; } + $start = microtime(true); + $old = $document->getArrayCopy(); $new = call_user_func($callback, $document); + var_dump("migration took " . microtime(true) - $start); - if (!$this->hasDifference($new->getArrayCopy(), $old)) { + $start = microtime(true); + $diff = !$this->hasDifference($new->getArrayCopy(), $old); + var_dump("Diff took " . microtime(true) - $start); + + if (!$diff) { return; } From 2fcbaee0b65dd66d07deff5feb015954d8bca8ee Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Thu, 19 May 2022 11:53:06 +0200 Subject: [PATCH 25/38] Revert "push debug logs" This reverts commit 4cbf3b1e12079fec4c4a723234ceb63e8dec0f28. --- src/Appwrite/Migration/Migration.php | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/Appwrite/Migration/Migration.php b/src/Appwrite/Migration/Migration.php index 14e931c316..844923993f 100644 --- a/src/Appwrite/Migration/Migration.php +++ b/src/Appwrite/Migration/Migration.php @@ -16,7 +16,7 @@ abstract class Migration /** * @var int */ - protected int $limit = 250; + protected int $limit = 100; /** * @var Document @@ -108,9 +108,7 @@ abstract class Migration Console::log('Migrating Collection ' . $collection['$id'] . ':'); do { - $start = microtime(true); $documents = $this->projectDB->find($collection['$id'], limit: $this->limit, cursor: $nextDocument); - var_dump("Fetching documents took " . microtime(true) - $start); $count = count($documents); $sum += $count; @@ -123,17 +121,10 @@ abstract class Migration return; } - $start = microtime(true); - $old = $document->getArrayCopy(); $new = call_user_func($callback, $document); - var_dump("migration took " . microtime(true) - $start); - $start = microtime(true); - $diff = !$this->hasDifference($new->getArrayCopy(), $old); - var_dump("Diff took " . microtime(true) - $start); - - if (!$diff) { + if (!$this->hasDifference($new->getArrayCopy(), $old)) { return; } From b426ec00a0422793a551f98a299c1d50f96bbd6c Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 19 May 2022 15:55:01 +0545 Subject: [PATCH 26/38] package update --- composer.json | 2 +- composer.lock | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 1cd1236d0f..e86553cbe6 100644 --- a/composer.json +++ b/composer.json @@ -71,7 +71,7 @@ } ], "require-dev": { - "appwrite/sdk-generator": "0.18.6", + "appwrite/sdk-generator": "0.18.7", "phpunit/phpunit": "9.5.20", "swoole/ide-helper": "4.8.9", "textalk/websocket": "1.5.7", diff --git a/composer.lock b/composer.lock index 69aadee3ae..5c8150a587 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "69e0c12a4c4b22cf17727f5b8833b1ac", + "content-hash": "b2284ecd9bc4b0b69c9d781ba781328d", "packages": [ { "name": "adhocore/jwt", @@ -3075,16 +3075,16 @@ }, { "name": "appwrite/sdk-generator", - "version": "0.18.6", + "version": "0.18.7", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "c0914d9f4047fd7b86112c289d98e9161cf9d0b0" + "reference": "29785df4e810aa8766815aee9f255b2446c4e194" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/c0914d9f4047fd7b86112c289d98e9161cf9d0b0", - "reference": "c0914d9f4047fd7b86112c289d98e9161cf9d0b0", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/29785df4e810aa8766815aee9f255b2446c4e194", + "reference": "29785df4e810aa8766815aee9f255b2446c4e194", "shasum": "" }, "require": { @@ -3119,9 +3119,9 @@ "description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms", "support": { "issues": "https://github.com/appwrite/sdk-generator/issues", - "source": "https://github.com/appwrite/sdk-generator/tree/0.18.6" + "source": "https://github.com/appwrite/sdk-generator/tree/0.18.7" }, - "time": "2022-05-17T15:09:23+00:00" + "time": "2022-05-19T09:55:58+00:00" }, { "name": "composer/pcre", From 8777d534eb7c1707cf6cb3831178420dfc108ecb Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 19 May 2022 16:00:50 +0545 Subject: [PATCH 27/38] update config and dart changelog --- app/config/platforms.php | 6 +++--- docs/sdks/dart/CHANGELOG.md | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/config/platforms.php b/app/config/platforms.php index 53d64c34e4..3219ba06c3 100644 --- a/app/config/platforms.php +++ b/app/config/platforms.php @@ -15,7 +15,7 @@ return [ [ 'key' => 'web', 'name' => 'Web', - 'version' => '8.0.0', + 'version' => '8.0.1', 'url' => 'https://github.com/appwrite/sdk-for-web', 'package' => 'https://www.npmjs.com/package/appwrite', 'enabled' => true, @@ -180,7 +180,7 @@ return [ [ 'key' => 'cli', 'name' => 'Command Line', - 'version' => '0.17.0', + 'version' => '0.17.1', 'url' => 'https://github.com/appwrite/sdk-for-cli', 'package' => 'https://www.npmjs.com/package/appwrite-cli', 'enabled' => true, @@ -352,7 +352,7 @@ return [ [ 'key' => 'dart', 'name' => 'Dart', - 'version' => '5.0.0', + 'version' => '5.0.1', 'url' => 'https://github.com/appwrite/sdk-for-dart', 'package' => 'https://pub.dev/packages/dart_appwrite', 'enabled' => true, diff --git a/docs/sdks/dart/CHANGELOG.md b/docs/sdks/dart/CHANGELOG.md index 7103bfa733..319398a285 100644 --- a/docs/sdks/dart/CHANGELOG.md +++ b/docs/sdks/dart/CHANGELOG.md @@ -1,3 +1,6 @@ +## 5.0.1 +* Code formatting fix + ## 5.0.0 * Support for Appwrite 0.14 * **BREAKING** `account.delete()` -> `account.updateStatus()` From eca1626beaf7c4dbc7a07438f6a81f89e3ec8e2b Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 19 May 2022 16:22:32 +0545 Subject: [PATCH 28/38] update sdk generator --- composer.json | 2 +- composer.lock | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index e86553cbe6..a228be5a7a 100644 --- a/composer.json +++ b/composer.json @@ -71,7 +71,7 @@ } ], "require-dev": { - "appwrite/sdk-generator": "0.18.7", + "appwrite/sdk-generator": "0.18.8", "phpunit/phpunit": "9.5.20", "swoole/ide-helper": "4.8.9", "textalk/websocket": "1.5.7", diff --git a/composer.lock b/composer.lock index 5c8150a587..e9d8a59f21 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b2284ecd9bc4b0b69c9d781ba781328d", + "content-hash": "5e016b74b013e85c65fba2e46e5dc98a", "packages": [ { "name": "adhocore/jwt", @@ -3075,16 +3075,16 @@ }, { "name": "appwrite/sdk-generator", - "version": "0.18.7", + "version": "0.18.8", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "29785df4e810aa8766815aee9f255b2446c4e194" + "reference": "8ba45dfb74ff6062f96c0e4d10d7c4fae94768b1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/29785df4e810aa8766815aee9f255b2446c4e194", - "reference": "29785df4e810aa8766815aee9f255b2446c4e194", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/8ba45dfb74ff6062f96c0e4d10d7c4fae94768b1", + "reference": "8ba45dfb74ff6062f96c0e4d10d7c4fae94768b1", "shasum": "" }, "require": { @@ -3119,9 +3119,9 @@ "description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms", "support": { "issues": "https://github.com/appwrite/sdk-generator/issues", - "source": "https://github.com/appwrite/sdk-generator/tree/0.18.7" + "source": "https://github.com/appwrite/sdk-generator/tree/0.18.8" }, - "time": "2022-05-19T09:55:58+00:00" + "time": "2022-05-19T10:34:06+00:00" }, { "name": "composer/pcre", From 90a4f4d756eba2e05313030aeac257bdf208f7be Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Thu, 19 May 2022 13:07:40 +0200 Subject: [PATCH 29/38] chore: update composer --- composer.json | 2 +- composer.lock | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 1cd1236d0f..79f144c068 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,7 @@ "utopia-php/preloader": "0.2.*", "utopia-php/domains": "1.1.*", "utopia-php/swoole": "0.3.*", - "utopia-php/storage": "0.7.*", + "utopia-php/storage": "0.9.*", "utopia-php/websocket": "0.1.0", "utopia-php/image": "0.5.*", "utopia-php/orchestration": "0.4.*", diff --git a/composer.lock b/composer.lock index 69aadee3ae..ece1c7694e 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "69e0c12a4c4b22cf17727f5b8833b1ac", + "content-hash": "78be7780db881871009109a373b2fc35", "packages": [ { "name": "adhocore/jwt", @@ -2628,16 +2628,16 @@ }, { "name": "utopia-php/storage", - "version": "0.7.1", + "version": "0.9.0", "source": { "type": "git", "url": "https://github.com/utopia-php/storage.git", - "reference": "1921d5da3d155c1e03b26f8f6184dba3a69cd5e4" + "reference": "c7912481a56e17cc86358fa8de57309de5e88ef7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/storage/zipball/1921d5da3d155c1e03b26f8f6184dba3a69cd5e4", - "reference": "1921d5da3d155c1e03b26f8f6184dba3a69cd5e4", + "url": "https://api.github.com/repos/utopia-php/storage/zipball/c7912481a56e17cc86358fa8de57309de5e88ef7", + "reference": "c7912481a56e17cc86358fa8de57309de5e88ef7", "shasum": "" }, "require": { @@ -2674,9 +2674,9 @@ ], "support": { "issues": "https://github.com/utopia-php/storage/issues", - "source": "https://github.com/utopia-php/storage/tree/0.7.1" + "source": "https://github.com/utopia-php/storage/tree/0.9.0" }, - "time": "2022-02-20T13:27:43+00:00" + "time": "2022-05-19T11:05:45+00:00" }, { "name": "utopia-php/swoole", From 706ecc6b409956ec573d714488c7afaefb30386b Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Thu, 19 May 2022 13:53:11 +0200 Subject: [PATCH 30/38] fix: migration method --- src/Appwrite/Migration/Migration.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Appwrite/Migration/Migration.php b/src/Appwrite/Migration/Migration.php index 844923993f..0944b6e900 100644 --- a/src/Appwrite/Migration/Migration.php +++ b/src/Appwrite/Migration/Migration.php @@ -153,10 +153,10 @@ abstract class Migration /** * Checks 2 arrays for differences. - * - * @param array $array1 - * @param array $array2 - * @return bool + * + * @param array $array1 + * @param array $array2 + * @return bool */ public function hasDifference(array $array1, array $array2): bool { @@ -165,8 +165,7 @@ abstract class Migration if (!isset($array2[$key]) || !is_array($array2[$key])) { return true; } else { - $new_diff = $this->hasDifference($value, $array2[$key]); - if ($new_diff) { + if ($this->hasDifference($value, $array2[$key])) { return true; } } From 0a559a3562b4850540f45f65e3c3e66df24382b0 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Thu, 19 May 2022 14:17:18 +0200 Subject: [PATCH 31/38] tests: add more migration tests --- src/Appwrite/Migration/Migration.php | 6 +-- tests/unit/Migration/MigrationTest.php | 71 ++++++++++++++++++++++++-- 2 files changed, 71 insertions(+), 6 deletions(-) diff --git a/src/Appwrite/Migration/Migration.php b/src/Appwrite/Migration/Migration.php index 0944b6e900..99b3f9236d 100644 --- a/src/Appwrite/Migration/Migration.php +++ b/src/Appwrite/Migration/Migration.php @@ -124,7 +124,7 @@ abstract class Migration $old = $document->getArrayCopy(); $new = call_user_func($callback, $document); - if (!$this->hasDifference($new->getArrayCopy(), $old)) { + if (!self::hasDifference($new->getArrayCopy(), $old)) { return; } @@ -158,14 +158,14 @@ abstract class Migration * @param array $array2 * @return bool */ - public function hasDifference(array $array1, array $array2): bool + public static function hasDifference(array $array1, array $array2): bool { foreach ($array1 as $key => $value) { if (is_array($value)) { if (!isset($array2[$key]) || !is_array($array2[$key])) { return true; } else { - if ($this->hasDifference($value, $array2[$key])) { + if (self::hasDifference($value, $array2[$key])) { return true; } } diff --git a/tests/unit/Migration/MigrationTest.php b/tests/unit/Migration/MigrationTest.php index 340e33772c..fb7b47c0d0 100644 --- a/tests/unit/Migration/MigrationTest.php +++ b/tests/unit/Migration/MigrationTest.php @@ -4,6 +4,7 @@ namespace Appwrite\Tests; use Appwrite\Migration\Migration; use PHPUnit\Framework\TestCase; +use ReflectionClass; use ReflectionMethod; use Utopia\Database\Document; @@ -36,12 +37,76 @@ abstract class MigrationTest extends TestCase */ public function testMigrationVersions() { - require_once __DIR__.'/../../../app/init.php'; + require_once __DIR__ . '/../../../app/init.php'; foreach (Migration::$versions as $class) { - $this->assertTrue(class_exists('Appwrite\\Migration\\Version\\'.$class)); + $this->assertTrue(class_exists('Appwrite\\Migration\\Version\\' . $class)); } // Test if current version exists - //$this->assertArrayHasKey(APP_VERSION_STABLE, Migration::$versions); + $this->assertArrayHasKey(APP_VERSION_STABLE, Migration::$versions); + } + + public function testHasDifference() + { + $this->assertFalse(Migration::hasDifference([], [])); + $this->assertFalse(Migration::hasDifference([ + 'a' => true, + 'b' => 'abc', + 'c' => 123, + 'd' => ['a', 'b', 'c'], + 'nested' => [ + 'a' => true, + 'b' => 'abc', + 'c' => 123, + 'd' => ['a', 'b', 'c'] + ] + ], [ + 'a' => true, + 'b' => 'abc', + 'c' => 123, + 'd' => ['a', 'b', 'c'], + 'nested' => [ + 'a' => true, + 'b' => 'abc', + 'c' => 123, + 'd' => ['a', 'b', 'c'] + ] + ])); + $this->assertTrue(Migration::hasDifference([ + 'a' => true + ], [ + 'b' => true + ])); + $this->assertTrue(Migration::hasDifference([ + 'a' => 'true' + ], [ + 'a' => true + ])); + $this->assertTrue(Migration::hasDifference([ + 'a' => true + ], [ + 'a' => false + ])); + $this->assertTrue(Migration::hasDifference([ + 'nested' => [ + 'a' => true + ] + ], [ + 'nested' => [] + ])); + $this->assertTrue(Migration::hasDifference([ + 'nested' => [ + 'a' => true, + 'b' => 'abc', + 'c' => 123, + 'd' => ['a', 'b', 'c'] + ] + ], [ + 'nested' => [ + 'a' => true, + 'c' => '123', + 'd' => ['a', 'b', 'c'] + ] + ])); } } From 33486ee2eb124a291bae82f89abe7daac97484fb Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Thu, 19 May 2022 14:18:55 +0200 Subject: [PATCH 32/38] tests: fix naming in migration --- tests/unit/Migration/MigrationTest.php | 34 +++++++++++++------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/unit/Migration/MigrationTest.php b/tests/unit/Migration/MigrationTest.php index fb7b47c0d0..49aee87f58 100644 --- a/tests/unit/Migration/MigrationTest.php +++ b/tests/unit/Migration/MigrationTest.php @@ -50,22 +50,22 @@ abstract class MigrationTest extends TestCase { $this->assertFalse(Migration::hasDifference([], [])); $this->assertFalse(Migration::hasDifference([ - 'a' => true, - 'b' => 'abc', - 'c' => 123, - 'd' => ['a', 'b', 'c'], - 'nested' => [ + 'bool' => true, + 'string' => 'abc', + 'int' => 123, + 'array' => ['a', 'b', 'c'], + 'assoc' => [ 'a' => true, 'b' => 'abc', 'c' => 123, 'd' => ['a', 'b', 'c'] ] ], [ - 'a' => true, - 'b' => 'abc', - 'c' => 123, - 'd' => ['a', 'b', 'c'], - 'nested' => [ + 'bool' => true, + 'string' => 'abc', + 'int' => 123, + 'array' => ['a', 'b', 'c'], + 'assoc' => [ 'a' => true, 'b' => 'abc', 'c' => 123, @@ -95,17 +95,17 @@ abstract class MigrationTest extends TestCase 'nested' => [] ])); $this->assertTrue(Migration::hasDifference([ - 'nested' => [ - 'a' => true, - 'b' => 'abc', - 'c' => 123, - 'd' => ['a', 'b', 'c'] + 'assoc' => [ + 'bool' => true, + 'string' => 'abc', + 'int' => 123, + 'array' => ['a', 'b', 'c'] ] ], [ 'nested' => [ 'a' => true, - 'c' => '123', - 'd' => ['a', 'b', 'c'] + 'int' => '123', + 'array' => ['a', 'b', 'c'] ] ])); } From 3199baa14fac55d0ed1a5b14c4929a862bc03224 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Thu, 19 May 2022 14:21:21 +0200 Subject: [PATCH 33/38] tests: add more variety to migration tests --- tests/unit/Migration/MigrationTest.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/unit/Migration/MigrationTest.php b/tests/unit/Migration/MigrationTest.php index 49aee87f58..0c8c34cbc8 100644 --- a/tests/unit/Migration/MigrationTest.php +++ b/tests/unit/Migration/MigrationTest.php @@ -72,6 +72,30 @@ abstract class MigrationTest extends TestCase 'd' => ['a', 'b', 'c'] ] ])); + $this->assertFalse(Migration::hasDifference([ + 'bool' => true, + 'string' => 'abc', + 'int' => 123, + 'array' => ['a', 'b', 'c'], + 'assoc' => [ + 'a' => true, + 'b' => 'abc', + 'c' => 123, + 'd' => ['a', 'b', 'c'] + ] + ], [ + 'string' => 'abc', + 'assoc' => [ + 'a' => true, + 'b' => 'abc', + 'c' => 123, + 'd' => ['a', 'b', 'c'] + ], + 'int' => 123, + 'array' => ['a', 'b', 'c'], + 'bool' => true, + + ])); $this->assertTrue(Migration::hasDifference([ 'a' => true ], [ From a00a35a02c88bdbb307207c983a2a4b408d7f7ba Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Thu, 19 May 2022 15:19:51 +0200 Subject: [PATCH 34/38] chore: prepare 0.14.2 release --- README-CN.md | 6 +++--- README.md | 6 +++--- app/init.php | 2 +- src/Appwrite/Migration/Migration.php | 1 + 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/README-CN.md b/README-CN.md index f95bd12f93..7a10dee770 100644 --- a/README-CN.md +++ b/README-CN.md @@ -59,7 +59,7 @@ docker run -it --rm \ --volume /var/run/docker.sock:/var/run/docker.sock \ --volume "$(pwd)"/appwrite:/usr/src/code/appwrite:rw \ --entrypoint="install" \ - appwrite/appwrite:0.14.1 + appwrite/appwrite:0.14.2 ``` ### Windows @@ -71,7 +71,7 @@ docker run -it --rm ^ --volume //var/run/docker.sock:/var/run/docker.sock ^ --volume "%cd%"/appwrite:/usr/src/code/appwrite:rw ^ --entrypoint="install" ^ - appwrite/appwrite:0.14.1 + appwrite/appwrite:0.14.2 ``` #### PowerShell @@ -81,7 +81,7 @@ docker run -it --rm , --volume /var/run/docker.sock:/var/run/docker.sock , --volume ${pwd}/appwrite:/usr/src/code/appwrite:rw , --entrypoint="install" , - appwrite/appwrite:0.14.1 + appwrite/appwrite:0.14.2 ``` 运行后,可以在浏览器上访问 http://localhost 找到 Appwrite 控制台。在非 Linux 的本机主机上完成安装后,服务器可能需要几分钟才能启动。 diff --git a/README.md b/README.md index 5254547afa..e67e4f3bad 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ docker run -it --rm \ --volume /var/run/docker.sock:/var/run/docker.sock \ --volume "$(pwd)"/appwrite:/usr/src/code/appwrite:rw \ --entrypoint="install" \ - appwrite/appwrite:0.14.1 + appwrite/appwrite:0.14.2 ``` ### Windows @@ -74,7 +74,7 @@ docker run -it --rm ^ --volume //var/run/docker.sock:/var/run/docker.sock ^ --volume "%cd%"/appwrite:/usr/src/code/appwrite:rw ^ --entrypoint="install" ^ - appwrite/appwrite:0.14.1 + appwrite/appwrite:0.14.2 ``` #### PowerShell @@ -84,7 +84,7 @@ docker run -it --rm , --volume /var/run/docker.sock:/var/run/docker.sock , --volume ${pwd}/appwrite:/usr/src/code/appwrite:rw , --entrypoint="install" , - appwrite/appwrite:0.14.1 + appwrite/appwrite:0.14.2 ``` Once the Docker installation completes, go to http://localhost to access the Appwrite console from your browser. Please note that on non-Linux native hosts, the server might take a few minutes to start after installation completes. diff --git a/app/init.php b/app/init.php index 2a5d19ad74..7e501b84a6 100644 --- a/app/init.php +++ b/app/init.php @@ -78,7 +78,7 @@ const APP_LIMIT_ENCRYPTION = 20000000; //20MB const APP_LIMIT_COMPRESSION = 20000000; //20MB const APP_LIMIT_ARRAY_PARAMS_SIZE = 100; // Default maximum of how many elements can there be in API parameter that expects array value const APP_CACHE_BUSTER = 305; -const APP_VERSION_STABLE = '0.14.1'; +const APP_VERSION_STABLE = '0.14.2'; const APP_DATABASE_ATTRIBUTE_EMAIL = 'email'; const APP_DATABASE_ATTRIBUTE_ENUM = 'enum'; const APP_DATABASE_ATTRIBUTE_IP = 'ip'; diff --git a/src/Appwrite/Migration/Migration.php b/src/Appwrite/Migration/Migration.php index b479a42262..391b69ecea 100644 --- a/src/Appwrite/Migration/Migration.php +++ b/src/Appwrite/Migration/Migration.php @@ -44,6 +44,7 @@ abstract class Migration '0.13.4' => 'V12', '0.14.0' => 'V13', '0.14.1' => 'V13', + '0.14.2' => 'V13', ]; /** From 343277f5b643c6029ef472e3dec0293d436faf94 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Thu, 19 May 2022 15:28:22 +0200 Subject: [PATCH 35/38] chore: update readme --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index c86ea04ed1..745469bf7e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,7 @@ - Support for Backblaze adapter in Storage - Support for Linode adapter in Storage - Support for Wasabi adapter in Storage +- Improved overall Migration speed # Version 0.14.1 From 1ff930c846be76933187c5803611755f83069070 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Thu, 19 May 2022 16:29:30 +0200 Subject: [PATCH 36/38] chore: update changelog --- CHANGES.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 745469bf7e..30b5b1e7db 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,8 +5,14 @@ - Support for Backblaze adapter in Storage - Support for Linode adapter in Storage - Support for Wasabi adapter in Storage +- New Cloud Function Runtimes: + - Dart 2.17 + - Deno 1.21 + - Java 18 + - Node 18 - Improved overall Migration speed + # Version 0.14.1 ## Bugs From c77285643b023f3c0398a6a3e582477662d5ab03 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Thu, 19 May 2022 17:06:39 +0200 Subject: [PATCH 37/38] fix: compose install template --- app/views/install/compose.phtml | 90 +++++++++++++++++++++++---------- 1 file changed, 63 insertions(+), 27 deletions(-) diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index b4cc31233a..6fa8335bfa 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -4,30 +4,6 @@ x-logging: &x-logging options: max-file: '5' max-size: '10m' - -x-env-storage: &x-env-storage |- - _APP_STORAGE_DEVICE - _APP_STORAGE_S3_ACCESS_KEY - _APP_STORAGE_S3_SECRET - _APP_STORAGE_S3_REGION - _APP_STORAGE_S3_BUCKET - _APP_STORAGE_DO_SPACES_ACCESS_KEY - _APP_STORAGE_DO_SPACES_SECRET - _APP_STORAGE_DO_SPACES_REGION - _APP_STORAGE_DO_SPACES_BUCKET - _APP_STORAGE_BACKBLAZE_ACCESS_KEY - _APP_STORAGE_BACKBLAZE_SECRET - _APP_STORAGE_BACKBLAZE_REGION - _APP_STORAGE_BACKBLAZE_BUCKET - _APP_STORAGE_LINODE_ACCESS_KEY - _APP_STORAGE_LINODE_SECRET - _APP_STORAGE_LINODE_REGION - _APP_STORAGE_LINODE_BUCKET - _APP_STORAGE_WASABI_ACCESS_KEY - _APP_STORAGE_WASABI_SECRET - _APP_STORAGE_WASABI_REGION - _APP_STORAGE_WASABI_BUCKET - getParam('httpPort', ''); @@ -134,7 +110,27 @@ services: - _APP_STORAGE_ANTIVIRUS - _APP_STORAGE_ANTIVIRUS_HOST - _APP_STORAGE_ANTIVIRUS_PORT - - *x-env-storage + - _APP_STORAGE_DEVICE + - _APP_STORAGE_S3_ACCESS_KEY + - _APP_STORAGE_S3_SECRET + - _APP_STORAGE_S3_REGION + - _APP_STORAGE_S3_BUCKET + - _APP_STORAGE_DO_SPACES_ACCESS_KEY + - _APP_STORAGE_DO_SPACES_SECRET + - _APP_STORAGE_DO_SPACES_REGION + - _APP_STORAGE_DO_SPACES_BUCKET + - _APP_STORAGE_BACKBLAZE_ACCESS_KEY + - _APP_STORAGE_BACKBLAZE_SECRET + - _APP_STORAGE_BACKBLAZE_REGION + - _APP_STORAGE_BACKBLAZE_BUCKET + - _APP_STORAGE_LINODE_ACCESS_KEY + - _APP_STORAGE_LINODE_SECRET + - _APP_STORAGE_LINODE_REGION + - _APP_STORAGE_LINODE_BUCKET + - _APP_STORAGE_WASABI_ACCESS_KEY + - _APP_STORAGE_WASABI_SECRET + - _APP_STORAGE_WASABI_REGION + - _APP_STORAGE_WASABI_BUCKET - _APP_FUNCTIONS_SIZE_LIMIT - _APP_FUNCTIONS_TIMEOUT - _APP_FUNCTIONS_BUILD_TIMEOUT @@ -273,7 +269,27 @@ services: - _APP_DB_SCHEMA - _APP_DB_USER - _APP_DB_PASS - - *x-env-storage + - _APP_STORAGE_DEVICE + - _APP_STORAGE_S3_ACCESS_KEY + - _APP_STORAGE_S3_SECRET + - _APP_STORAGE_S3_REGION + - _APP_STORAGE_S3_BUCKET + - _APP_STORAGE_DO_SPACES_ACCESS_KEY + - _APP_STORAGE_DO_SPACES_SECRET + - _APP_STORAGE_DO_SPACES_REGION + - _APP_STORAGE_DO_SPACES_BUCKET + - _APP_STORAGE_BACKBLAZE_ACCESS_KEY + - _APP_STORAGE_BACKBLAZE_SECRET + - _APP_STORAGE_BACKBLAZE_REGION + - _APP_STORAGE_BACKBLAZE_BUCKET + - _APP_STORAGE_LINODE_ACCESS_KEY + - _APP_STORAGE_LINODE_SECRET + - _APP_STORAGE_LINODE_REGION + - _APP_STORAGE_LINODE_BUCKET + - _APP_STORAGE_WASABI_ACCESS_KEY + - _APP_STORAGE_WASABI_SECRET + - _APP_STORAGE_WASABI_REGION + - _APP_STORAGE_WASABI_BUCKET - _APP_LOGGING_PROVIDER - _APP_LOGGING_CONFIG - _APP_EXECUTOR_SECRET @@ -430,7 +446,27 @@ services: - OPEN_RUNTIMES_NETWORK - _APP_LOGGING_PROVIDER - _APP_LOGGING_CONFIG - - *x-env-storage + - _APP_STORAGE_DEVICE + - _APP_STORAGE_S3_ACCESS_KEY + - _APP_STORAGE_S3_SECRET + - _APP_STORAGE_S3_REGION + - _APP_STORAGE_S3_BUCKET + - _APP_STORAGE_DO_SPACES_ACCESS_KEY + - _APP_STORAGE_DO_SPACES_SECRET + - _APP_STORAGE_DO_SPACES_REGION + - _APP_STORAGE_DO_SPACES_BUCKET + - _APP_STORAGE_BACKBLAZE_ACCESS_KEY + - _APP_STORAGE_BACKBLAZE_SECRET + - _APP_STORAGE_BACKBLAZE_REGION + - _APP_STORAGE_BACKBLAZE_BUCKET + - _APP_STORAGE_LINODE_ACCESS_KEY + - _APP_STORAGE_LINODE_SECRET + - _APP_STORAGE_LINODE_REGION + - _APP_STORAGE_LINODE_BUCKET + - _APP_STORAGE_WASABI_ACCESS_KEY + - _APP_STORAGE_WASABI_SECRET + - _APP_STORAGE_WASABI_REGION + - _APP_STORAGE_WASABI_BUCKET - DOCKERHUB_PULL_USERNAME - DOCKERHUB_PULL_PASSWORD From f9056d1dcae27563b40b80f5c65908260f17d39e Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Thu, 19 May 2022 17:31:04 +0200 Subject: [PATCH 38/38] update: composer --- composer.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.lock b/composer.lock index ece1c7694e..9b4fe66f57 100644 --- a/composer.lock +++ b/composer.lock @@ -115,11 +115,11 @@ }, { "name": "appwrite/php-runtimes", - "version": "0.9.0", + "version": "0.9.1", "source": { "type": "git", "url": "https://github.com/appwrite/runtimes.git", - "reference": "e8aa94aa42f45711e11cb1da401b442ecc2c32a4" + "reference": "01acf8741f539f64248d54a9f0f6c4d39195d16c" }, "require": { "php": ">=8.0", @@ -154,7 +154,7 @@ "php", "runtimes" ], - "time": "2022-05-16T10:54:14+00:00" + "time": "2022-05-19T11:48:16+00:00" }, { "name": "chillerlan/php-qrcode",