From e72f29a26e8ff95ce7ebc3c6b734b7bd64bf8f38 Mon Sep 17 00:00:00 2001 From: Sojan Jose Date: Wed, 22 Jul 2020 11:53:47 +0530 Subject: [PATCH] Chore: Update storage to support s3 compatible services (#1082) This change is to allow using s3 compatible services such as DigitalOcean spaces, Minio, etc Co-authored-by: petebytes Co-authored-by: Pranav Raj S --- config/environments/development.rb | 2 +- config/storage.yml | 9 +++++++++ .../project-setup/configuring-cloud-storage.md | 16 ++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/config/environments/development.rb b/config/environments/development.rb index 88ebfe82c..bdba46ea3 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -30,7 +30,7 @@ Rails.application.configure do config.public_file_server.enabled = true # Store uploaded files on the local file system (see config/storage.yml for options). - config.active_storage.service = :local + config.active_storage.service = ENV.fetch('ACTIVE_STORAGE_SERVICE', 'local').to_sym config.active_job.queue_adapter = :sidekiq diff --git a/config/storage.yml b/config/storage.yml index a44d0381d..ba053d00e 100644 --- a/config/storage.yml +++ b/config/storage.yml @@ -28,6 +28,15 @@ microsoft: storage_access_key: <%= ENV.fetch('AZURE_STORAGE_ACCESS_KEY', '') %> container: <%= ENV.fetch('AZURE_STORAGE_CONTAINER', '') %> +# s3 compatible service such as DigitalOcean Spaces, Minio. +s3_compatible: + service: S3 + access_key_id: <%= ENV.fetch('STORAGE_ACCESS_KEY_ID', '') %> + secret_access_key: <%= ENV.fetch('STORAGE_SECRET_ACCESS_KEY', '') %> + region: <%= ENV.fetch('STORAGE_REGION', '') %> + bucket: <%= ENV.fetch('STORAGE_BUCKET_NAME', '') %> + endpoint: <%= ENV.fetch('STORAGE_ENDPOINT', '') %> + # mirror: # service: Mirror # primary: local diff --git a/docs/development/project-setup/configuring-cloud-storage.md b/docs/development/project-setup/configuring-cloud-storage.md index ccdcf7da4..d0390eb4b 100644 --- a/docs/development/project-setup/configuring-cloud-storage.md +++ b/docs/development/project-setup/configuring-cloud-storage.md @@ -56,3 +56,19 @@ AZURE_STORAGE_ACCOUNT_NAME= AZURE_STORAGE_ACCESS_KEY= AZURE_STORAGE_CONTAINER= ``` + + +### Using Amazon S3 Compatible Service + +Use s3 compatible service such as [DigitalOcean Spaces](https://www.digitalocean.com/docs/spaces/resources/s3-sdk-examples/#configure-a-client), Minio. + +Configure the following env variables. + +```bash +ACTIVE_STORAGE_SERVICE='s3_compatible' +STORAGE_BUCKET_NAME= +STORAGE_ACCESS_KEY_ID= +STORAGE_SECRET_ACCESS_KEY= +STORAGE_REGION=nyc3 +STORAGE_ENDPOINT=https://nyc3.digitaloceanspaces.com +```