From 494ae40088a4cc6b0a2b131b692f92780e76486e Mon Sep 17 00:00:00 2001 From: songtianlun Date: Wed, 22 Jan 2025 17:26:06 +0800 Subject: [PATCH] chore: update storage configuration for production - Change active storage service to use `:build` or `:amazon` - Added a new `build` service for local disk storage This update allows for better flexibility in managing file storage based on the environment. The configuration now checks the `RAILS_BUILD` environment variable to decide on the storage service, making it easier to handle local testing and production deployments without manual adjustments. --- config/environments/production.rb | 2 +- config/storage.yml | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index cb4aed0..7117d2f 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -22,7 +22,7 @@ Rails.application.configure do # config.asset_host = "http://assets.example.com" # Store uploaded files on the local file system (see config/storage.yml for options). - config.active_storage.service = :amazon + config.active_storage.service = ENV["RAILS_BUILD"] ? :build : :amazon # Assume all access to the app is happening through a SSL-terminating reverse proxy. config.assume_ssl = true diff --git a/config/storage.yml b/config/storage.yml index f0c3c9a..4dedeb4 100644 --- a/config/storage.yml +++ b/config/storage.yml @@ -6,6 +6,10 @@ local: service: Disk root: <%= Rails.root.join("storage") %> +build: + service: Disk + root: <%= Rails.root.join("tmp/storage") %> + # Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) # amazon: # service: S3