feat: option to skip s3 bucket creation (#852)
This commit is contained in:
parent
f19e9b0498
commit
03fdcf4621
|
|
@ -78,8 +78,12 @@ GOTRUE_EXTERNAL_APPLE_SECRET=
|
||||||
GOTRUE_EXTERNAL_APPLE_REDIRECT_URI=http://your-host/gotrue/callback
|
GOTRUE_EXTERNAL_APPLE_REDIRECT_URI=http://your-host/gotrue/callback
|
||||||
|
|
||||||
# File Storage
|
# File Storage
|
||||||
# This is where storage like images, files, etc. will be stored
|
# Create the bucket if not exists on AppFlowy Cloud start up.
|
||||||
# By default, Minio is used as the default file storage which uses host's file system
|
# 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_USE_MINIO=true
|
||||||
APPFLOWY_S3_MINIO_URL=http://minio:9000 # change this if you are using a different address for minio
|
APPFLOWY_S3_MINIO_URL=http://minio:9000 # change this if you are using a different address for minio
|
||||||
APPFLOWY_S3_ACCESS_KEY=minioadmin
|
APPFLOWY_S3_ACCESS_KEY=minioadmin
|
||||||
|
|
|
||||||
1
dev.env
1
dev.env
|
|
@ -76,6 +76,7 @@ GOTRUE_EXTERNAL_APPLE_SECRET=
|
||||||
GOTRUE_EXTERNAL_APPLE_REDIRECT_URI=http://localhost:9999/callback
|
GOTRUE_EXTERNAL_APPLE_REDIRECT_URI=http://localhost:9999/callback
|
||||||
|
|
||||||
# File Storage
|
# File Storage
|
||||||
|
APPFLOWY_S3_CREATE_BUCKET=true
|
||||||
APPFLOWY_S3_USE_MINIO=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_MINIO_URL=http://localhost:9000 # change this if you are using a different address for minio
|
||||||
APPFLOWY_S3_ACCESS_KEY=minioadmin
|
APPFLOWY_S3_ACCESS_KEY=minioadmin
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,7 @@ services:
|
||||||
- APPFLOWY_GOTRUE_EXT_URL=${API_EXTERNAL_URL}
|
- APPFLOWY_GOTRUE_EXT_URL=${API_EXTERNAL_URL}
|
||||||
- APPFLOWY_GOTRUE_ADMIN_EMAIL=${GOTRUE_ADMIN_EMAIL}
|
- APPFLOWY_GOTRUE_ADMIN_EMAIL=${GOTRUE_ADMIN_EMAIL}
|
||||||
- APPFLOWY_GOTRUE_ADMIN_PASSWORD=${GOTRUE_ADMIN_PASSWORD}
|
- 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_USE_MINIO=${APPFLOWY_S3_USE_MINIO}
|
||||||
- APPFLOWY_S3_MINIO_URL=${APPFLOWY_S3_MINIO_URL}
|
- APPFLOWY_S3_MINIO_URL=${APPFLOWY_S3_MINIO_URL}
|
||||||
- APPFLOWY_S3_ACCESS_KEY=${APPFLOWY_S3_ACCESS_KEY}
|
- APPFLOWY_S3_ACCESS_KEY=${APPFLOWY_S3_ACCESS_KEY}
|
||||||
|
|
|
||||||
|
|
@ -461,7 +461,11 @@ pub async fn get_aws_s3_client(s3_setting: &S3Setting) -> Result<aws_sdk_s3::Cli
|
||||||
config_builder.build()
|
config_builder.build()
|
||||||
};
|
};
|
||||||
let client = aws_sdk_s3::Client::from_conf(config);
|
let client = aws_sdk_s3::Client::from_conf(config);
|
||||||
create_bucket_if_not_exists(&client, s3_setting).await?;
|
if s3_setting.create_bucket {
|
||||||
|
create_bucket_if_not_exists(&client, s3_setting).await?;
|
||||||
|
} else {
|
||||||
|
info!("Skipping bucket creation, assumed to be created externally");
|
||||||
|
}
|
||||||
Ok(client)
|
Ok(client)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ pub struct CasbinSetting {
|
||||||
|
|
||||||
#[derive(serde::Deserialize, Clone, Debug)]
|
#[derive(serde::Deserialize, Clone, Debug)]
|
||||||
pub struct S3Setting {
|
pub struct S3Setting {
|
||||||
|
pub create_bucket: bool,
|
||||||
pub use_minio: bool,
|
pub use_minio: bool,
|
||||||
pub minio_url: String,
|
pub minio_url: String,
|
||||||
pub access_key: String,
|
pub access_key: String,
|
||||||
|
|
@ -205,6 +206,9 @@ pub fn get_configuration() -> Result<Config, anyhow::Error> {
|
||||||
},
|
},
|
||||||
redis_uri: get_env_var("APPFLOWY_REDIS_URI", "redis://localhost:6379").into(),
|
redis_uri: get_env_var("APPFLOWY_REDIS_URI", "redis://localhost:6379").into(),
|
||||||
s3: S3Setting {
|
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")
|
use_minio: get_env_var("APPFLOWY_S3_USE_MINIO", "true")
|
||||||
.parse()
|
.parse()
|
||||||
.context("fail to get APPFLOWY_S3_USE_MINIO")?,
|
.context("fail to get APPFLOWY_S3_USE_MINIO")?,
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ impl Deref for TestBucket {
|
||||||
impl TestBucket {
|
impl TestBucket {
|
||||||
pub async fn new() -> Self {
|
pub async fn new() -> Self {
|
||||||
let setting = S3Setting {
|
let setting = S3Setting {
|
||||||
|
create_bucket: true,
|
||||||
use_minio: true,
|
use_minio: true,
|
||||||
minio_url: LOCALHOST_MINIO_URL.to_string(),
|
minio_url: LOCALHOST_MINIO_URL.to_string(),
|
||||||
access_key: LOCALHOST_MINIO_ACCESS_KEY.to_string(),
|
access_key: LOCALHOST_MINIO_ACCESS_KEY.to_string(),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue