From f03a68fbfece1f98df1302fe97e6a599667970a7 Mon Sep 17 00:00:00 2001 From: Everly Precia Suresh Date: Fri, 18 Mar 2022 17:17:43 +0000 Subject: [PATCH] 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); } } }