From 03fdcf4621c98b0056a4f5c0f2fc2aa407023379 Mon Sep 17 00:00:00 2001 From: Khor Shu Heng <32997938+khorshuheng@users.noreply.github.com> Date: Wed, 2 Oct 2024 09:54:46 +0800 Subject: [PATCH] feat: option to skip s3 bucket creation (#852) --- deploy.env | 8 ++++++-- dev.env | 1 + docker-compose.yml | 1 + src/application.rs | 6 +++++- src/config/config.rs | 4 ++++ tests/file_test/mod.rs | 1 + 6 files changed, 18 insertions(+), 3 deletions(-) diff --git a/deploy.env b/deploy.env index b823976d..743592e5 100644 --- a/deploy.env +++ b/deploy.env @@ -78,8 +78,12 @@ GOTRUE_EXTERNAL_APPLE_SECRET= GOTRUE_EXTERNAL_APPLE_REDIRECT_URI=http://your-host/gotrue/callback # File Storage -# This is where storage like images, files, etc. will be stored -# By default, Minio is used as the default file storage which uses host's file system +# Create the bucket if not exists on AppFlowy Cloud start up. +# Set this to false if the bucket has been created externally. +APPFLOWY_S3_CREATE_BUCKET=true +# This is where storage like images, files, etc. will be stored. +# By default, Minio is used as the default file storage which uses host's file system. +# Keep this as true if you are using other S3 compatible storage provider other than AWS. APPFLOWY_S3_USE_MINIO=true APPFLOWY_S3_MINIO_URL=http://minio:9000 # change this if you are using a different address for minio APPFLOWY_S3_ACCESS_KEY=minioadmin diff --git a/dev.env b/dev.env index c6cbfbee..8a79184b 100644 --- a/dev.env +++ b/dev.env @@ -76,6 +76,7 @@ GOTRUE_EXTERNAL_APPLE_SECRET= GOTRUE_EXTERNAL_APPLE_REDIRECT_URI=http://localhost:9999/callback # File Storage +APPFLOWY_S3_CREATE_BUCKET=true APPFLOWY_S3_USE_MINIO=true APPFLOWY_S3_MINIO_URL=http://localhost:9000 # change this if you are using a different address for minio APPFLOWY_S3_ACCESS_KEY=minioadmin diff --git a/docker-compose.yml b/docker-compose.yml index 5ebf11f9..a25cc112 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -98,6 +98,7 @@ services: - APPFLOWY_GOTRUE_EXT_URL=${API_EXTERNAL_URL} - APPFLOWY_GOTRUE_ADMIN_EMAIL=${GOTRUE_ADMIN_EMAIL} - APPFLOWY_GOTRUE_ADMIN_PASSWORD=${GOTRUE_ADMIN_PASSWORD} + - APPFLOWY_S3_CREATE_BUCKET=${APPFLOWY_S3_CREATE_BUCKET} - APPFLOWY_S3_USE_MINIO=${APPFLOWY_S3_USE_MINIO} - APPFLOWY_S3_MINIO_URL=${APPFLOWY_S3_MINIO_URL} - APPFLOWY_S3_ACCESS_KEY=${APPFLOWY_S3_ACCESS_KEY} diff --git a/src/application.rs b/src/application.rs index 192f22fb..d4472925 100644 --- a/src/application.rs +++ b/src/application.rs @@ -461,7 +461,11 @@ pub async fn get_aws_s3_client(s3_setting: &S3Setting) -> Result Result { }, redis_uri: get_env_var("APPFLOWY_REDIS_URI", "redis://localhost:6379").into(), s3: S3Setting { + create_bucket: get_env_var("APPFLOWY_S3_CREATE_BUCKET", "true") + .parse() + .context("fail to get APPFLOWY_S3_CREATE_BUCKET")?, use_minio: get_env_var("APPFLOWY_S3_USE_MINIO", "true") .parse() .context("fail to get APPFLOWY_S3_USE_MINIO")?, diff --git a/tests/file_test/mod.rs b/tests/file_test/mod.rs index 5e18da75..f06746e8 100644 --- a/tests/file_test/mod.rs +++ b/tests/file_test/mod.rs @@ -37,6 +37,7 @@ impl Deref for TestBucket { impl TestBucket { pub async fn new() -> Self { let setting = S3Setting { + create_bucket: true, use_minio: true, minio_url: LOCALHOST_MINIO_URL.to_string(), access_key: LOCALHOST_MINIO_ACCESS_KEY.to_string(),